OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 // This test only works with the GPU backend. | 9 // This test only works with the GPU backend. |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 | 54 |
55 copy.setColor(SK_ColorYELLOW); | 55 copy.setColor(SK_ColorYELLOW); |
56 canvas->drawPoints(SkCanvas::kPoints_PointMode, 2, left+1, copy); | 56 canvas->drawPoints(SkCanvas::kPoints_PointMode, 2, left+1, copy); |
57 | 57 |
58 copy.setColor(SK_ColorGREEN); | 58 copy.setColor(SK_ColorGREEN); |
59 canvas->drawPoints(SkCanvas::kPoints_PointMode, 2, right+1, copy); | 59 canvas->drawPoints(SkCanvas::kPoints_PointMode, 2, right+1, copy); |
60 } | 60 } |
61 | 61 |
62 static void draw_random_patch(SkPoint points[12], SkColor colors[4], SkCanvas* c anvas, | 62 static void draw_random_patch(SkPoint points[12], SkColor colors[4], SkCanvas* c anvas, |
63 SkPaint& paint, SkRandom* rnd) { | 63 SkPaint& paint, SkRandom* rnd) { |
64 SkPoint ptsCpy[12]; | 64 SkPoint ptsCpy[12]; |
mtklein
2014/08/04 20:40:47
Seems like we still have many 12's and 4's. It's
dandov
2014/08/04 21:47:54
I think I fixed all of the 12's and 4's that are r
| |
65 memcpy(ptsCpy, points, 12 * sizeof(SkPoint)); | 65 memcpy(ptsCpy, points, SkPatch::kNumCtrlPts * sizeof(SkPoint)); |
66 for (int i = 0; i < 5; i++) { | 66 for (int i = 0; i < 5; i++) { |
67 int index = rnd->nextRangeU(0, 11); | 67 int index = rnd->nextRangeU(0, 11); |
68 SkScalar dx = rnd->nextRangeScalar(-50, 50), dy = rnd->nextRangeScalar(- 50, 50); | 68 SkScalar dx = rnd->nextRangeScalar(-50, 50), dy = rnd->nextRangeScalar(- 50, 50); |
69 ptsCpy[index].offset(dx, dy); | 69 ptsCpy[index].offset(dx, dy); |
70 } | 70 } |
71 SkPatch patch(ptsCpy, colors); | 71 SkPatch patch(ptsCpy, colors); |
72 canvas->drawPatch(patch, paint); | 72 canvas->drawPatch(patch, paint); |
73 draw_control_points(canvas, patch, paint); | 73 draw_control_points(canvas, patch, paint); |
74 } | 74 } |
75 | 75 |
(...skipping 11 matching lines...) Expand all Loading... | |
87 protected: | 87 protected: |
88 virtual SkString onShortName() SK_OVERRIDE { | 88 virtual SkString onShortName() SK_OVERRIDE { |
89 return SkString("patch_primitive"); | 89 return SkString("patch_primitive"); |
90 } | 90 } |
91 | 91 |
92 virtual SkISize onISize() SK_OVERRIDE { | 92 virtual SkISize onISize() SK_OVERRIDE { |
93 return SkISize::Make(800, 800); | 93 return SkISize::Make(800, 800); |
94 } | 94 } |
95 | 95 |
96 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 96 virtual uint32_t onGetFlags() const SK_OVERRIDE { |
97 return kSkipTiled_Flag | kSkipPipe_Flag | kSkipPicture_Flag; | 97 return kSkipTiled_Flag; |
98 } | 98 } |
99 | 99 |
100 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 100 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
101 | 101 |
102 SkPaint paint; | 102 SkPaint paint; |
103 SkColor colors[4] = { | 103 SkColor colors[4] = { |
104 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorCYAN | 104 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorCYAN |
105 }; | 105 }; |
106 SkPoint points[12] = { | 106 SkPoint points[12] = { |
107 {50,50},{75,20},{125,80}, {150,50}, | 107 {50,50},{75,20},{125,80}, {150,50}, |
(...skipping 27 matching lines...) Expand all Loading... | |
135 | 135 |
136 private: | 136 private: |
137 typedef GM INHERITED; | 137 typedef GM INHERITED; |
138 }; | 138 }; |
139 | 139 |
140 DEF_GM(return SkNEW(SkPatchGM); ) | 140 DEF_GM(return SkNEW(SkPatchGM); ) |
141 | 141 |
142 } | 142 } |
143 | 143 |
144 #endif | 144 #endif |
OLD | NEW |