#include "config.h"
#include "FEFlood.h"
#include "Filter.h"
#include "GraphicsContext.h"
#include <wtf/text/TextStream.h>
namespace WebCore {
FEFlood::FEFlood(Filter& filter, const Color& floodColor, float floodOpacity)
: FilterEffect(filter)
, m_floodColor(floodColor)
, m_floodOpacity(floodOpacity)
{
}
Ref<FEFlood> FEFlood::create(Filter& filter, const Color& floodColor, float floodOpacity)
{
return adoptRef(*new FEFlood(filter, floodColor, floodOpacity));
}
bool FEFlood::setFloodColor(const Color& color)
{
if (m_floodColor == color)
return false;
m_floodColor = color;
return true;
}
bool FEFlood::setFloodOpacity(float floodOpacity)
{
if (m_floodOpacity == floodOpacity)
return false;
m_floodOpacity = floodOpacity;
return true;
}
void FEFlood::platformApplySoftware()
{
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
return;
float colorAlpha = floodColor().alpha() / 255.0;
auto color = colorWithOverrideAlpha(floodColor().rgb(), colorAlpha * floodOpacity());
resultImage->context().fillRect(FloatRect(FloatPoint(), absolutePaintRect().size()), color);
}
TextStream& FEFlood::externalRepresentation(TextStream& ts, RepresentationType representation) const
{
ts << indent << "[feFlood";
FilterEffect::externalRepresentation(ts, representation);
ts << " flood-color=\"" << floodColor().nameForRenderTreeAsText() << "\" "
<< "flood-opacity=\"" << floodOpacity() << "\"]\n";
return ts;
}
}