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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // vertically/horizontally thin rects that don't cover pixel centers | 140 // vertically/horizontally thin rects that don't cover pixel centers |
141 fRects.addToTail(SkRect::MakeLTRB(5.55f, 0.5f, 5.75f, 24.5f)); | 141 fRects.addToTail(SkRect::MakeLTRB(5.55f, 0.5f, 5.75f, 24.5f)); |
142 fRects.addToTail(SkRect::MakeLTRB(5.5f, .05f, 29.5f, .25f)); | 142 fRects.addToTail(SkRect::MakeLTRB(5.5f, .05f, 29.5f, .25f)); |
143 // small in x and y | 143 // small in x and y |
144 fRects.addToTail(SkRect::MakeLTRB(5.05f, .55f, 5.45f, .85f)); | 144 fRects.addToTail(SkRect::MakeLTRB(5.05f, .55f, 5.45f, .85f)); |
145 // inverted in x and y | 145 // inverted in x and y |
146 fRects.addToTail(SkRect::MakeLTRB(100.f, 50.5f, 5.f, 0.5f)); | 146 fRects.addToTail(SkRect::MakeLTRB(100.f, 50.5f, 5.f, 0.5f)); |
147 } | 147 } |
148 | 148 |
149 void onDraw(SkCanvas* canvas) override { | 149 void onDraw(SkCanvas* canvas) override { |
| 150 using namespace GrDefaultGeoProcFactory; |
150 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 151 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
151 if (NULL == rt) { | 152 if (NULL == rt) { |
152 this->drawGpuOnlyMessage(canvas); | 153 this->drawGpuOnlyMessage(canvas); |
153 return; | 154 return; |
154 } | 155 } |
155 GrContext* context = rt->getContext(); | 156 GrContext* context = rt->getContext(); |
156 if (NULL == context) { | 157 if (NULL == context) { |
157 return; | 158 return; |
158 } | 159 } |
159 | 160 |
160 static const GrColor color = 0xff000000; | 161 Color color(0xff000000); |
| 162 Coverage coverage(Coverage::kSolid_Type); |
| 163 LocalCoords localCoords(LocalCoords::kUnused_Type); |
161 SkAutoTUnref<const GrGeometryProcessor> gp( | 164 SkAutoTUnref<const GrGeometryProcessor> gp( |
162 GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPositi
on_GPType, color, | 165 GrDefaultGeoProcFactory::Create(color, coverage, localCoords, Sk
Matrix::I())); |
163 false, false)); | |
164 | 166 |
165 SkScalar y = 0; | 167 SkScalar y = 0; |
166 for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_I
terStart); | 168 for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_I
terStart); |
167 iter.get(); | 169 iter.get(); |
168 iter.next()) { | 170 iter.next()) { |
169 const SkPath* path = iter.get(); | 171 const SkPath* path = iter.get(); |
170 SkScalar x = 0; | 172 SkScalar x = 0; |
171 | 173 |
172 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { | 174 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { |
173 GrTestTarget tt; | 175 GrTestTarget tt; |
(...skipping 10 matching lines...) Expand all Loading... |
184 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(
edgeType, p)); | 186 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(
edgeType, p)); |
185 if (!fp) { | 187 if (!fp) { |
186 continue; | 188 continue; |
187 } | 189 } |
188 | 190 |
189 GrPipelineBuilder pipelineBuilder; | 191 GrPipelineBuilder pipelineBuilder; |
190 pipelineBuilder.addCoverageProcessor(fp); | 192 pipelineBuilder.addCoverageProcessor(fp); |
191 pipelineBuilder.setRenderTarget(rt); | 193 pipelineBuilder.setRenderTarget(rt); |
192 | 194 |
193 ConvexPolyTestBatch::Geometry geometry; | 195 ConvexPolyTestBatch::Geometry geometry; |
194 geometry.fColor = color; | 196 geometry.fColor = color.fColor; |
195 geometry.fBounds = p.getBounds(); | 197 geometry.fBounds = p.getBounds(); |
196 | 198 |
197 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom
etry)); | 199 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom
etry)); |
198 | 200 |
199 tt.target()->drawBatch(pipelineBuilder, batch); | 201 tt.target()->drawBatch(pipelineBuilder, batch); |
200 | 202 |
201 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f); | 203 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f); |
202 } | 204 } |
203 | 205 |
204 // Draw AA and non AA paths using normal API for reference. | 206 // Draw AA and non AA paths using normal API for reference. |
(...skipping 28 matching lines...) Expand all Loading... |
233 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(
edgeType, rect)); | 235 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(
edgeType, rect)); |
234 if (!fp) { | 236 if (!fp) { |
235 continue; | 237 continue; |
236 } | 238 } |
237 | 239 |
238 GrPipelineBuilder pipelineBuilder; | 240 GrPipelineBuilder pipelineBuilder; |
239 pipelineBuilder.addCoverageProcessor(fp); | 241 pipelineBuilder.addCoverageProcessor(fp); |
240 pipelineBuilder.setRenderTarget(rt); | 242 pipelineBuilder.setRenderTarget(rt); |
241 | 243 |
242 ConvexPolyTestBatch::Geometry geometry; | 244 ConvexPolyTestBatch::Geometry geometry; |
243 geometry.fColor = color; | 245 geometry.fColor = color.fColor; |
244 geometry.fBounds = rect; | 246 geometry.fBounds = rect; |
245 | 247 |
246 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom
etry)); | 248 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom
etry)); |
247 | 249 |
248 tt.target()->drawBatch(pipelineBuilder, batch); | 250 tt.target()->drawBatch(pipelineBuilder, batch); |
249 | 251 |
250 x += SkScalarCeilToScalar(rect.width() + 10.f); | 252 x += SkScalarCeilToScalar(rect.width() + 10.f); |
251 } | 253 } |
252 | 254 |
253 // Draw rect without and with AA using normal API for reference | 255 // Draw rect without and with AA using normal API for reference |
(...skipping 14 matching lines...) Expand all Loading... |
268 SkTLList<SkPath> fPaths; | 270 SkTLList<SkPath> fPaths; |
269 SkTLList<SkRect> fRects; | 271 SkTLList<SkRect> fRects; |
270 | 272 |
271 typedef GM INHERITED; | 273 typedef GM INHERITED; |
272 }; | 274 }; |
273 | 275 |
274 DEF_GM( return SkNEW(ConvexPolyEffect); ) | 276 DEF_GM( return SkNEW(ConvexPolyEffect); ) |
275 } | 277 } |
276 | 278 |
277 #endif | 279 #endif |
OLD | NEW |