diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-29 20:55:09 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-29 20:55:09 +0000 |
commit | 9a6eb0e1e8a8de7371cd9604f34619b8f87de66f (patch) | |
tree | 8564502495bbe823b0afa1d7370520e080f600f7 /gm/arithmode.cpp | |
parent | 1198e740d58abba5edc749c14ed088688b3e76ca (diff) |
Provide a GPU implementation of SkArithmeticMode, using a custom GrEffect exposed via asNewEffectOrCoeff().
Doing it this way required modifying the arithmode GM to use saveLayer()/restore() rather than creating an offscreen SkBitmap, since otherwise the compositing is always done in raster mode. Fixing that in turn exposed that SkArithmeticMode did not work in Picture mode, since it wasn't flattenable. Made it so.
Note: this will require rebaselining the arithmode GM (again).
R=bsalomon@google.com, reed@google.com
Originally committed: https://code.google.com/p/skia/source/detail?r=9324
Reverted: https://code.google.com/p/skia/source/detail?r=9325
Review URL: https://codereview.chromium.org/16064002
git-svn-id: http://skia.googlecode.com/svn/trunk@9330 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/arithmode.cpp')
-rw-r--r-- | gm/arithmode.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/gm/arithmode.cpp b/gm/arithmode.cpp index 2a97eca957..63be6c3871 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; |