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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 fRects.addToTail(SkRect::MakeLTRB(5.5f, .05f, 29.5f, .25f)); | 144 fRects.addToTail(SkRect::MakeLTRB(5.5f, .05f, 29.5f, .25f)); |
145 // small in x and y | 145 // small in x and y |
146 fRects.addToTail(SkRect::MakeLTRB(5.05f, .55f, 5.45f, .85f)); | 146 fRects.addToTail(SkRect::MakeLTRB(5.05f, .55f, 5.45f, .85f)); |
147 // inverted in x and y | 147 // inverted in x and y |
148 fRects.addToTail(SkRect::MakeLTRB(100.f, 50.5f, 5.f, 0.5f)); | 148 fRects.addToTail(SkRect::MakeLTRB(100.f, 50.5f, 5.f, 0.5f)); |
149 } | 149 } |
150 | 150 |
151 void onDraw(SkCanvas* canvas) override { | 151 void onDraw(SkCanvas* canvas) override { |
152 using namespace GrDefaultGeoProcFactory; | 152 using namespace GrDefaultGeoProcFactory; |
153 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 153 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
154 if (NULL == rt) { | 154 if (nullptr == rt) { |
155 this->drawGpuOnlyMessage(canvas); | 155 this->drawGpuOnlyMessage(canvas); |
156 return; | 156 return; |
157 } | 157 } |
158 GrContext* context = rt->getContext(); | 158 GrContext* context = rt->getContext(); |
159 if (NULL == context) { | 159 if (nullptr == context) { |
160 return; | 160 return; |
161 } | 161 } |
162 | 162 |
163 Color color(0xff000000); | 163 Color color(0xff000000); |
164 Coverage coverage(Coverage::kSolid_Type); | 164 Coverage coverage(Coverage::kSolid_Type); |
165 LocalCoords localCoords(LocalCoords::kUnused_Type); | 165 LocalCoords localCoords(LocalCoords::kUnused_Type); |
166 SkAutoTUnref<const GrGeometryProcessor> gp( | 166 SkAutoTUnref<const GrGeometryProcessor> gp( |
167 GrDefaultGeoProcFactory::Create(color, coverage, localCoords, Sk
Matrix::I())); | 167 GrDefaultGeoProcFactory::Create(color, coverage, localCoords, Sk
Matrix::I())); |
168 | 168 |
169 SkScalar y = 0; | 169 SkScalar y = 0; |
170 for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_I
terStart); | 170 for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_I
terStart); |
171 iter.get(); | 171 iter.get(); |
172 iter.next()) { | 172 iter.next()) { |
173 const SkPath* path = iter.get(); | 173 const SkPath* path = iter.get(); |
174 SkScalar x = 0; | 174 SkScalar x = 0; |
175 | 175 |
176 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { | 176 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { |
177 GrTestTarget tt; | 177 GrTestTarget tt; |
178 context->getTestTarget(&tt); | 178 context->getTestTarget(&tt); |
179 if (NULL == tt.target()) { | 179 if (nullptr == tt.target()) { |
180 SkDEBUGFAIL("Couldn't get Gr test target."); | 180 SkDEBUGFAIL("Couldn't get Gr test target."); |
181 return; | 181 return; |
182 } | 182 } |
183 const SkMatrix m = SkMatrix::MakeTrans(x, y); | 183 const SkMatrix m = SkMatrix::MakeTrans(x, y); |
184 SkPath p; | 184 SkPath p; |
185 path->transform(m, &p); | 185 path->transform(m, &p); |
186 | 186 |
187 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; | 187 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; |
188 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(
edgeType, p)); | 188 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(
edgeType, p)); |
189 if (!fp) { | 189 if (!fp) { |
(...skipping 30 matching lines...) Expand all Loading... |
220 | 220 |
221 for (SkTLList<SkRect>::Iter iter(fRects, SkTLList<SkRect>::Iter::kHead_I
terStart); | 221 for (SkTLList<SkRect>::Iter iter(fRects, SkTLList<SkRect>::Iter::kHead_I
terStart); |
222 iter.get(); | 222 iter.get(); |
223 iter.next()) { | 223 iter.next()) { |
224 | 224 |
225 SkScalar x = 0; | 225 SkScalar x = 0; |
226 | 226 |
227 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { | 227 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { |
228 GrTestTarget tt; | 228 GrTestTarget tt; |
229 context->getTestTarget(&tt); | 229 context->getTestTarget(&tt); |
230 if (NULL == tt.target()) { | 230 if (nullptr == tt.target()) { |
231 SkDEBUGFAIL("Couldn't get Gr test target."); | 231 SkDEBUGFAIL("Couldn't get Gr test target."); |
232 return; | 232 return; |
233 } | 233 } |
234 SkRect rect = *iter.get(); | 234 SkRect rect = *iter.get(); |
235 rect.offset(x, y); | 235 rect.offset(x, y); |
236 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; | 236 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; |
237 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(
edgeType, rect)); | 237 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(
edgeType, rect)); |
238 if (!fp) { | 238 if (!fp) { |
239 continue; | 239 continue; |
240 } | 240 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 SkTLList<SkPath> fPaths; | 272 SkTLList<SkPath> fPaths; |
273 SkTLList<SkRect> fRects; | 273 SkTLList<SkRect> fRects; |
274 | 274 |
275 typedef GM INHERITED; | 275 typedef GM INHERITED; |
276 }; | 276 }; |
277 | 277 |
278 DEF_GM(return new ConvexPolyEffect;) | 278 DEF_GM(return new ConvexPolyEffect;) |
279 } | 279 } |
280 | 280 |
281 #endif | 281 #endif |
OLD | NEW |