aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-04-17 06:32:13 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-04-17 06:32:13 -0700
commit4afe21e864bebab22ff83aeaa04b5e11fe5698a2 (patch)
treecf062a265f32ad881d49a4f361cff6d86a84ad1c
parentca1a22ee534f0fcabed7fa06cbf3ea5068b489da (diff)
add a GM to demo the blend bug
-rw-r--r--gm/blend.cpp48
-rw-r--r--gyp/gmslides.gypi1
2 files changed, 49 insertions, 0 deletions
diff --git a/gm/blend.cpp b/gm/blend.cpp
new file mode 100644
index 0000000000..90453a5224
--- /dev/null
+++ b/gm/blend.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+
+DEF_SIMPLE_GM(blend, canvas, 300, 100) {
+ SkPaint p;
+
+ // All three of these blocks should be the same color.
+ canvas->save();
+ canvas->scale(100,100);
+
+ p.setColor(SK_ColorRED);
+ canvas->drawRect(SkRect::MakeXYWH(0,0,1,1), p);
+ p.setColor(0xFC008000);
+ canvas->drawRect(SkRect::MakeXYWH(0,0,1,1), p);
+
+ p.setColor(SK_ColorRED);
+ canvas->drawRect(SkRect::MakeXYWH(1,0,1,1), p);
+ canvas->saveLayer(NULL, NULL);
+ p.setColor(0xFC008000);
+ canvas->drawRect(SkRect::MakeXYWH(1,0,1,1), p);
+ canvas->restore();
+
+ p.setColor(SK_ColorRED);
+ canvas->drawRect(SkRect::MakeXYWH(2,0,1,1), p);
+ canvas->saveLayerAlpha(NULL, 0xFC);
+ p.setColor(0xFF008000);
+ canvas->drawRect(SkRect::MakeXYWH(2,0,1,1), p);
+ canvas->restore();
+ canvas->restore();
+
+ // Print out the colors in each block (if we're looking at 8888 raster).
+ if (canvas->imageInfo().colorType() == kN32_SkColorType) {
+ if (const SkPMColor* px = (const SkPMColor*)canvas->peekPixels(NULL, NULL)) {
+ p.setColor(SK_ColorWHITE);
+ for (int i = 0; i < 3; i++) {
+ SkPMColor c = px[i * 100];
+ SkString text = SkStringPrintf("0x%08x", c);
+ canvas->drawText(text.c_str(), text.size(), i * 100.0f + 20.0f, 50.0f, p);
+ }
+ }
+ }
+}
diff --git a/gyp/gmslides.gypi b/gyp/gmslides.gypi
index dfaad55910..b0eaaaf5fc 100644
--- a/gyp/gmslides.gypi
+++ b/gyp/gmslides.gypi
@@ -42,6 +42,7 @@
'../gm/bitmapsource.cpp',
'../gm/bitmapsource2.cpp',
'../gm/bleed.cpp',
+ '../gm/blend.cpp',
'../gm/blurcircles.cpp',
'../gm/blurs.cpp',
'../gm/blurquickreject.cpp',