Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: src/core/SkImageFilter.cpp

Issue 13602013: Allow single-pass filters (which use asNewEffect()) to participate in the image filter DAG. This w… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix return value of SkImageFilter::asNewEffect(). Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/effects/SkMatrixConvolutionImageFilter.h ('k') | src/core/SkImageFilterUtils.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkImageFilter.cpp
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 56fb1ae47e356e25d1df5e847797152a42ac7a42..ba19a9772366818c620a8051f6c96a2e37698737 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -10,6 +10,11 @@
#include "SkBitmap.h"
#include "SkFlattenableBuffers.h"
#include "SkRect.h"
+#if SK_SUPPORT_GPU
+#include "GrContext.h"
+#include "GrTexture.h"
+#include "SkImageFilterUtils.h"
+#endif
SK_DEFINE_INST_COUNT(SkImageFilter)
@@ -104,12 +109,45 @@ bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const SkMatrix&,
}
bool SkImageFilter::canFilterImageGPU() const {
- return false;
+ return asNewEffect(NULL, NULL);
bsalomon 2013/04/08 19:38:30 this->
}
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result) {
- SkASSERT(false); // Should never be called, since canFilterImageGPU() returned false.
+#if SK_SUPPORT_GPU
+ SkBitmap input;
+ SkASSERT(fInputCount == 1);
+ if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, &input)) {
bsalomon 2013/04/08 19:38:30 this->
+ return false;
+ }
+ GrTexture* srcTexture = (GrTexture*) input.getTexture();
+ SkRect rect;
+ src.getBounds(&rect);
+ GrContext* context = srcTexture->getContext();
+
+ GrTextureDesc desc;
+ desc.fFlags = kRenderTarget_GrTextureFlagBit,
+ desc.fWidth = input.width();
+ desc.fHeight = input.height();
+ desc.fConfig = kRGBA_8888_GrPixelConfig;
+
+ GrAutoScratchTexture dst(context, desc);
+ GrContext::AutoMatrix am;
+ am.setIdentity(context);
+ GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget());
+ GrContext::AutoClip acs(context, rect);
+ GrEffectRef* effect;
+ asNewEffect(&effect, srcTexture);
bsalomon 2013/04/08 19:38:30 this->
+ SkASSERT(effect);
+ SkAutoUnref effectRef(effect);
+ GrPaint paint;
+ paint.colorStage(0)->setEffect(effect);
+ context->drawRect(paint, rect);
+ SkAutoTUnref<GrTexture> resultTex(dst.detach());
+ SkImageFilterUtils::WrapTexture(resultTex, input.width(), input.height(), result);
+ return true;
+#else
return false;
+#endif
}
bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
« no previous file with comments | « include/effects/SkMatrixConvolutionImageFilter.h ('k') | src/core/SkImageFilterUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698