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

Side by Side Diff: gm/convexpolyeffect.cpp

Issue 1140983002: remove color from GrGeometryProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup2
Patch Set: more 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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 ConvexPolyTestBatch(const GrGeometryProcessor* gp, const Geometry& geo) 43 ConvexPolyTestBatch(const GrGeometryProcessor* gp, const Geometry& geo)
44 : INHERITED(gp, geo.fBounds) 44 : INHERITED(gp, geo.fBounds)
45 , fGeometry(geo) { 45 , fGeometry(geo) {
46 } 46 }
47 47
48 Geometry* geoData(int index) override { 48 Geometry* geoData(int index) override {
49 SkASSERT(0 == index); 49 SkASSERT(0 == index);
50 return &fGeometry; 50 return &fGeometry;
51 } 51 }
52 52
53 const Geometry* geoData(int index) const override {
54 SkASSERT(0 == index);
55 return &fGeometry;
56 }
57
53 void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeli ne) override { 58 void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeli ne) override {
54 size_t vertexStride = this->geometryProcessor()->getVertexStride(); 59 size_t vertexStride = this->geometryProcessor()->getVertexStride();
55 SkASSERT(vertexStride == sizeof(SkPoint)); 60 SkASSERT(vertexStride == sizeof(SkPoint));
56 QuadHelper helper; 61 QuadHelper helper;
57 SkPoint* verts = reinterpret_cast<SkPoint*>(helper.init(batchTarget, ver texStride, 1)); 62 SkPoint* verts = reinterpret_cast<SkPoint*>(helper.init(batchTarget, ver texStride, 1));
58 if (!verts) { 63 if (!verts) {
59 return; 64 return;
60 } 65 }
61 66
62 // Make sure any artifacts around the exterior of path are visible by us ing overly 67 // Make sure any artifacts around the exterior of path are visible by us ing overly
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 void onDraw(SkCanvas* canvas) override { 148 void onDraw(SkCanvas* canvas) override {
144 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget (); 149 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget ();
145 if (NULL == rt) { 150 if (NULL == rt) {
146 this->drawGpuOnlyMessage(canvas); 151 this->drawGpuOnlyMessage(canvas);
147 return; 152 return;
148 } 153 }
149 GrContext* context = rt->getContext(); 154 GrContext* context = rt->getContext();
150 if (NULL == context) { 155 if (NULL == context) {
151 return; 156 return;
152 } 157 }
153 158
robertphillips 2015/05/13 20:33:50 Here too ?
159 static const GrColor color = 0xff000000;
154 SkAutoTUnref<const GrGeometryProcessor> gp( 160 SkAutoTUnref<const GrGeometryProcessor> gp(
155 GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPositi on_GPType, 161 GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPositi on_GPType, color));
156 0xff000000));
157 162
158 SkScalar y = 0; 163 SkScalar y = 0;
159 for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_I terStart); 164 for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_I terStart);
160 iter.get(); 165 iter.get();
161 iter.next()) { 166 iter.next()) {
162 const SkPath* path = iter.get(); 167 const SkPath* path = iter.get();
163 SkScalar x = 0; 168 SkScalar x = 0;
164 169
165 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { 170 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) {
166 GrTestTarget tt; 171 GrTestTarget tt;
(...skipping 10 matching lines...) Expand all
177 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, p)); 182 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, p));
178 if (!fp) { 183 if (!fp) {
179 continue; 184 continue;
180 } 185 }
181 186
182 GrPipelineBuilder pipelineBuilder; 187 GrPipelineBuilder pipelineBuilder;
183 pipelineBuilder.addCoverageProcessor(fp); 188 pipelineBuilder.addCoverageProcessor(fp);
184 pipelineBuilder.setRenderTarget(rt); 189 pipelineBuilder.setRenderTarget(rt);
185 190
186 ConvexPolyTestBatch::Geometry geometry; 191 ConvexPolyTestBatch::Geometry geometry;
187 geometry.fColor = gp->color(); 192 geometry.fColor = color;
188 geometry.fBounds = p.getBounds(); 193 geometry.fBounds = p.getBounds();
189 194
190 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom etry)); 195 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom etry));
191 196
192 tt.target()->drawBatch(&pipelineBuilder, batch); 197 tt.target()->drawBatch(&pipelineBuilder, batch);
193 198
194 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f); 199 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f);
195 } 200 }
196 201
197 // Draw AA and non AA paths using normal API for reference. 202 // Draw AA and non AA paths using normal API for reference.
(...skipping 28 matching lines...) Expand all
226 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, rect)); 231 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, rect));
227 if (!fp) { 232 if (!fp) {
228 continue; 233 continue;
229 } 234 }
230 235
231 GrPipelineBuilder pipelineBuilder; 236 GrPipelineBuilder pipelineBuilder;
232 pipelineBuilder.addCoverageProcessor(fp); 237 pipelineBuilder.addCoverageProcessor(fp);
233 pipelineBuilder.setRenderTarget(rt); 238 pipelineBuilder.setRenderTarget(rt);
234 239
235 ConvexPolyTestBatch::Geometry geometry; 240 ConvexPolyTestBatch::Geometry geometry;
236 geometry.fColor = gp->color(); 241 geometry.fColor = color;
237 geometry.fBounds = rect; 242 geometry.fBounds = rect;
238 243
239 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom etry)); 244 SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geom etry));
240 245
241 tt.target()->drawBatch(&pipelineBuilder, batch); 246 tt.target()->drawBatch(&pipelineBuilder, batch);
242 247
243 x += SkScalarCeilToScalar(rect.width() + 10.f); 248 x += SkScalarCeilToScalar(rect.width() + 10.f);
244 } 249 }
245 250
246 // Draw rect without and with AA using normal API for reference 251 // Draw rect without and with AA using normal API for reference
(...skipping 14 matching lines...) Expand all
261 SkTLList<SkPath> fPaths; 266 SkTLList<SkPath> fPaths;
262 SkTLList<SkRect> fRects; 267 SkTLList<SkRect> fRects;
263 268
264 typedef GM INHERITED; 269 typedef GM INHERITED;
265 }; 270 };
266 271
267 DEF_GM( return SkNEW(ConvexPolyEffect); ) 272 DEF_GM( return SkNEW(ConvexPolyEffect); )
268 } 273 }
269 274
270 #endif 275 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698