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

Side by Side Diff: gm/convexpolyeffect.cpp

Issue 715903002: Push creation of default GP to the caller (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: added comment Created 6 years, 1 month 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 | « no previous file | src/gpu/GrAAHairLinePathRenderer.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
11 #include "gm.h" 11 #include "gm.h"
12 12
13 #if SK_SUPPORT_GPU 13 #if SK_SUPPORT_GPU
14 14
15 #include "GrContext.h" 15 #include "GrContext.h"
16 #include "GrDefaultGeoProcFactory.h"
16 #include "GrPathUtils.h" 17 #include "GrPathUtils.h"
17 #include "GrTest.h" 18 #include "GrTest.h"
18 #include "SkColorPriv.h" 19 #include "SkColorPriv.h"
19 #include "SkDevice.h" 20 #include "SkDevice.h"
20 #include "SkGeometry.h" 21 #include "SkGeometry.h"
21 #include "SkTLList.h" 22 #include "SkTLList.h"
22 23
23 #include "effects/GrConvexPolyEffect.h" 24 #include "effects/GrConvexPolyEffect.h"
24 25
25 namespace skiagm { 26 namespace skiagm {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 SkMatrix m; 126 SkMatrix m;
126 SkPath p; 127 SkPath p;
127 m.setTranslate(x, y); 128 m.setTranslate(x, y);
128 path->transform(m, &p); 129 path->transform(m, &p);
129 130
130 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; 131 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
131 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, p)); 132 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, p));
132 if (!fp) { 133 if (!fp) {
133 continue; 134 continue;
134 } 135 }
136 drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create( false))->unref();
135 drawState->addCoverageProcessor(fp); 137 drawState->addCoverageProcessor(fp);
136 drawState->setIdentityViewMatrix(); 138 drawState->setIdentityViewMatrix();
137 drawState->setRenderTarget(rt); 139 drawState->setRenderTarget(rt);
138 drawState->setColor(0xff000000); 140 drawState->setColor(0xff000000);
139 141
140 // TODO hack
141 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, 0); 142 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, 0);
142 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices()); 143 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices());
143 144
144 //SkPoint verts[4];
145 SkRect bounds = p.getBounds(); 145 SkRect bounds = p.getBounds();
146 // Make sure any artifacts around the exterior of path are visib le by using overly 146 // Make sure any artifacts around the exterior of path are visib le by using overly
147 // conservative bounding geometry. 147 // conservative bounding geometry.
148 bounds.outset(5.f, 5.f); 148 bounds.outset(5.f, 5.f);
149 bounds.toQuad(verts); 149 bounds.toQuad(verts);
150 150
151 //tt.target()->setVertexSourceToArray(verts, 4);
152 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer( )); 151 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer( ));
153 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0, 4, 6); 152 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0, 4, 6);
154 153
155 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f); 154 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f);
156 } 155 }
157 156
158 // Draw AA and non AA paths using normal API for reference. 157 // Draw AA and non AA paths using normal API for reference.
159 canvas->save(); 158 canvas->save();
160 canvas->translate(x, y); 159 canvas->translate(x, y);
161 SkPaint paint; 160 SkPaint paint;
(...skipping 21 matching lines...) Expand all
183 } 182 }
184 SkRect rect = *iter.get(); 183 SkRect rect = *iter.get();
185 rect.offset(x, y); 184 rect.offset(x, y);
186 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; 185 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
187 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, rect)); 186 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, rect));
188 if (!fp) { 187 if (!fp) {
189 continue; 188 continue;
190 } 189 }
191 190
192 GrDrawState* drawState = tt.target()->drawState(); 191 GrDrawState* drawState = tt.target()->drawState();
192 drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create( false))->unref();
193 drawState->addCoverageProcessor(fp); 193 drawState->addCoverageProcessor(fp);
194 drawState->setIdentityViewMatrix(); 194 drawState->setIdentityViewMatrix();
195 drawState->setRenderTarget(rt); 195 drawState->setRenderTarget(rt);
196 drawState->setColor(0xff000000); 196 drawState->setColor(0xff000000);
197 197
198 // TODO hack
199 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, 0); 198 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, 0);
200 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices()); 199 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices());
201 200
202 //SkPoint verts[4];
203 SkRect bounds = rect; 201 SkRect bounds = rect;
204 bounds.outset(5.f, 5.f); 202 bounds.outset(5.f, 5.f);
205 bounds.toQuad(verts); 203 bounds.toQuad(verts);
206 204
207 //tt.target()->setVertexSourceToArray(verts, 4);
208 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer( )); 205 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer( ));
209 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0, 4, 6); 206 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0, 4, 6);
210 207
211 x += SkScalarCeilToScalar(rect.width() + 10.f); 208 x += SkScalarCeilToScalar(rect.width() + 10.f);
212 } 209 }
213 210
214 // Draw rect without and with AA using normal API for reference 211 // Draw rect without and with AA using normal API for reference
215 canvas->save(); 212 canvas->save();
216 canvas->translate(x, y); 213 canvas->translate(x, y);
217 SkPaint paint; 214 SkPaint paint;
(...skipping 11 matching lines...) Expand all
229 SkTLList<SkPath> fPaths; 226 SkTLList<SkPath> fPaths;
230 SkTLList<SkRect> fRects; 227 SkTLList<SkRect> fRects;
231 228
232 typedef GM INHERITED; 229 typedef GM INHERITED;
233 }; 230 };
234 231
235 DEF_GM( return SkNEW(ConvexPolyEffect); ) 232 DEF_GM( return SkNEW(ConvexPolyEffect); )
236 } 233 }
237 234
238 #endif 235 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrAAHairLinePathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698