#include "config.h"
#include "FEBlend.h"
#include "FEBlendNEON.h"
#include "Filter.h"
#include "FloatPoint.h"
#include "GraphicsContext.h"
#include <JavaScriptCore/Uint8ClampedArray.h>
#include <wtf/text/TextStream.h>
namespace WebCore {
FEBlend::FEBlend(Filter& filter, BlendMode mode)
: FilterEffect(filter)
, m_mode(mode)
{
}
Ref<FEBlend> FEBlend::create(Filter& filter, BlendMode mode)
{
return adoptRef(*new FEBlend(filter, mode));
}
bool FEBlend::setBlendMode(BlendMode mode)
{
if (m_mode == mode)
return false;
m_mode = mode;
return true;
}
#if !HAVE(ARM_NEON_INTRINSICS)
void FEBlend::platformApplySoftware()
{
FilterEffect* in = inputEffect(0);
FilterEffect* in2 = inputEffect(1);
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
return;
GraphicsContext& filterContext = resultImage->context();
ImageBuffer* imageBuffer = in->imageBufferResult();
ImageBuffer* imageBuffer2 = in2->imageBufferResult();
if (!imageBuffer || !imageBuffer2)
return;
filterContext.drawImageBuffer(*imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()));
filterContext.drawImageBuffer(*imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), { CompositeOperator::SourceOver, m_mode });
}
#endif
TextStream& FEBlend::externalRepresentation(TextStream& ts, RepresentationType representation) const
{
ts << indent << "[feBlend";
FilterEffect::externalRepresentation(ts, representation);
ts << " mode=\"" << (m_mode == BlendMode::Normal ? "normal" : compositeOperatorName(CompositeOperator::SourceOver, m_mode)) << "\"]\n";
TextStream::IndentScope indentScope(ts);
inputEffect(0)->externalRepresentation(ts, representation);
inputEffect(1)->externalRepresentation(ts, representation);
return ts;
}
}