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

Unified Diff: gm/arithmode.cpp

Issue 16064002: Provide a GPU implementation of SkArithmeticMode (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Don't attempt to write to inputColor. 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 | include/effects/SkArithmeticMode.h » ('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 2a97eca957e525762714d918faeb0f5fb1d6b0bd..63be6c387166660f22c03bcc98c3baad3ecac90a 100644
--- a/gm/arithmode.cpp
+++ b/gm/arithmode.cpp
@@ -54,18 +54,6 @@ static SkBitmap make_dst() {
return bm;
}
-static SkBitmap make_arith(const SkBitmap& src, const SkBitmap& dst,
- const SkScalar k[]) {
- SkBitmap bm = make_bm();
- SkCanvas canvas(bm);
- SkPaint paint;
- canvas.drawBitmap(dst, 0, 0, NULL);
- SkXfermode* xfer = SkArithmeticMode::Create(k[0], k[1], k[2], k[3]);
- paint.setXfermode(xfer)->unref();
- canvas.drawBitmap(src, 0, 0, &paint);
- return bm;
-}
-
static void show_k_text(SkCanvas* canvas, SkScalar x, SkScalar y, const SkScalar k[]) {
SkPaint paint;
paint.setTextSize(SkIntToScalar(24));
@@ -116,12 +104,18 @@ protected:
SkScalar gap = SkIntToScalar(src.width() + 20);
while (k < stop) {
SkScalar x = 0;
- SkBitmap res = make_arith(src, dst, k);
canvas->drawBitmap(src, x, y, NULL);
x += gap;
canvas->drawBitmap(dst, x, y, NULL);
x += gap;
- canvas->drawBitmap(res, x, y, NULL);
+ SkRect rect = SkRect::MakeXYWH(x, y, SkIntToScalar(WW), SkIntToScalar(HH));
+ canvas->saveLayer(&rect, NULL);
+ canvas->drawBitmap(dst, x, y, NULL);
+ SkXfermode* xfer = SkArithmeticMode::Create(k[0], k[1], k[2], k[3]);
+ SkPaint paint;
+ paint.setXfermode(xfer)->unref();
+ canvas->drawBitmap(src, x, y, &paint);
+ canvas->restore();
x += gap;
show_k_text(canvas, x, y, k);
k += 4;
« no previous file with comments | « no previous file | include/effects/SkArithmeticMode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698