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

Side by Side Diff: gm/convexpolyeffect.cpp

Issue 1293583002: Introduce GrBatch subclasses GrDrawBatch and GrVertexBatch to prepare for non-drawing batches (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove duplicated fields in GrVertexBatch Created 5 years, 4 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') | include/gpu/GrDrawContext.h » ('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 18 matching lines...) Expand all
29 namespace skiagm { 29 namespace skiagm {
30 30
31 class ConvexPolyTestBatch : public GrTestBatch { 31 class ConvexPolyTestBatch : public GrTestBatch {
32 public: 32 public:
33 struct Geometry : public GrTestBatch::Geometry { 33 struct Geometry : public GrTestBatch::Geometry {
34 SkRect fBounds; 34 SkRect fBounds;
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 GrDrawBatch* Create(const GrGeometryProcessor* gp, const Geometry& ge o) {
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, geo.fBounds) 45 : INHERITED(gp, geo.fBounds)
46 , fGeometry(geo) { 46 , fGeometry(geo) {
47 this->initClassID<ConvexPolyTestBatch>(); 47 this->initClassID<ConvexPolyTestBatch>();
48 } 48 }
49 49
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 190 }
191 191
192 GrPipelineBuilder pipelineBuilder; 192 GrPipelineBuilder pipelineBuilder;
193 pipelineBuilder.addCoverageProcessor(fp); 193 pipelineBuilder.addCoverageProcessor(fp);
194 pipelineBuilder.setRenderTarget(rt); 194 pipelineBuilder.setRenderTarget(rt);
195 195
196 ConvexPolyTestBatch::Geometry geometry; 196 ConvexPolyTestBatch::Geometry geometry;
197 geometry.fColor = color.fColor; 197 geometry.fColor = color.fColor;
198 geometry.fBounds = p.getBounds(); 198 geometry.fBounds = p.getBounds();
199 199
200 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom etry)); 200 SkAutoTUnref<GrDrawBatch> batch(ConvexPolyTestBatch::Create(gp, geometry));
201 201
202 tt.target()->drawBatch(pipelineBuilder, batch); 202 tt.target()->drawBatch(pipelineBuilder, batch);
203 203
204 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f); 204 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f);
205 } 205 }
206 206
207 // Draw AA and non AA paths using normal API for reference. 207 // Draw AA and non AA paths using normal API for reference.
208 canvas->save(); 208 canvas->save();
209 canvas->translate(x, y); 209 canvas->translate(x, y);
210 SkPaint paint; 210 SkPaint paint;
(...skipping 28 matching lines...) Expand all
239 } 239 }
240 240
241 GrPipelineBuilder pipelineBuilder; 241 GrPipelineBuilder pipelineBuilder;
242 pipelineBuilder.addCoverageProcessor(fp); 242 pipelineBuilder.addCoverageProcessor(fp);
243 pipelineBuilder.setRenderTarget(rt); 243 pipelineBuilder.setRenderTarget(rt);
244 244
245 ConvexPolyTestBatch::Geometry geometry; 245 ConvexPolyTestBatch::Geometry geometry;
246 geometry.fColor = color.fColor; 246 geometry.fColor = color.fColor;
247 geometry.fBounds = rect; 247 geometry.fBounds = rect;
248 248
249 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom etry)); 249 SkAutoTUnref<GrDrawBatch> batch(ConvexPolyTestBatch::Create(gp, geometry));
250 250
251 tt.target()->drawBatch(pipelineBuilder, batch); 251 tt.target()->drawBatch(pipelineBuilder, batch);
252 252
253 x += SkScalarCeilToScalar(rect.width() + 10.f); 253 x += SkScalarCeilToScalar(rect.width() + 10.f);
254 } 254 }
255 255
256 // Draw rect without and with AA using normal API for reference 256 // Draw rect without and with AA using normal API for reference
257 canvas->save(); 257 canvas->save();
258 canvas->translate(x, y); 258 canvas->translate(x, y);
259 SkPaint paint; 259 SkPaint paint;
(...skipping 11 matching lines...) Expand all
271 SkTLList<SkPath> fPaths; 271 SkTLList<SkPath> fPaths;
272 SkTLList<SkRect> fRects; 272 SkTLList<SkRect> fRects;
273 273
274 typedef GM INHERITED; 274 typedef GM INHERITED;
275 }; 275 };
276 276
277 DEF_GM( return SkNEW(ConvexPolyEffect); ) 277 DEF_GM( return SkNEW(ConvexPolyEffect); )
278 } 278 }
279 279
280 #endif 280 #endif
OLDNEW
« no previous file with comments | « gm/beziereffects.cpp ('k') | include/gpu/GrDrawContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698