2 * Copyright 2015 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
11 #include "sk_tool_utils.h"
13 static void draw_rotated_image(SkCanvas* canvas, const SkImage* image) {
14 sk_tool_utils::draw_checkerboard(canvas, SkColorSetRGB(156, 154, 156),
19 SkRect rect = SkRect::MakeLTRB(-68.0f, -68.0f, 68.0f, 68.0f);
21 paint.setColor(SkColorSetRGB(49, 48, 49));
22 SkScalar scale = SkTMin(128.0f / image->width(),
23 128.0f / image->height());
24 SkScalar point[2] = {-0.5f * image->width(), -0.5f * image->height()};
25 for (int j = 0; j < 4; ++j) {
26 for (int i = 0; i < 4; ++i) {
27 SkAutoCanvasRestore autoCanvasRestore(canvas, true);
28 canvas->translate(96.0f + 192.0f * i, 96.0f + 192.0f * j);
29 canvas->rotate(18.0f * (i + 4 * j));
30 canvas->drawRect(rect, paint);
31 canvas->scale(scale, scale);
32 canvas->drawImage(image, point[0], point[1]);
37 DEF_SIMPLE_GM(repeated_bitmap, canvas, 576, 576) {
38 draw_rotated_image(canvas, GetResourceAsImage("randPixels.png").get());
41 DEF_SIMPLE_GM(repeated_bitmap_jpg, canvas, 576, 576) {
42 draw_rotated_image(canvas, GetResourceAsImage("color_wheel.jpg").get());