This source file includes following definitions.
- m_floodOpacity
- create
- floodColor
- setFloodColor
- floodOpacity
- setFloodOpacity
- applySoftware
- createImageFilter
- externalRepresentation
#include "config.h"
#include "platform/graphics/filters/FEFlood.h"
#include "SkColorFilter.h"
#include "SkColorFilterImageFilter.h"
#include "SkFlattenableBuffers.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
#include "platform/text/TextStream.h"
#include "third_party/skia/include/core/SkDevice.h"
namespace WebCore {
FEFlood::FEFlood(Filter* filter, const Color& floodColor, float floodOpacity)
: FilterEffect(filter)
, m_floodColor(floodColor)
, m_floodOpacity(floodOpacity)
{
FilterEffect::setOperatingColorSpace(ColorSpaceDeviceRGB);
}
PassRefPtr<FEFlood> FEFlood::create(Filter* filter, const Color& floodColor, float floodOpacity)
{
return adoptRef(new FEFlood(filter, floodColor, floodOpacity));
}
Color FEFlood::floodColor() const
{
return m_floodColor;
}
bool FEFlood::setFloodColor(const Color& color)
{
if (m_floodColor == color)
return false;
m_floodColor = color;
return true;
}
float FEFlood::floodOpacity() const
{
return m_floodOpacity;
}
bool FEFlood::setFloodOpacity(float floodOpacity)
{
if (m_floodOpacity == floodOpacity)
return false;
m_floodOpacity = floodOpacity;
return true;
}
void FEFlood::applySoftware()
{
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
return;
Color color = floodColor().combineWithAlpha(floodOpacity());
resultImage->context()->fillRect(FloatRect(FloatPoint(), absolutePaintRect().size()), color);
FilterEffect::setResultColorSpace(ColorSpaceDeviceRGB);
}
PassRefPtr<SkImageFilter> FEFlood::createImageFilter(SkiaImageFilterBuilder* builder)
{
Color color = floodColor().combineWithAlpha(floodOpacity());
SkImageFilter::CropRect rect = getCropRect(builder->cropOffset());
SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(color.rgb(), SkXfermode::kSrc_Mode));
return adoptRef(SkColorFilterImageFilter::Create(cf, 0, &rect));
}
TextStream& FEFlood::externalRepresentation(TextStream& ts, int indent) const
{
writeIndent(ts, indent);
ts << "[feFlood";
FilterEffect::externalRepresentation(ts);
ts << " flood-color=\"" << floodColor().nameForRenderTreeAsText() << "\" "
<< "flood-opacity=\"" << floodOpacity() << "\"]\n";
return ts;
}
}