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

Unified Diff: gm/colorwheel.cpp

Issue 680533002: add gm: colorwheel (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: all mtklein suggestions Created 6 years, 2 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 | gm/gm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/colorwheel.cpp
diff --git a/gm/colorwheel.cpp b/gm/colorwheel.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d780fff1396ae0fecc0f2fc5bfabe319748b6050
--- /dev/null
+++ b/gm/colorwheel.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Resources.h"
+#include "SkData.h"
+#include "SkDecodingImageGenerator.h"
+#include "gm.h"
+
+static void checkerboard(SkCanvas* canvas, int w, int h) {
+ SkASSERT(w > 0);
+ SkASSERT(h > 0);
+ w = ((w - 1) | 0xF) + 1;
+ h = ((h - 1) | 0xF) + 1;
+ SkPaint light;
+ light.setColor(0xFF999999);
+ canvas->drawRect(SkRect::MakeXYWH(0, 0, w, h), light);
+ SkPaint dark;
+ dark.setColor(0xFF666666);
+ for (int y = 0; y < w; y += 16) {
+ SkScalar ty = SkIntToScalar(y);
+ for (int x = 0; x < h; x += 16) {
+ SkScalar tx = SkIntToScalar(x);
+ canvas->drawRect(SkRect::MakeXYWH(tx + 0, ty + 0, 8, 8), dark);
+ canvas->drawRect(SkRect::MakeXYWH(tx + 8, ty + 8, 8, 8), dark);
+ }
+ }
+}
+
+/*
+ This GM tests whether the image decoders properly decode each color
+ channel. Four copies of the same image should appear in the GM, and
+ the letter R should be red, B should be blue, G green, C cyan, M
+ magenta, Y yellow, and K black. In all but the JPEG version of the
+ image, the letters should be on a white disc on a transparent
+ background (rendered as a checkerboard). The JPEG image has a grey
+ background and compression artifacts.
+ */
+DEF_SIMPLE_GM(colorwheel, canvas, 256, 256) {
+ canvas->clear(SK_ColorWHITE);
+ checkerboard(canvas, 256, 256);
+ SkBitmap bitmap;
+ if (GetResourceAsBitmap("color_wheel.png", &bitmap)) {
mtklein 2014/10/24 17:28:44 Might want SkAssertResult in here somewhere?
hal.canary 2014/10/24 18:01:14 Done.
+ canvas->drawBitmap(bitmap, 0, 0); // top left
+ }
+ if (GetResourceAsBitmap("color_wheel.gif", &bitmap)) {
+ canvas->drawBitmap(bitmap, 128, 0); // top right
+ }
+ if (GetResourceAsBitmap("color_wheel.webp", &bitmap)) {
+ canvas->drawBitmap(bitmap, 0, 128); // bottom left
+ }
+ if (GetResourceAsBitmap("color_wheel.jpg", &bitmap)) {
+ canvas->drawBitmap(bitmap, 128, 128); // bottom right
+ }
+}
« no previous file with comments | « no previous file | gm/gm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698