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

Unified Diff: gm/blend.cpp

Issue 1094863003: add a GM to demo the blend bug (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: f Created 5 years, 8 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 | gyp/gmslides.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/blend.cpp
diff --git a/gm/blend.cpp b/gm/blend.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..90453a52246a2e668208a5898f25452b8b829e6c
--- /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);
+ }
+ }
+ }
+}
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698