This source file includes following definitions.
- create
- applySoftware
- createImageFilter
- externalRepresentation
#include "config.h"
#include "platform/graphics/filters/FEMerge.h"
#include "SkMergeImageFilter.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
#include "platform/text/TextStream.h"
#include "wtf/OwnPtr.h"
namespace WebCore {
FEMerge::FEMerge(Filter* filter)
: FilterEffect(filter)
{
}
PassRefPtr<FEMerge> FEMerge::create(Filter* filter)
{
return adoptRef(new FEMerge(filter));
}
void FEMerge::applySoftware()
{
unsigned size = numberOfEffectInputs();
ASSERT(size > 0);
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
return;
GraphicsContext* filterContext = resultImage->context();
for (unsigned i = 0; i < size; ++i) {
FilterEffect* in = inputEffect(i);
filterContext->drawImageBuffer(in->asImageBuffer(), drawingRegionOfInputImage(in->absolutePaintRect()));
}
}
PassRefPtr<SkImageFilter> FEMerge::createImageFilter(SkiaImageFilterBuilder* builder)
{
unsigned size = numberOfEffectInputs();
OwnPtr<RefPtr<SkImageFilter>[]> inputRefs = adoptArrayPtr(new RefPtr<SkImageFilter>[size]);
OwnPtr<SkImageFilter*[]> inputs = adoptArrayPtr(new SkImageFilter*[size]);
for (unsigned i = 0; i < size; ++i) {
inputRefs[i] = builder->build(inputEffect(i), operatingColorSpace());
inputs[i] = inputRefs[i].get();
}
SkImageFilter::CropRect rect = getCropRect(builder->cropOffset());
return adoptRef(new SkMergeImageFilter(inputs.get(), size, 0, &rect));
}
TextStream& FEMerge::externalRepresentation(TextStream& ts, int indent) const
{
writeIndent(ts, indent);
ts << "[feMerge";
FilterEffect::externalRepresentation(ts);
unsigned size = numberOfEffectInputs();
ASSERT(size > 0);
ts << " mergeNodes=\"" << size << "\"]\n";
for (unsigned i = 0; i < size; ++i)
inputEffect(i)->externalRepresentation(ts, indent + 1);
return ts;
}
}