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

Side by Side Diff: gm/repeated_bitmap.cpp

Issue 1372783003: SkPDF: Implement drawImage*() properly (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-09-30 (Wednesday) 21:22:24 EDT Created 5 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 unified diff | Download patch
« no previous file with comments | « dm/DM.cpp ('k') | gyp/pdf.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Resources.h"
9 #include "SkImage.h"
8 #include "gm.h" 10 #include "gm.h"
9 #include "sk_tool_utils.h" 11 #include "sk_tool_utils.h"
10 #include "Resources.h"
11 12
12 DEF_SIMPLE_GM(repeated_bitmap, canvas, 576, 576) { 13 static void draw_rotated_image(SkCanvas* canvas, const SkImage* image) {
13 sk_tool_utils::draw_checkerboard(canvas, sk_tool_utils::color_to_565(0xFF999 999), 14 sk_tool_utils::draw_checkerboard(canvas, SkColorSetRGB(156, 154, 156),
14 SK_ColorWHITE, 12); 15 SK_ColorWHITE, 12);
15 SkRect rect = SkRect::MakeLTRB(-4.25f, -4.25f, 4.25f, 4.25f); 16 if (!image) {
17 return;
18 }
19 SkRect rect = SkRect::MakeLTRB(-68.0f, -68.0f, 68.0f, 68.0f);
16 SkPaint paint; 20 SkPaint paint;
17 paint.setColor(0xFF333333); 21 paint.setColor(SkColorSetRGB(49, 48, 49));
18 SkBitmap bm; 22 SkScalar scale = SkTMin(128.0f / image->width(),
19 if (GetResourceAsBitmap("randPixels.png", &bm)) { 23 128.0f / image->height());
20 for (int j = 0; j < 4; ++j) { 24 SkScalar point[2] = {-0.5f * image->width(), -0.5f * image->height()};
21 for (int i = 0; i < 4; ++i) { 25 for (int j = 0; j < 4; ++j) {
22 SkAutoCanvasRestore autoCanvasRestore(canvas, true); 26 for (int i = 0; i < 4; ++i) {
23 canvas->scale(12.0f, 12.0f); 27 SkAutoCanvasRestore autoCanvasRestore(canvas, true);
24 canvas->translate(6.0f + 12.0f * SkIntToScalar(i), 28 canvas->translate(96.0f + 192.0f * i, 96.0f + 192.0f * j);
25 6.0f + 12.0f * SkIntToScalar(j)); 29 canvas->rotate(18.0f * (i + 4 * j));
26 canvas->rotate(18.0f * (i + 4 * j)); 30 canvas->drawRect(rect, paint);
27 canvas->drawRect(rect, paint); 31 canvas->scale(scale, scale);
28 canvas->drawBitmap(bm, -4.0f, -4.0f); 32 canvas->drawImage(image, point[0], point[1]);
29 }
30 } 33 }
31 } 34 }
32 } 35 }
33 36
37 DEF_SIMPLE_GM(repeated_bitmap, canvas, 576, 576) {
38 SkAutoTUnref<SkImage> image(GetResourceAsImage("randPixels.png"));
39 draw_rotated_image(canvas, image);
40 }
41
34 DEF_SIMPLE_GM(repeated_bitmap_jpg, canvas, 576, 576) { 42 DEF_SIMPLE_GM(repeated_bitmap_jpg, canvas, 576, 576) {
35 sk_tool_utils::draw_checkerboard(canvas, sk_tool_utils::color_to_565(0xFF999 999), 43 SkAutoTUnref<SkImage> image(GetResourceAsImage("color_wheel.jpg"));
36 SK_ColorWHITE, 12); 44 draw_rotated_image(canvas, image);
37 SkRect rect = SkRect::MakeLTRB(-68.0f, -68.0f, 68.0f, 68.0f);
38 SkPaint paint;
39 paint.setColor(0xFF333333);
40 SkBitmap bm;
41 if (GetResourceAsBitmap("color_wheel.jpg", &bm)) {
42 for (int j = 0; j < 4; ++j) {
43 for (int i = 0; i < 4; ++i) {
44 SkAutoCanvasRestore autoCanvasRestore(canvas, true);
45 canvas->translate(96.0f + 192.0f * SkIntToScalar(i),
46 96.0f + 192.0f * SkIntToScalar(j));
47 canvas->rotate(18.0f * (i + 4 * j));
48 canvas->drawRect(rect, paint);
49 canvas->drawBitmap(bm, -64.0f, -64.0f);
50 }
51 }
52 }
53 } 45 }
OLDNEW
« no previous file with comments | « dm/DM.cpp ('k') | gyp/pdf.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698