Replace the asAFoo() functions in SkImageFilter with canFilterImageGPU() and
onFilterImageGPU() virtuals. This allows each filter to implement its own GPU
processing code, even for multi-pass filters.
Review URL: http://codereview.appspot.com/6449075/
git-svn-id: http://skia.googlecode.com/svn/trunk@4900 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 869ba6d..3c2e385 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -8,6 +8,8 @@
#include "SkMorphologyImageFilter.h"
#include "SkBitmap.h"
#include "SkColorPriv.h"
+#include "GrContext.h"
+#include "GrTexture.h"
SkMorphologyImageFilter::SkMorphologyImageFilter(SkFlattenableReadBuffer& buffer)
: INHERITED(buffer) {
@@ -210,14 +212,16 @@
return true;
}
-bool SkDilateImageFilter::asADilate(SkISize* radius) const {
- *radius = this->radius();
- return true;
+GrTexture* SkDilateImageFilter::onFilterImageGPU(GrTexture* src, const SkRect& rect) {
+ return src->getContext()->applyMorphology(src, rect,
+ GrContext::kDilate_MorphologyType,
+ radius());
}
-bool SkErodeImageFilter::asAnErode(SkISize* radius) const {
- *radius = this->radius();
- return true;
+GrTexture* SkErodeImageFilter::onFilterImageGPU(GrTexture* src, const SkRect& rect) {
+ return src->getContext()->applyMorphology(src, rect,
+ GrContext::kErode_MorphologyType,
+ radius());
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkDilateImageFilter)