Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: gm/convexpolyeffect.cpp

Issue 1121463002: Move bounds to GrBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweak Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/beziereffects.cpp ('k') | src/gpu/GrAAConvexPathRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 }; 35 };
36 36
37 const char* name() const override { return "ConvexPolyTestBatch"; } 37 const char* name() const override { return "ConvexPolyTestBatch"; }
38 38
39 static GrBatch* Create(const GrGeometryProcessor* gp, const Geometry& geo) { 39 static GrBatch* Create(const GrGeometryProcessor* gp, const Geometry& geo) {
40 return SkNEW_ARGS(ConvexPolyTestBatch, (gp, geo)); 40 return SkNEW_ARGS(ConvexPolyTestBatch, (gp, geo));
41 } 41 }
42 42
43 private: 43 private:
44 ConvexPolyTestBatch(const GrGeometryProcessor* gp, const Geometry& geo) 44 ConvexPolyTestBatch(const GrGeometryProcessor* gp, const Geometry& geo)
45 : INHERITED(gp) 45 : INHERITED(gp, geo.fBounds)
46 , fGeometry(geo) { 46 , fGeometry(geo) {
47 } 47 }
48 48
49 Geometry* geoData(int index) override { 49 Geometry* geoData(int index) override {
50 SkASSERT(0 == index); 50 SkASSERT(0 == index);
51 return &fGeometry; 51 return &fGeometry;
52 } 52 }
53 53
54 void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeli ne) override { 54 void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeli ne) override {
55 size_t vertexStride = this->geometryProcessor()->getVertexStride(); 55 size_t vertexStride = this->geometryProcessor()->getVertexStride();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 GrPipelineBuilder pipelineBuilder; 204 GrPipelineBuilder pipelineBuilder;
205 pipelineBuilder.addCoverageProcessor(fp); 205 pipelineBuilder.addCoverageProcessor(fp);
206 pipelineBuilder.setRenderTarget(rt); 206 pipelineBuilder.setRenderTarget(rt);
207 207
208 ConvexPolyTestBatch::Geometry geometry; 208 ConvexPolyTestBatch::Geometry geometry;
209 geometry.fColor = gp->color(); 209 geometry.fColor = gp->color();
210 geometry.fBounds = p.getBounds(); 210 geometry.fBounds = p.getBounds();
211 211
212 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom etry)); 212 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom etry));
213 213
214 tt.target()->drawBatch(&pipelineBuilder, batch, NULL); 214 tt.target()->drawBatch(&pipelineBuilder, batch);
215 215
216 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f); 216 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f);
217 } 217 }
218 218
219 // Draw AA and non AA paths using normal API for reference. 219 // Draw AA and non AA paths using normal API for reference.
220 canvas->save(); 220 canvas->save();
221 canvas->translate(x, y); 221 canvas->translate(x, y);
222 SkPaint paint; 222 SkPaint paint;
223 canvas->drawPath(*path, paint); 223 canvas->drawPath(*path, paint);
224 canvas->translate(path->getBounds().width() + 10.f, 0); 224 canvas->translate(path->getBounds().width() + 10.f, 0);
(...skipping 28 matching lines...) Expand all
253 GrPipelineBuilder pipelineBuilder; 253 GrPipelineBuilder pipelineBuilder;
254 pipelineBuilder.addCoverageProcessor(fp); 254 pipelineBuilder.addCoverageProcessor(fp);
255 pipelineBuilder.setRenderTarget(rt); 255 pipelineBuilder.setRenderTarget(rt);
256 256
257 ConvexPolyTestBatch::Geometry geometry; 257 ConvexPolyTestBatch::Geometry geometry;
258 geometry.fColor = gp->color(); 258 geometry.fColor = gp->color();
259 geometry.fBounds = rect; 259 geometry.fBounds = rect;
260 260
261 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom etry)); 261 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom etry));
262 262
263 tt.target()->drawBatch(&pipelineBuilder, batch, NULL); 263 tt.target()->drawBatch(&pipelineBuilder, batch);
264 264
265 x += SkScalarCeilToScalar(rect.width() + 10.f); 265 x += SkScalarCeilToScalar(rect.width() + 10.f);
266 } 266 }
267 267
268 // Draw rect without and with AA using normal API for reference 268 // Draw rect without and with AA using normal API for reference
269 canvas->save(); 269 canvas->save();
270 canvas->translate(x, y); 270 canvas->translate(x, y);
271 SkPaint paint; 271 SkPaint paint;
272 canvas->drawRect(*iter.get(), paint); 272 canvas->drawRect(*iter.get(), paint);
273 x += SkScalarCeilToScalar(iter.get()->width() + 10.f); 273 x += SkScalarCeilToScalar(iter.get()->width() + 10.f);
274 paint.setAntiAlias(true); 274 paint.setAntiAlias(true);
275 canvas->drawRect(*iter.get(), paint); 275 canvas->drawRect(*iter.get(), paint);
276 canvas->restore(); 276 canvas->restore();
277 277
278 y += SkScalarCeilToScalar(iter.get()->height() + 20.f); 278 y += SkScalarCeilToScalar(iter.get()->height() + 20.f);
279 } 279 }
280 } 280 }
281 281
282 private: 282 private:
283 SkTLList<SkPath> fPaths; 283 SkTLList<SkPath> fPaths;
284 SkTLList<SkRect> fRects; 284 SkTLList<SkRect> fRects;
285 285
286 typedef GM INHERITED; 286 typedef GM INHERITED;
287 }; 287 };
288 288
289 DEF_GM( return SkNEW(ConvexPolyEffect); ) 289 DEF_GM( return SkNEW(ConvexPolyEffect); )
290 } 290 }
291 291
292 #endif 292 #endif
OLDNEW
« no previous file with comments | « gm/beziereffects.cpp ('k') | src/gpu/GrAAConvexPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698