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

Side by Side 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, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | gm/gm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Resources.h"
9 #include "SkData.h"
10 #include "SkDecodingImageGenerator.h"
11 #include "gm.h"
12
13 static void checkerboard(SkCanvas* canvas, int w, int h) {
14 SkASSERT(w > 0);
15 SkASSERT(h > 0);
16 w = ((w - 1) | 0xF) + 1;
17 h = ((h - 1) | 0xF) + 1;
18 SkPaint light;
19 light.setColor(0xFF999999);
20 canvas->drawRect(SkRect::MakeXYWH(0, 0, w, h), light);
21 SkPaint dark;
22 dark.setColor(0xFF666666);
23 for (int y = 0; y < w; y += 16) {
24 SkScalar ty = SkIntToScalar(y);
25 for (int x = 0; x < h; x += 16) {
26 SkScalar tx = SkIntToScalar(x);
27 canvas->drawRect(SkRect::MakeXYWH(tx + 0, ty + 0, 8, 8), dark);
28 canvas->drawRect(SkRect::MakeXYWH(tx + 8, ty + 8, 8, 8), dark);
29 }
30 }
31 }
32
33 /*
34 This GM tests whether the image decoders properly decode each color
35 channel. Four copies of the same image should appear in the GM, and
36 the letter R should be red, B should be blue, G green, C cyan, M
37 magenta, Y yellow, and K black. In all but the JPEG version of the
38 image, the letters should be on a white disc on a transparent
39 background (rendered as a checkerboard). The JPEG image has a grey
40 background and compression artifacts.
41 */
42 DEF_SIMPLE_GM(colorwheel, canvas, 256, 256) {
43 canvas->clear(SK_ColorWHITE);
44 checkerboard(canvas, 256, 256);
45 SkBitmap bitmap;
46 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.
47 canvas->drawBitmap(bitmap, 0, 0); // top left
48 }
49 if (GetResourceAsBitmap("color_wheel.gif", &bitmap)) {
50 canvas->drawBitmap(bitmap, 128, 0); // top right
51 }
52 if (GetResourceAsBitmap("color_wheel.webp", &bitmap)) {
53 canvas->drawBitmap(bitmap, 0, 128); // bottom left
54 }
55 if (GetResourceAsBitmap("color_wheel.jpg", &bitmap)) {
56 canvas->drawBitmap(bitmap, 128, 128); // bottom right
57 }
58 }
OLDNEW
« 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