aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-02-28 17:45:27 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-01 02:11:08 +0000
commitc61abeed8958a757c6b49937f28b63066148dd67 (patch)
tree483450579dc12b2c9e38a07c3d38feb008aeab10 /gm
parent822128b475c1782788f96e7a1a848d0affb878b1 (diff)
add isolate (init-with-previous) savelayer flag
BUG=skia:4884 Change-Id: If7fabf5cc2c87b870f48dfb87e27a2524fec5ae5 Reviewed-on: https://skia-review.googlesource.com/9045 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'gm')
-rw-r--r--gm/savelayer.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/gm/savelayer.cpp b/gm/savelayer.cpp
index 510fc2f1f4..6a01edd4f0 100644
--- a/gm/savelayer.cpp
+++ b/gm/savelayer.cpp
@@ -80,6 +80,8 @@ private:
typedef skiagm::GM INHERITED;
};
+DEF_GM(return new UnclippedSaveLayerGM(UnclippedSaveLayerGM::Mode::kClipped);)
+DEF_GM(return new UnclippedSaveLayerGM(UnclippedSaveLayerGM::Mode::kUnclipped);)
DEF_SIMPLE_GM(picture_savelayer, canvas, 320, 640) {
SkPaint paint1, paint2, paint3;
@@ -99,8 +101,23 @@ DEF_SIMPLE_GM(picture_savelayer, canvas, 320, 640) {
}
};
-//////////////////////////////////////////////////////////////////////////////
+#include "Resources.h"
-DEF_GM(return new UnclippedSaveLayerGM(UnclippedSaveLayerGM::Mode::kClipped);)
-DEF_GM(return new UnclippedSaveLayerGM(UnclippedSaveLayerGM::Mode::kUnclipped);)
+// Test kInitWithPrevious_SaveLayerFlag by drawing an image, save a layer with the flag, which
+// should seed the layer with the image (from below). Then we punch a hole in the layer and
+// restore with kPlus mode, which should show the mandrill super-bright on the outside, but
+// normal where we punched the hole.
+DEF_SIMPLE_GM(savelayer_initfromprev, canvas, 256, 256) {
+ canvas->drawImage(GetResourceAsImage("mandrill_256.png"), 0, 0, nullptr);
+
+ SkCanvas::SaveLayerRec rec;
+ SkPaint paint;
+ paint.setBlendMode(SkBlendMode::kPlus);
+ rec.fSaveLayerFlags = SkCanvas::kInitWithPrevious_SaveLayerFlag;
+ rec.fPaint = &paint;
+ canvas->saveLayer(rec);
+ paint.setBlendMode(SkBlendMode::kClear);
+ canvas->drawCircle(128, 128, 96, paint);
+ canvas->restore();
+};