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

Side by Side Diff: gm/convexpolyeffect.cpp

Issue 183893023: Unify edge type enums across GrEffect subclasses that clip rendering to a geometry. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: tot again Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « gm/beziereffects.cpp ('k') | gm/rrects.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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return; 113 return;
114 } 114 }
115 115
116 SkScalar y = 0; 116 SkScalar y = 0;
117 for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_I terStart); 117 for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_I terStart);
118 NULL != iter.get(); 118 NULL != iter.get();
119 iter.next()) { 119 iter.next()) {
120 const SkPath* path = iter.get(); 120 const SkPath* path = iter.get();
121 SkScalar x = 0; 121 SkScalar x = 0;
122 122
123 for (int et = 0; et < GrConvexPolyEffect::kEdgeTypeCnt; ++et) { 123 for (int et = 0; et < kGrEffectEdgeTypeCnt; ++et) {
124 GrTestTarget tt; 124 GrTestTarget tt;
125 context->getTestTarget(&tt); 125 context->getTestTarget(&tt);
126 if (NULL == tt.target()) { 126 if (NULL == tt.target()) {
127 SkDEBUGFAIL("Couldn't get Gr test target."); 127 SkDEBUGFAIL("Couldn't get Gr test target.");
128 return; 128 return;
129 } 129 }
130 GrDrawState* drawState = tt.target()->drawState(); 130 GrDrawState* drawState = tt.target()->drawState();
131 drawState->setVertexAttribs<kAttribs>(SK_ARRAY_COUNT(kAttribs)); 131 drawState->setVertexAttribs<kAttribs>(SK_ARRAY_COUNT(kAttribs));
132 132
133 SkMatrix m; 133 SkMatrix m;
134 SkPath p; 134 SkPath p;
135 m.setTranslate(x, y); 135 m.setTranslate(x, y);
136 path->transform(m, &p); 136 path->transform(m, &p);
137 137
138 GrConvexPolyEffect::EdgeType edgeType = (GrConvexPolyEffect::Edg eType) et; 138 GrEffectEdgeType edgeType = (GrEffectEdgeType) et;
139 SkAutoTUnref<GrEffectRef> effect(GrConvexPolyEffect::Create(edge Type, p)); 139 SkAutoTUnref<GrEffectRef> effect(GrConvexPolyEffect::Create(edge Type, p));
140 if (!effect) { 140 if (!effect) {
141 SkDEBUGFAIL("Couldn't create convex poly effect."); 141 continue;
142 return;
143 } 142 }
144 drawState->addCoverageEffect(effect, 1); 143 drawState->addCoverageEffect(effect, 1);
145 drawState->setIdentityViewMatrix(); 144 drawState->setIdentityViewMatrix();
146 drawState->setRenderTarget(rt); 145 drawState->setRenderTarget(rt);
147 drawState->setColor(0xff000000); 146 drawState->setColor(0xff000000);
148 147
149 SkPoint verts[4]; 148 SkPoint verts[4];
150 SkRect bounds = p.getBounds(); 149 SkRect bounds = p.getBounds();
151 // Make sure any artifacts around the exterior of path are visib le by using overly 150 // Make sure any artifacts around the exterior of path are visib le by using overly
152 // conservative bounding geometry. 151 // conservative bounding geometry.
(...skipping 19 matching lines...) Expand all
172 171
173 y += SkScalarCeilToScalar(path->getBounds().height() + 20.f); 172 y += SkScalarCeilToScalar(path->getBounds().height() + 20.f);
174 } 173 }
175 174
176 for (SkTLList<SkRect>::Iter iter(fRects, SkTLList<SkRect>::Iter::kHead_I terStart); 175 for (SkTLList<SkRect>::Iter iter(fRects, SkTLList<SkRect>::Iter::kHead_I terStart);
177 NULL != iter.get(); 176 NULL != iter.get();
178 iter.next()) { 177 iter.next()) {
179 178
180 SkScalar x = 0; 179 SkScalar x = 0;
181 180
182 for (int et = 0; et < GrConvexPolyEffect::kEdgeTypeCnt; ++et) { 181 for (int et = 0; et < kGrEffectEdgeTypeCnt; ++et) {
183 GrTestTarget tt; 182 GrTestTarget tt;
184 context->getTestTarget(&tt); 183 context->getTestTarget(&tt);
185 if (NULL == tt.target()) { 184 if (NULL == tt.target()) {
186 SkDEBUGFAIL("Couldn't get Gr test target."); 185 SkDEBUGFAIL("Couldn't get Gr test target.");
187 return; 186 return;
188 } 187 }
189 SkRect rect = *iter.get(); 188 SkRect rect = *iter.get();
190 rect.offset(x, y); 189 rect.offset(x, y);
191 GrConvexPolyEffect::EdgeType edgeType = (GrConvexPolyEffect::Edg eType) et; 190 GrEffectEdgeType edgeType = (GrEffectEdgeType) et;
192 SkAutoTUnref<GrEffectRef> effect(GrConvexPolyEffect::Create(edge Type, rect)); 191 SkAutoTUnref<GrEffectRef> effect(GrConvexPolyEffect::Create(edge Type, rect));
193 if (!effect) { 192 if (!effect) {
194 SkDEBUGFAIL("Couldn't create convex poly effect."); 193 continue;
195 return;
196 } 194 }
197 195
198 GrDrawState* drawState = tt.target()->drawState(); 196 GrDrawState* drawState = tt.target()->drawState();
199 drawState->setVertexAttribs<kAttribs>(SK_ARRAY_COUNT(kAttribs)); 197 drawState->setVertexAttribs<kAttribs>(SK_ARRAY_COUNT(kAttribs));
200 drawState->addCoverageEffect(effect, 1); 198 drawState->addCoverageEffect(effect, 1);
201 drawState->setIdentityViewMatrix(); 199 drawState->setIdentityViewMatrix();
202 drawState->setRenderTarget(rt); 200 drawState->setRenderTarget(rt);
203 drawState->setColor(0xff000000); 201 drawState->setColor(0xff000000);
204 202
205 SkPoint verts[4]; 203 SkPoint verts[4];
(...skipping 26 matching lines...) Expand all
232 SkTLList<SkPath> fPaths; 230 SkTLList<SkPath> fPaths;
233 SkTLList<SkRect> fRects; 231 SkTLList<SkRect> fRects;
234 232
235 typedef GM INHERITED; 233 typedef GM INHERITED;
236 }; 234 };
237 235
238 DEF_GM( return SkNEW(ConvexPolyEffect); ) 236 DEF_GM( return SkNEW(ConvexPolyEffect); )
239 } 237 }
240 238
241 #endif 239 #endif
OLDNEW
« no previous file with comments | « gm/beziereffects.cpp ('k') | gm/rrects.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698