| 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; |
| 87 protected: | 88 protected: |
| 88 void onOnceBeforeDraw() override { | 89 void onOnceBeforeDraw() override { |
| 89 | 90 |
| 90 SkAssertResult(SkParsePath::FromSVGString("M0,0h0M10,0h0M20,0h0", &fMove
HfPath)); | 91 SkAssertResult(SkParsePath::FromSVGString("M0,0h0M10,0h0M20,0h0", &fMove
HfPath)); |
| 91 SkAssertResult(SkParsePath::FromSVGString("M0,0zM10,0zM20,0z", &fMoveZfP
ath)); | 92 SkAssertResult(SkParsePath::FromSVGString("M0,0zM10,0zM20,0z", &fMoveZfP
ath)); |
| 92 SkAssertResult(SkParsePath::FromSVGString("M0,0h25", &fDashedfPath)); | 93 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)); |
| 93 | 97 |
| 94 for (int i = 0; i < 3; ++i) { | 98 for (int i = 0; i < 3; ++i) { |
| 95 fRefPath[0].addCircle(i * 10.f, 0, 5); | 99 fRefPath[0].addCircle(i * 10.f, 0, 5); |
| 96 fRefPath[1].addCircle(i * 10.f, 0, 10); | 100 fRefPath[1].addCircle(i * 10.f, 0, 10); |
| 97 fRefPath[2].addRect(i * 10.f - 4, -2, i * 10.f + 4, 6); | 101 fRefPath[2].addRect(i * 10.f - 4, -2, i * 10.f + 4, 6); |
| 98 fRefPath[3].addRect(i * 10.f - 10, -10, i * 10.f + 10, 10); | 102 fRefPath[3].addRect(i * 10.f - 10, -10, i * 10.f + 10, 10); |
| 99 } | 103 } |
| 100 } | 104 } |
| 101 | 105 |
| 102 SkString onShortName() override { | 106 SkString onShortName() override { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 133 canvas->drawPath(fRefPath[i * 2], fillPaint); | 137 canvas->drawPath(fRefPath[i * 2], fillPaint); |
| 134 strokePaint.setStrokeWidth(20); | 138 strokePaint.setStrokeWidth(20); |
| 135 strokePaint.setAlpha(127); | 139 strokePaint.setAlpha(127); |
| 136 canvas->translate(0, 50); | 140 canvas->translate(0, 50); |
| 137 canvas->drawPath(fMoveHfPath, strokePaint); | 141 canvas->drawPath(fMoveHfPath, strokePaint); |
| 138 canvas->translate(0, 30); | 142 canvas->translate(0, 30); |
| 139 canvas->drawPath(fMoveZfPath, strokePaint); | 143 canvas->drawPath(fMoveZfPath, strokePaint); |
| 140 canvas->translate(0, 30); | 144 canvas->translate(0, 30); |
| 141 fillPaint.setAlpha(127); | 145 fillPaint.setAlpha(127); |
| 142 canvas->drawPath(fRefPath[1 + i * 2], fillPaint); | 146 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); |
| 143 canvas->restore(); | 153 canvas->restore(); |
| 144 } | 154 } |
| 145 } | 155 } |
| 146 | 156 |
| 147 private: | 157 private: |
| 148 typedef skiagm::GM INHERITED; | 158 typedef skiagm::GM INHERITED; |
| 149 }; | 159 }; |
| 150 | 160 |
| 151 class Strokes2GM : public skiagm::GM { | 161 class Strokes2GM : public skiagm::GM { |
| 152 SkPath fPath; | 162 SkPath fPath; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 static skiagm::GM* F3(void*) { return new Strokes4GM; } | 411 static skiagm::GM* F3(void*) { return new Strokes4GM; } |
| 402 static skiagm::GM* F4(void*) { return new Strokes5GM; } | 412 static skiagm::GM* F4(void*) { return new Strokes5GM; } |
| 403 | 413 |
| 404 static skiagm::GMRegistry R0(F0); | 414 static skiagm::GMRegistry R0(F0); |
| 405 static skiagm::GMRegistry R1(F1); | 415 static skiagm::GMRegistry R1(F1); |
| 406 static skiagm::GMRegistry R2(F2); | 416 static skiagm::GMRegistry R2(F2); |
| 407 static skiagm::GMRegistry R3(F3); | 417 static skiagm::GMRegistry R3(F3); |
| 408 static skiagm::GMRegistry R4(F4); | 418 static skiagm::GMRegistry R4(F4); |
| 409 | 419 |
| 410 DEF_GM( return new ZeroLenStrokesGM; ) | 420 DEF_GM( return new ZeroLenStrokesGM; ) |
| OLD | NEW |