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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 paint.setColor(0xFF0088FF); | 24 paint.setColor(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); |
30 } | 30 } |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 static void draw_fatpath(SkCanvas* canvas, SkSurface* surface, | 34 static void draw_fatpath(SkCanvas* canvas, SkSurface* surface, const SkPath& pat
h) { |
35 const SkPath paths[], int count) { | |
36 SkPaint paint; | 35 SkPaint paint; |
37 | 36 |
38 surface->getCanvas()->clear(SK_ColorTRANSPARENT); | 37 surface->getCanvas()->clear(SK_ColorTRANSPARENT); |
39 for (int i = 0; i < count; ++i) { | 38 surface->getCanvas()->drawPath(path, paint); |
40 surface->getCanvas()->drawPath(paths[i], paint); | |
41 } | |
42 surface->draw(canvas, 0, 0, NULL); | 39 surface->draw(canvas, 0, 0, NULL); |
43 | 40 |
44 paint.setAntiAlias(true); | 41 paint.setAntiAlias(true); |
45 paint.setColor(SK_ColorRED); | 42 paint.setColor(SK_ColorRED); |
46 paint.setStyle(SkPaint::kStroke_Style); | 43 paint.setStyle(SkPaint::kStroke_Style); |
47 for (int j = 0; j < count; ++j) { | 44 canvas->drawPath(path, paint); |
48 canvas->drawPath(paths[j], paint); | |
49 } | |
50 | 45 |
51 draw_pixel_centers(canvas); | 46 draw_pixel_centers(canvas); |
52 } | 47 } |
53 | 48 |
54 class FatPathFillGM : public skiagm::GM { | 49 class FatPathFillGM : public skiagm::GM { |
55 public: | 50 public: |
56 FatPathFillGM() {} | 51 FatPathFillGM() {} |
57 | 52 |
58 protected: | 53 protected: |
59 | 54 |
60 virtual SkString onShortName() { | 55 SkString onShortName() override { |
61 return SkString("fatpathfill"); | 56 return SkString("fatpathfill"); |
62 } | 57 } |
63 | 58 |
64 virtual SkISize onISize() { | 59 SkISize onISize() override { |
65 return SkISize::Make(SMALL_W * ZOOM, SMALL_H * ZOOM * REPEAT_LOOP); | 60 return SkISize::Make(SMALL_W * ZOOM, SMALL_H * ZOOM * REPEAT_LOOP); |
66 } | 61 } |
67 | 62 |
68 virtual void onDraw(SkCanvas* canvas) { | 63 void onDraw(SkCanvas* canvas) override { |
69 SkAutoTUnref<SkSurface> surface(new_surface(SMALL_W, SMALL_H)); | 64 SkAutoTUnref<SkSurface> surface(new_surface(SMALL_W, SMALL_H)); |
70 | 65 |
71 canvas->scale(ZOOM, ZOOM); | 66 canvas->scale(ZOOM, ZOOM); |
72 | 67 |
73 SkPaint paint; | 68 SkPaint paint; |
74 paint.setStyle(SkPaint::kStroke_Style); | 69 paint.setStyle(SkPaint::kStroke_Style); |
75 paint.setStrokeWidth(SK_Scalar1); | 70 paint.setStrokeWidth(SK_Scalar1); |
76 | 71 |
77 for (int i = 0; i < REPEAT_LOOP; ++i) { | 72 for (int i = 0; i < REPEAT_LOOP; ++i) { |
78 SkPath line, path; | 73 SkPath line, path; |
79 line.moveTo(SkIntToScalar(1), SkIntToScalar(2)); | 74 line.moveTo(1, 2); |
80 line.lineTo(SkIntToScalar(4 + i), SkIntToScalar(1)); | 75 line.lineTo(SkIntToScalar(4 + i), 1); |
81 paint.getFillPath(line, &path); | 76 paint.getFillPath(line, &path); |
82 draw_fatpath(canvas, surface, &path, 1); | 77 draw_fatpath(canvas, surface, path); |
83 | 78 |
84 canvas->translate(0, SMALL_H); | 79 canvas->translate(0, SMALL_H); |
85 } | 80 } |
86 } | 81 } |
87 | 82 |
88 private: | 83 private: |
89 typedef skiagm::GM INHERITED; | 84 typedef skiagm::GM INHERITED; |
90 }; | 85 }; |
91 | 86 |
92 /////////////////////////////////////////////////////////////////////////////// | 87 /////////////////////////////////////////////////////////////////////////////// |
93 | 88 |
94 DEF_GM(return new FatPathFillGM;) | 89 DEF_GM(return new FatPathFillGM;) |
OLD | NEW |