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

Side by Side Diff: gm/convexpolyeffect.cpp

Issue 794843002: Revert of Remove GP from drawstate, revision of invariant output for GP (Closed) Base URL: https://skia.googlesource.com/skia.git@color-to-gp
Patch Set: Created 6 years 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/GrFragmentProcessor.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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 m.setTranslate(x, y); 126 m.setTranslate(x, y);
127 path->transform(m, &p); 127 path->transform(m, &p);
128 128
129 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; 129 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
130 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, p)); 130 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, p));
131 if (!fp) { 131 if (!fp) {
132 continue; 132 continue;
133 } 133 }
134 134
135 GrDrawState ds; 135 GrDrawState ds;
136 SkAutoTUnref<const GrGeometryProcessor> gp( 136 const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create( 0xff000000);
137 GrDefaultGeoProcFactory::Create(0xff000000)); 137 ds.setGeometryProcessor(gp)->unref();
138 ds.addCoverageProcessor(fp); 138 ds.addCoverageProcessor(fp);
139 ds.setIdentityViewMatrix(); 139 ds.setIdentityViewMatrix();
140 ds.setRenderTarget(rt); 140 ds.setRenderTarget(rt);
141 141
142 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, gp->getVer texStride(), 0); 142 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, gp->getVer texStride(), 0);
143 SkASSERT(gp->getVertexStride() == sizeof(SkPoint)); 143 SkASSERT(gp->getVertexStride() == sizeof(SkPoint));
144 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices()); 144 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices());
145 145
146 SkRect bounds = p.getBounds(); 146 SkRect bounds = p.getBounds();
147 // Make sure any artifacts around the exterior of path are visib le by using overly 147 // Make sure any artifacts around the exterior of path are visib le by using overly
148 // conservative bounding geometry. 148 // conservative bounding geometry.
149 bounds.outset(5.f, 5.f); 149 bounds.outset(5.f, 5.f);
150 bounds.toQuad(verts); 150 bounds.toQuad(verts);
151 151
152 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer( )); 152 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer( ));
153 tt.target()->drawIndexed(&ds, gp, kTriangleFan_GrPrimitiveType, 0, 0, 4, 6); 153 tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0 , 4, 6);
154 154
155 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f); 155 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f);
156 } 156 }
157 157
158 // Draw AA and non AA paths using normal API for reference. 158 // Draw AA and non AA paths using normal API for reference.
159 canvas->save(); 159 canvas->save();
160 canvas->translate(x, y); 160 canvas->translate(x, y);
161 SkPaint paint; 161 SkPaint paint;
162 canvas->drawPath(*path, paint); 162 canvas->drawPath(*path, paint);
163 canvas->translate(path->getBounds().width() + 10.f, 0); 163 canvas->translate(path->getBounds().width() + 10.f, 0);
(...skipping 19 matching lines...) Expand all
183 } 183 }
184 SkRect rect = *iter.get(); 184 SkRect rect = *iter.get();
185 rect.offset(x, y); 185 rect.offset(x, y);
186 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; 186 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
187 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, rect)); 187 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, rect));
188 if (!fp) { 188 if (!fp) {
189 continue; 189 continue;
190 } 190 }
191 191
192 GrDrawState ds; 192 GrDrawState ds;
193 SkAutoTUnref<const GrGeometryProcessor> gp( 193 const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create( 0xff000000);
194 GrDefaultGeoProcFactory::Create(0xff000000)); 194 ds.setGeometryProcessor(gp)->unref();
195 ds.addCoverageProcessor(fp); 195 ds.addCoverageProcessor(fp);
196 ds.setIdentityViewMatrix(); 196 ds.setIdentityViewMatrix();
197 ds.setRenderTarget(rt); 197 ds.setRenderTarget(rt);
198 198
199 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, gp->getVer texStride(), 0); 199 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, gp->getVer texStride(), 0);
200 SkASSERT(gp->getVertexStride() == sizeof(SkPoint)); 200 SkASSERT(gp->getVertexStride() == sizeof(SkPoint));
201 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices()); 201 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices());
202 202
203 SkRect bounds = rect; 203 SkRect bounds = rect;
204 bounds.outset(5.f, 5.f); 204 bounds.outset(5.f, 5.f);
205 bounds.toQuad(verts); 205 bounds.toQuad(verts);
206 206
207 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer( )); 207 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer( ));
208 tt.target()->drawIndexed(&ds, gp, kTriangleFan_GrPrimitiveType, 0, 0, 4, 6); 208 tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0 , 4, 6);
209 209
210 x += SkScalarCeilToScalar(rect.width() + 10.f); 210 x += SkScalarCeilToScalar(rect.width() + 10.f);
211 } 211 }
212 212
213 // Draw rect without and with AA using normal API for reference 213 // Draw rect without and with AA using normal API for reference
214 canvas->save(); 214 canvas->save();
215 canvas->translate(x, y); 215 canvas->translate(x, y);
216 SkPaint paint; 216 SkPaint paint;
217 canvas->drawRect(*iter.get(), paint); 217 canvas->drawRect(*iter.get(), paint);
218 x += SkScalarCeilToScalar(iter.get()->width() + 10.f); 218 x += SkScalarCeilToScalar(iter.get()->width() + 10.f);
219 paint.setAntiAlias(true); 219 paint.setAntiAlias(true);
220 canvas->drawRect(*iter.get(), paint); 220 canvas->drawRect(*iter.get(), paint);
221 canvas->restore(); 221 canvas->restore();
222 222
223 y += SkScalarCeilToScalar(iter.get()->height() + 20.f); 223 y += SkScalarCeilToScalar(iter.get()->height() + 20.f);
224 } 224 }
225 } 225 }
226 226
227 private: 227 private:
228 SkTLList<SkPath> fPaths; 228 SkTLList<SkPath> fPaths;
229 SkTLList<SkRect> fRects; 229 SkTLList<SkRect> fRects;
230 230
231 typedef GM INHERITED; 231 typedef GM INHERITED;
232 }; 232 };
233 233
234 DEF_GM( return SkNEW(ConvexPolyEffect); ) 234 DEF_GM( return SkNEW(ConvexPolyEffect); )
235 } 235 }
236 236
237 #endif 237 #endif
OLDNEW
« no previous file with comments | « gm/beziereffects.cpp ('k') | include/gpu/GrFragmentProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698