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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkCullPoints.h" | 10 #include "SkCullPoints.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 } | 40 } |
41 | 41 |
42 SkISize onISize() override { return SkISize::Make(700, 460); } | 42 SkISize onISize() override { return SkISize::Make(700, 460); } |
43 | 43 |
44 void onDraw(SkCanvas* canvas) override { | 44 void onDraw(SkCanvas* canvas) override { |
45 SkPath path; | 45 SkPath path; |
46 SkRandom rand; | 46 SkRandom rand; |
47 | 47 |
48 int scale = 300; | 48 int scale = 300; |
49 for (int i = 0; i < 4; ++i) { | 49 for (int i = 0; i < 4; ++i) { |
50 path.lineTo(rand.nextUScalar1() * scale, rand.nextUScalar1() * scale
); | 50 // get the random values deterministically |
51 path.quadTo(rand.nextUScalar1() * scale, rand.nextUScalar1() * scale
, | 51 SkScalar randoms[12]; |
52 rand.nextUScalar1() * scale, rand.nextUScalar1() * scale
); | 52 for (int index = 0; index < (int) SK_ARRAY_COUNT(randoms); ++index)
{ |
53 path.cubicTo(rand.nextUScalar1() * scale, rand.nextUScalar1() * scal
e, | 53 randoms[index] = rand.nextUScalar1(); |
54 rand.nextUScalar1() * scale, rand.nextUScalar1() * scal
e, | 54 } |
55 rand.nextUScalar1() * scale, rand.nextUScalar1() * scal
e); | 55 path.lineTo(randoms[0] * scale, randoms[1] * scale); |
| 56 path.quadTo(randoms[2] * scale, randoms[3] * scale, |
| 57 randoms[4] * scale, randoms[5] * scale); |
| 58 path.cubicTo(randoms[6] * scale, randoms[7] * scale, |
| 59 randoms[8] * scale, randoms[9] * scale, |
| 60 randoms[10] * scale, randoms[11] * scale); |
56 } | 61 } |
57 | 62 |
58 path.setFillType(SkPath::kEvenOdd_FillType); | 63 path.setFillType(SkPath::kEvenOdd_FillType); |
59 path.offset(SkIntToScalar(20), SkIntToScalar(20)); | 64 path.offset(SkIntToScalar(20), SkIntToScalar(20)); |
60 | 65 |
61 test_hittest(canvas, path); | 66 test_hittest(canvas, path); |
62 | 67 |
63 canvas->translate(SkIntToScalar(scale), 0); | 68 canvas->translate(SkIntToScalar(scale), 0); |
64 path.setFillType(SkPath::kWinding_FillType); | 69 path.setFillType(SkPath::kWinding_FillType); |
65 | 70 |
66 test_hittest(canvas, path); | 71 test_hittest(canvas, path); |
67 } | 72 } |
68 | 73 |
69 private: | 74 private: |
70 typedef GM INHERITED; | 75 typedef GM INHERITED; |
71 }; | 76 }; |
72 | 77 |
73 ////////////////////////////////////////////////////////////////////////////// | 78 ////////////////////////////////////////////////////////////////////////////// |
74 | 79 |
75 static skiagm::GM* MyFactory(void*) { return new HitTestPathGM; } | 80 static skiagm::GM* MyFactory(void*) { return new HitTestPathGM; } |
76 static skiagm::GMRegistry reg(MyFactory); | 81 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |