OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkPath.h" | 9 #include "SkPath.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 private: | 77 private: |
78 typedef skiagm::GM INHERITED; | 78 typedef skiagm::GM INHERITED; |
79 }; | 79 }; |
80 | 80 |
81 /* See | 81 /* See |
82 https://code.google.com/p/chromium/issues/detail?id=422974 and | 82 https://code.google.com/p/chromium/issues/detail?id=422974 and |
83 http://jsfiddle.net/1xnku3sg/2/ | 83 http://jsfiddle.net/1xnku3sg/2/ |
84 */ | 84 */ |
85 class ZeroLenStrokesGM : public skiagm::GM { | 85 class ZeroLenStrokesGM : public skiagm::GM { |
86 SkPath fMoveHfPath, fMoveZfPath, fDashedfPath, fRefPath[4]; | 86 SkPath fMoveHfPath, fMoveZfPath, fDashedfPath, fRefPath[4]; |
87 SkPath fCubicPath, fQuadPath, fLinePath; | |
88 protected: | 87 protected: |
89 void onOnceBeforeDraw() override { | 88 void onOnceBeforeDraw() override { |
90 | 89 |
91 SkAssertResult(SkParsePath::FromSVGString("M0,0h0M10,0h0M20,0h0", &fMove
HfPath)); | 90 SkAssertResult(SkParsePath::FromSVGString("M0,0h0M10,0h0M20,0h0", &fMove
HfPath)); |
92 SkAssertResult(SkParsePath::FromSVGString("M0,0zM10,0zM20,0z", &fMoveZfP
ath)); | 91 SkAssertResult(SkParsePath::FromSVGString("M0,0zM10,0zM20,0z", &fMoveZfP
ath)); |
93 SkAssertResult(SkParsePath::FromSVGString("M0,0h25", &fDashedfPath)); | 92 SkAssertResult(SkParsePath::FromSVGString("M0,0h25", &fDashedfPath)); |
94 SkAssertResult(SkParsePath::FromSVGString("M 0 0 C 0 0 0 0 0 0", &fCubic
Path)); | |
95 SkAssertResult(SkParsePath::FromSVGString("M 0 0 Q 0 0 0 0", &fQuadPath)
); | |
96 SkAssertResult(SkParsePath::FromSVGString("M 0 0 L 0 0", &fLinePath)); | |
97 | 93 |
98 for (int i = 0; i < 3; ++i) { | 94 for (int i = 0; i < 3; ++i) { |
99 fRefPath[0].addCircle(i * 10.f, 0, 5); | 95 fRefPath[0].addCircle(i * 10.f, 0, 5); |
100 fRefPath[1].addCircle(i * 10.f, 0, 10); | 96 fRefPath[1].addCircle(i * 10.f, 0, 10); |
101 fRefPath[2].addRect(i * 10.f - 4, -2, i * 10.f + 4, 6); | 97 fRefPath[2].addRect(i * 10.f - 4, -2, i * 10.f + 4, 6); |
102 fRefPath[3].addRect(i * 10.f - 10, -10, i * 10.f + 10, 10); | 98 fRefPath[3].addRect(i * 10.f - 10, -10, i * 10.f + 10, 10); |
103 } | 99 } |
104 } | 100 } |
105 | 101 |
106 SkString onShortName() override { | 102 SkString onShortName() override { |
(...skipping 30 matching lines...) Expand all Loading... |
137 canvas->drawPath(fRefPath[i * 2], fillPaint); | 133 canvas->drawPath(fRefPath[i * 2], fillPaint); |
138 strokePaint.setStrokeWidth(20); | 134 strokePaint.setStrokeWidth(20); |
139 strokePaint.setAlpha(127); | 135 strokePaint.setAlpha(127); |
140 canvas->translate(0, 50); | 136 canvas->translate(0, 50); |
141 canvas->drawPath(fMoveHfPath, strokePaint); | 137 canvas->drawPath(fMoveHfPath, strokePaint); |
142 canvas->translate(0, 30); | 138 canvas->translate(0, 30); |
143 canvas->drawPath(fMoveZfPath, strokePaint); | 139 canvas->drawPath(fMoveZfPath, strokePaint); |
144 canvas->translate(0, 30); | 140 canvas->translate(0, 30); |
145 fillPaint.setAlpha(127); | 141 fillPaint.setAlpha(127); |
146 canvas->drawPath(fRefPath[1 + i * 2], fillPaint); | 142 canvas->drawPath(fRefPath[1 + i * 2], fillPaint); |
147 canvas->translate(0, 30); | |
148 canvas->drawPath(fCubicPath, strokePaint); | |
149 canvas->translate(0, 30); | |
150 canvas->drawPath(fQuadPath, strokePaint); | |
151 canvas->translate(0, 30); | |
152 canvas->drawPath(fLinePath, strokePaint); | |
153 canvas->restore(); | 143 canvas->restore(); |
154 } | 144 } |
155 } | 145 } |
156 | 146 |
157 private: | 147 private: |
158 typedef skiagm::GM INHERITED; | 148 typedef skiagm::GM INHERITED; |
159 }; | 149 }; |
160 | 150 |
161 class Strokes2GM : public skiagm::GM { | 151 class Strokes2GM : public skiagm::GM { |
162 SkPath fPath; | 152 SkPath fPath; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 static skiagm::GM* F3(void*) { return new Strokes4GM; } | 401 static skiagm::GM* F3(void*) { return new Strokes4GM; } |
412 static skiagm::GM* F4(void*) { return new Strokes5GM; } | 402 static skiagm::GM* F4(void*) { return new Strokes5GM; } |
413 | 403 |
414 static skiagm::GMRegistry R0(F0); | 404 static skiagm::GMRegistry R0(F0); |
415 static skiagm::GMRegistry R1(F1); | 405 static skiagm::GMRegistry R1(F1); |
416 static skiagm::GMRegistry R2(F2); | 406 static skiagm::GMRegistry R2(F2); |
417 static skiagm::GMRegistry R3(F3); | 407 static skiagm::GMRegistry R3(F3); |
418 static skiagm::GMRegistry R4(F4); | 408 static skiagm::GMRegistry R4(F4); |
419 | 409 |
420 DEF_GM( return new ZeroLenStrokesGM; ) | 410 DEF_GM( return new ZeroLenStrokesGM; ) |
OLD | NEW |