OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "gm.h" | 8 #include "gm.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
11 #include "SkSurface.h" | 11 #include "SkSurface.h" |
12 | 12 |
13 #define ZOOM 32 | 13 #define ZOOM 32 |
14 #define SMALL_W 9 | 14 #define SMALL_W 9 |
15 #define SMALL_H 3 | 15 #define SMALL_H 3 |
16 #define REPEAT_LOOP 5 | 16 #define REPEAT_LOOP 5 |
17 | 17 |
18 static SkSurface* new_surface(int width, int height) { | 18 static sk_sp<SkSurface> new_surface(int width, int height) { |
19 return SkSurface::NewRasterN32Premul(width, height); | 19 return SkSurface::MakeRasterN32Premul(width, height); |
20 } | 20 } |
21 | 21 |
22 static void draw_pixel_centers(SkCanvas* canvas) { | 22 static void draw_pixel_centers(SkCanvas* canvas) { |
23 SkPaint paint; | 23 SkPaint paint; |
24 paint.setColor(sk_tool_utils::color_to_565(0xFF0088FF)); | 24 paint.setColor(sk_tool_utils::color_to_565(0xFF0088FF)); |
25 paint.setAntiAlias(true); | 25 paint.setAntiAlias(true); |
26 | 26 |
27 for (int y = 0; y < SMALL_H; ++y) { | 27 for (int y = 0; y < SMALL_H; ++y) { |
28 for (int x = 0; x < SMALL_W; ++x) { | 28 for (int x = 0; x < SMALL_W; ++x) { |
29 canvas->drawCircle(x + 0.5f, y + 0.5f, 1.5f / ZOOM, paint); | 29 canvas->drawCircle(x + 0.5f, y + 0.5f, 1.5f / ZOOM, paint); |
(...skipping 12 matching lines...) Expand all Loading... |
42 paint.setColor(SK_ColorRED); | 42 paint.setColor(SK_ColorRED); |
43 paint.setStyle(SkPaint::kStroke_Style); | 43 paint.setStyle(SkPaint::kStroke_Style); |
44 canvas->drawPath(path, paint); | 44 canvas->drawPath(path, paint); |
45 | 45 |
46 draw_pixel_centers(canvas); | 46 draw_pixel_centers(canvas); |
47 } | 47 } |
48 | 48 |
49 DEF_SIMPLE_GM(fatpathfill, canvas, | 49 DEF_SIMPLE_GM(fatpathfill, canvas, |
50 SMALL_W * ZOOM, | 50 SMALL_W * ZOOM, |
51 SMALL_H * ZOOM * REPEAT_LOOP) { | 51 SMALL_H * ZOOM * REPEAT_LOOP) { |
52 SkAutoTUnref<SkSurface> surface(new_surface(SMALL_W, SMALL_H)); | 52 auto surface(new_surface(SMALL_W, SMALL_H)); |
53 | 53 |
54 canvas->scale(ZOOM, ZOOM); | 54 canvas->scale(ZOOM, ZOOM); |
55 | 55 |
56 SkPaint paint; | 56 SkPaint paint; |
57 paint.setStyle(SkPaint::kStroke_Style); | 57 paint.setStyle(SkPaint::kStroke_Style); |
58 paint.setStrokeWidth(SK_Scalar1); | 58 paint.setStrokeWidth(SK_Scalar1); |
59 | 59 |
60 for (int i = 0; i < REPEAT_LOOP; ++i) { | 60 for (int i = 0; i < REPEAT_LOOP; ++i) { |
61 SkPath line, path; | 61 SkPath line, path; |
62 line.moveTo(1, 2); | 62 line.moveTo(1, 2); |
63 line.lineTo(SkIntToScalar(4 + i), 1); | 63 line.lineTo(SkIntToScalar(4 + i), 1); |
64 paint.getFillPath(line, &path); | 64 paint.getFillPath(line, &path); |
65 draw_fatpath(canvas, surface, path); | 65 draw_fatpath(canvas, surface.get(), path); |
66 | 66 |
67 canvas->translate(0, SMALL_H); | 67 canvas->translate(0, SMALL_H); |
68 } | 68 } |
69 } | 69 } |
OLD | NEW |