OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 paint->setColor(rand.nextU()); | 32 paint->setColor(rand.nextU()); |
33 paint->setAlpha(0xFF); | 33 paint->setAlpha(0xFF); |
34 } | 34 } |
35 | 35 |
36 | 36 |
37 class StrokesGM : public skiagm::GM { | 37 class StrokesGM : public skiagm::GM { |
38 public: | 38 public: |
39 StrokesGM() {} | 39 StrokesGM() {} |
40 | 40 |
41 protected: | 41 protected: |
42 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 42 uint32_t onGetFlags() const SK_OVERRIDE { |
43 return kSkipTiled_Flag; | 43 return kSkipTiled_Flag; |
44 } | 44 } |
45 | 45 |
46 virtual SkString onShortName() SK_OVERRIDE { | 46 SkString onShortName() SK_OVERRIDE { |
47 return SkString("strokes_round"); | 47 return SkString("strokes_round"); |
48 } | 48 } |
49 | 49 |
50 virtual SkISize onISize() SK_OVERRIDE { | 50 SkISize onISize() SK_OVERRIDE { |
51 return SkISize::Make(W, H*2); | 51 return SkISize::Make(W, H*2); |
52 } | 52 } |
53 | 53 |
54 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 54 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
55 SkPaint paint; | 55 SkPaint paint; |
56 paint.setStyle(SkPaint::kStroke_Style); | 56 paint.setStyle(SkPaint::kStroke_Style); |
57 paint.setStrokeWidth(SkIntToScalar(9)/2); | 57 paint.setStrokeWidth(SkIntToScalar(9)/2); |
58 | 58 |
59 for (int y = 0; y < 2; y++) { | 59 for (int y = 0; y < 2; y++) { |
60 paint.setAntiAlias(!!y); | 60 paint.setAntiAlias(!!y); |
61 SkAutoCanvasRestore acr(canvas, true); | 61 SkAutoCanvasRestore acr(canvas, true); |
62 canvas->translate(0, SH * y); | 62 canvas->translate(0, SH * y); |
63 canvas->clipRect(SkRect::MakeLTRB( | 63 canvas->clipRect(SkRect::MakeLTRB( |
64 SkIntToScalar(2), SkIntToScalar(2) | 64 SkIntToScalar(2), SkIntToScalar(2) |
(...skipping 23 matching lines...) Expand all Loading... |
88 SkRandom rand; | 88 SkRandom rand; |
89 fPath.moveTo(0, 0); | 89 fPath.moveTo(0, 0); |
90 for (int i = 0; i < 13; i++) { | 90 for (int i = 0; i < 13; i++) { |
91 SkScalar x = rand.nextUScalar1() * (W >> 1); | 91 SkScalar x = rand.nextUScalar1() * (W >> 1); |
92 SkScalar y = rand.nextUScalar1() * (H >> 1); | 92 SkScalar y = rand.nextUScalar1() * (H >> 1); |
93 fPath.lineTo(x, y); | 93 fPath.lineTo(x, y); |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 protected: | 97 protected: |
98 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 98 uint32_t onGetFlags() const SK_OVERRIDE { |
99 return kSkipTiled_Flag; | 99 return kSkipTiled_Flag; |
100 } | 100 } |
101 | 101 |
102 virtual SkString onShortName() SK_OVERRIDE { | 102 SkString onShortName() SK_OVERRIDE { |
103 return SkString("strokes_poly"); | 103 return SkString("strokes_poly"); |
104 } | 104 } |
105 | 105 |
106 virtual SkISize onISize() SK_OVERRIDE { | 106 SkISize onISize() SK_OVERRIDE { |
107 return SkISize::Make(W, H*2); | 107 return SkISize::Make(W, H*2); |
108 } | 108 } |
109 | 109 |
110 static void rotate(SkScalar angle, SkScalar px, SkScalar py, SkCanvas* canva
s) { | 110 static void rotate(SkScalar angle, SkScalar px, SkScalar py, SkCanvas* canva
s) { |
111 SkMatrix matrix; | 111 SkMatrix matrix; |
112 matrix.setRotate(angle, px, py); | 112 matrix.setRotate(angle, px, py); |
113 canvas->concat(matrix); | 113 canvas->concat(matrix); |
114 } | 114 } |
115 | 115 |
116 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 116 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
117 canvas->drawColor(SK_ColorWHITE); | 117 canvas->drawColor(SK_ColorWHITE); |
118 | 118 |
119 SkPaint paint; | 119 SkPaint paint; |
120 paint.setStyle(SkPaint::kStroke_Style); | 120 paint.setStyle(SkPaint::kStroke_Style); |
121 paint.setStrokeWidth(SkIntToScalar(9)/2); | 121 paint.setStrokeWidth(SkIntToScalar(9)/2); |
122 | 122 |
123 for (int y = 0; y < 2; y++) { | 123 for (int y = 0; y < 2; y++) { |
124 paint.setAntiAlias(!!y); | 124 paint.setAntiAlias(!!y); |
125 SkAutoCanvasRestore acr(canvas, true); | 125 SkAutoCanvasRestore acr(canvas, true); |
126 canvas->translate(0, SH * y); | 126 canvas->translate(0, SH * y); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 SkRect r = bounds; | 189 SkRect r = bounds; |
190 r.inset(bounds.width() / 10, -bounds.height() / 10); | 190 r.inset(bounds.width() / 10, -bounds.height() / 10); |
191 path->addOval(r, SkPath::kCCW_Direction); | 191 path->addOval(r, SkPath::kCCW_Direction); |
192 title->set("CW CCW"); | 192 title->set("CW CCW"); |
193 } | 193 } |
194 | 194 |
195 public: | 195 public: |
196 Strokes3GM() {} | 196 Strokes3GM() {} |
197 | 197 |
198 protected: | 198 protected: |
199 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 199 uint32_t onGetFlags() const SK_OVERRIDE { |
200 return kSkipTiled_Flag; | 200 return kSkipTiled_Flag; |
201 } | 201 } |
202 | 202 |
203 virtual SkString onShortName() SK_OVERRIDE { | 203 SkString onShortName() SK_OVERRIDE { |
204 return SkString("strokes3"); | 204 return SkString("strokes3"); |
205 } | 205 } |
206 | 206 |
207 virtual SkISize onISize() SK_OVERRIDE { | 207 SkISize onISize() SK_OVERRIDE { |
208 return SkISize::Make(W, H*2); | 208 return SkISize::Make(W, H*2); |
209 } | 209 } |
210 | 210 |
211 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 211 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
212 SkPaint origPaint; | 212 SkPaint origPaint; |
213 origPaint.setAntiAlias(true); | 213 origPaint.setAntiAlias(true); |
214 origPaint.setStyle(SkPaint::kStroke_Style); | 214 origPaint.setStyle(SkPaint::kStroke_Style); |
215 SkPaint fillPaint(origPaint); | 215 SkPaint fillPaint(origPaint); |
216 fillPaint.setColor(SK_ColorRED); | 216 fillPaint.setColor(SK_ColorRED); |
217 SkPaint strokePaint(origPaint); | 217 SkPaint strokePaint(origPaint); |
218 strokePaint.setColor(0xFF4444FF); | 218 strokePaint.setColor(0xFF4444FF); |
219 | 219 |
220 void (*procs[])(SkPath*, const SkRect&, SkString*) = { | 220 void (*procs[])(SkPath*, const SkRect&, SkString*) = { |
221 make0, make1, make2, make3, make4, make5 | 221 make0, make1, make2, make3, make4, make5 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 253 |
254 ////////////////////////////////////////////////////////////////////////////// | 254 ////////////////////////////////////////////////////////////////////////////// |
255 | 255 |
256 static skiagm::GM* F0(void*) { return new StrokesGM; } | 256 static skiagm::GM* F0(void*) { return new StrokesGM; } |
257 static skiagm::GM* F1(void*) { return new Strokes2GM; } | 257 static skiagm::GM* F1(void*) { return new Strokes2GM; } |
258 static skiagm::GM* F2(void*) { return new Strokes3GM; } | 258 static skiagm::GM* F2(void*) { return new Strokes3GM; } |
259 | 259 |
260 static skiagm::GMRegistry R0(F0); | 260 static skiagm::GMRegistry R0(F0); |
261 static skiagm::GMRegistry R1(F1); | 261 static skiagm::GMRegistry R1(F1); |
262 static skiagm::GMRegistry R2(F2); | 262 static skiagm::GMRegistry R2(F2); |
OLD | NEW |