#include "platform/graphics/filters/FEMorphology.h"
#include "SkMorphologyImageFilter.h"
-#include "platform/graphics/GraphicsContext.h"
-#include "platform/graphics/Image.h"
-#include "platform/graphics/filters/ParallelJobs.h"
+#include "platform/graphics/filters/Filter.h"
#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
#include "platform/text/TextStream.h"
-#include "wtf/Uint8ClampedArray.h"
-#include "wtf/Vector.h"
-using namespace std;
-
-namespace WebCore {
+namespace blink {
FEMorphology::FEMorphology(Filter* filter, MorphologyOperatorType type, float radiusX, float radiusY)
: FilterEffect(filter)
return true;
}
-void FEMorphology::applySoftware()
-{
- ImageBuffer* resultImage = createImageBufferResult();
- if (!resultImage)
- return;
-
- FilterEffect* in = inputEffect(0);
-
- IntRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
-
- setIsAlphaImage(in->isAlphaImage());
-
- float radiusX = filter()->applyHorizontalScale(m_radiusX);
- float radiusY = filter()->applyVerticalScale(m_radiusY);
-
- RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
-
- SkPaint paint;
- GraphicsContext* dstContext = resultImage->context();
- if (m_type == FEMORPHOLOGY_OPERATOR_DILATE)
- paint.setImageFilter(SkDilateImageFilter::Create(radiusX, radiusY))->unref();
- else if (m_type == FEMORPHOLOGY_OPERATOR_ERODE)
- paint.setImageFilter(SkErodeImageFilter::Create(radiusX, radiusY))->unref();
-
- SkRect bounds = SkRect::MakeWH(absolutePaintRect().width(), absolutePaintRect().height());
- dstContext->saveLayer(&bounds, &paint);
- dstContext->drawImage(image.get(), drawingRegion.location(), CompositeCopy);
- dstContext->restoreLayer();
-}
-
PassRefPtr<SkImageFilter> FEMorphology::createImageFilter(SkiaImageFilterBuilder* builder)
{
RefPtr<SkImageFilter> input(builder->build(inputEffect(0), operatingColorSpace()));
return ts;
}
-} // namespace WebCore
+} // namespace blink