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

Unified Diff: gm/arithmode.cpp

Issue 16125008: Implement SkXfermode image filter (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix GPU side of SkArithmeticMode to handle background input. Created 7 years, 7 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 | « no previous file | gm/xfermodeimagefilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/arithmode.cpp
diff --git a/gm/arithmode.cpp b/gm/arithmode.cpp
index 63be6c387166660f22c03bcc98c3baad3ecac90a..715103273271fd0c0542cbf0399539056f7376f0 100644
--- a/gm/arithmode.cpp
+++ b/gm/arithmode.cpp
@@ -11,7 +11,9 @@
#include "SkShader.h"
#include "SkArithmeticMode.h"
+#include "SkBitmapSource.h"
#include "SkGradientShader.h"
+#include "SkXfermodeImageFilter.h"
#define WW 100
#define HH 32
@@ -113,7 +115,15 @@ protected:
canvas->drawBitmap(dst, x, y, NULL);
SkXfermode* xfer = SkArithmeticMode::Create(k[0], k[1], k[2], k[3]);
SkPaint paint;
- paint.setXfermode(xfer)->unref();
+ if ((k - K) % 2 != 0) {
+ // Test out an arithmode filter created as an xfermode image filter
+ SkAutoTUnref<SkImageFilter> background(new SkBitmapSource(dst));
+ SkXfermode* xfer = SkArithmeticMode::Create(0, one, one, 0);
reed1 2013/05/30 20:42:44 I think this xfer leaks, and it makes us leak the
Stephen White 2013/05/30 20:50:26 Good point. This whole whole section never gets ex
+ SkAutoTUnref<SkImageFilter> filter(new SkXfermodeImageFilter(xfer, background));
+ paint.setImageFilter(filter);
+ } else {
+ paint.setXfermode(xfer)->unref();
+ }
canvas->drawBitmap(src, x, y, &paint);
canvas->restore();
x += gap;
« no previous file with comments | « no previous file | gm/xfermodeimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698