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