OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 // This test only works with the GPU backend. | 8 // This test only works with the GPU backend. |
9 | 9 |
10 #include "gm.h" | 10 #include "gm.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 tri.lineTo(100.f, 20.f); | 103 tri.lineTo(100.f, 20.f); |
104 tri.lineTo(15.f, 100.f); | 104 tri.lineTo(15.f, 100.f); |
105 | 105 |
106 fPaths.addToTail(tri); | 106 fPaths.addToTail(tri); |
107 fPaths.addToTail(SkPath())->reverseAddPath(tri); | 107 fPaths.addToTail(SkPath())->reverseAddPath(tri); |
108 | 108 |
109 tri.close(); | 109 tri.close(); |
110 fPaths.addToTail(tri); | 110 fPaths.addToTail(tri); |
111 | 111 |
112 SkPath ngon; | 112 SkPath ngon; |
113 static const SkScalar kRadius = 50.f; | 113 constexpr SkScalar kRadius = 50.f; |
114 const SkPoint center = { kRadius, kRadius }; | 114 const SkPoint center = { kRadius, kRadius }; |
115 for (int i = 0; i < GrConvexPolyEffect::kMaxEdges; ++i) { | 115 for (int i = 0; i < GrConvexPolyEffect::kMaxEdges; ++i) { |
116 SkScalar angle = 2 * SK_ScalarPI * i / GrConvexPolyEffect::kMaxEdges
; | 116 SkScalar angle = 2 * SK_ScalarPI * i / GrConvexPolyEffect::kMaxEdges
; |
117 SkPoint point; | 117 SkPoint point; |
118 point.fY = SkScalarSinCos(angle, &point.fX); | 118 point.fY = SkScalarSinCos(angle, &point.fX); |
119 point.scale(kRadius); | 119 point.scale(kRadius); |
120 point = center + point; | 120 point = center + point; |
121 if (0 == i) { | 121 if (0 == i) { |
122 ngon.moveTo(point); | 122 ngon.moveTo(point); |
123 } else { | 123 } else { |
(...skipping 29 matching lines...) Expand all Loading... |
153 } | 153 } |
154 | 154 |
155 void onDraw(SkCanvas* canvas) override { | 155 void onDraw(SkCanvas* canvas) override { |
156 GrDrawContext* drawContext = canvas->internal_private_accessTopLayerDraw
Context(); | 156 GrDrawContext* drawContext = canvas->internal_private_accessTopLayerDraw
Context(); |
157 if (!drawContext) { | 157 if (!drawContext) { |
158 skiagm::GM::DrawGpuOnlyMessage(canvas); | 158 skiagm::GM::DrawGpuOnlyMessage(canvas); |
159 return; | 159 return; |
160 } | 160 } |
161 | 161 |
162 SkScalar y = 0; | 162 SkScalar y = 0; |
163 static const SkScalar kDX = 12.f; | 163 constexpr SkScalar kDX = 12.f; |
164 for (PathList::Iter iter(fPaths, PathList::Iter::kHead_IterStart); | 164 for (PathList::Iter iter(fPaths, PathList::Iter::kHead_IterStart); |
165 iter.get(); | 165 iter.get(); |
166 iter.next()) { | 166 iter.next()) { |
167 const SkPath* path = iter.get(); | 167 const SkPath* path = iter.get(); |
168 SkScalar x = 0; | 168 SkScalar x = 0; |
169 | 169 |
170 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { | 170 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { |
171 const SkMatrix m = SkMatrix::MakeTrans(x, y); | 171 const SkMatrix m = SkMatrix::MakeTrans(x, y); |
172 SkPath p; | 172 SkPath p; |
173 path->transform(m, &p); | 173 path->transform(m, &p); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 PathList fPaths; | 248 PathList fPaths; |
249 RectList fRects; | 249 RectList fRects; |
250 | 250 |
251 typedef GM INHERITED; | 251 typedef GM INHERITED; |
252 }; | 252 }; |
253 | 253 |
254 DEF_GM(return new ConvexPolyEffect;) | 254 DEF_GM(return new ConvexPolyEffect;) |
255 } | 255 } |
256 | 256 |
257 #endif | 257 #endif |
OLD | NEW |