Add fixes & test for isConfigTexturable and isConfigRenderable
[platform/upstream/libSkiaSharp.git] / gm / repeated_bitmap.cpp
1 /*
2  * Copyright 2015 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 "SkImage.h"
10 #include "gm.h"
11 #include "sk_tool_utils.h"
12
13 static void draw_rotated_image(SkCanvas* canvas, const SkImage* image) {
14     sk_tool_utils::draw_checkerboard(canvas, SkColorSetRGB(156, 154, 156),
15                                      SK_ColorWHITE, 12);
16     if (!image) {
17         return;
18     }
19     SkRect rect = SkRect::MakeLTRB(-68.0f, -68.0f, 68.0f, 68.0f);
20     SkPaint paint;
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]);
33         }
34     }
35 }
36
37 DEF_SIMPLE_GM(repeated_bitmap, canvas, 576, 576) {
38     draw_rotated_image(canvas, GetResourceAsImage("randPixels.png").get());
39 }
40
41 DEF_SIMPLE_GM(repeated_bitmap_jpg, canvas, 576, 576) {
42     draw_rotated_image(canvas, GetResourceAsImage("color_wheel.jpg").get());
43 }