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 |
+ } |
+} |