OLD | NEW |
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 Loading... |
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 ds.setGeometryProcessor(GrDefaultGeoProcFactory::Create(false))-
>unref(); | 136 const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create(
); |
| 137 ds.setGeometryProcessor(gp)->unref(); |
137 ds.addCoverageProcessor(fp); | 138 ds.addCoverageProcessor(fp); |
138 ds.setIdentityViewMatrix(); | 139 ds.setIdentityViewMatrix(); |
139 ds.setRenderTarget(rt); | 140 ds.setRenderTarget(rt); |
140 ds.setColor(0xff000000); | 141 ds.setColor(0xff000000); |
141 | 142 |
142 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, ds.getVert
exStride(), 0); | 143 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, gp->getVer
texStride(), 0); |
143 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices()); | 144 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices()); |
144 | 145 |
145 SkRect bounds = p.getBounds(); | 146 SkRect bounds = p.getBounds(); |
146 // 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 |
147 // conservative bounding geometry. | 148 // conservative bounding geometry. |
148 bounds.outset(5.f, 5.f); | 149 bounds.outset(5.f, 5.f); |
149 bounds.toQuad(verts); | 150 bounds.toQuad(verts); |
150 | 151 |
151 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer(
)); | 152 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer(
)); |
152 tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0
, 4, 6); | 153 tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0
, 4, 6); |
(...skipping 29 matching lines...) Expand all Loading... |
182 } | 183 } |
183 SkRect rect = *iter.get(); | 184 SkRect rect = *iter.get(); |
184 rect.offset(x, y); | 185 rect.offset(x, y); |
185 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; | 186 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; |
186 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(
edgeType, rect)); | 187 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(
edgeType, rect)); |
187 if (!fp) { | 188 if (!fp) { |
188 continue; | 189 continue; |
189 } | 190 } |
190 | 191 |
191 GrDrawState ds; | 192 GrDrawState ds; |
192 ds.setGeometryProcessor(GrDefaultGeoProcFactory::Create(false))-
>unref(); | 193 const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create(
); |
| 194 ds.setGeometryProcessor(gp)->unref(); |
193 ds.addCoverageProcessor(fp); | 195 ds.addCoverageProcessor(fp); |
194 ds.setIdentityViewMatrix(); | 196 ds.setIdentityViewMatrix(); |
195 ds.setRenderTarget(rt); | 197 ds.setRenderTarget(rt); |
196 ds.setColor(0xff000000); | 198 ds.setColor(0xff000000); |
197 | 199 |
198 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, ds.getVert
exStride(), 0); | 200 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, gp->getVer
texStride(), 0); |
199 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices()); | 201 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices()); |
200 | 202 |
201 SkRect bounds = rect; | 203 SkRect bounds = rect; |
202 bounds.outset(5.f, 5.f); | 204 bounds.outset(5.f, 5.f); |
203 bounds.toQuad(verts); | 205 bounds.toQuad(verts); |
204 | 206 |
205 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer(
)); | 207 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer(
)); |
206 tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0
, 4, 6); | 208 tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0
, 4, 6); |
207 | 209 |
208 x += SkScalarCeilToScalar(rect.width() + 10.f); | 210 x += SkScalarCeilToScalar(rect.width() + 10.f); |
(...skipping 17 matching lines...) Expand all Loading... |
226 SkTLList<SkPath> fPaths; | 228 SkTLList<SkPath> fPaths; |
227 SkTLList<SkRect> fRects; | 229 SkTLList<SkRect> fRects; |
228 | 230 |
229 typedef GM INHERITED; | 231 typedef GM INHERITED; |
230 }; | 232 }; |
231 | 233 |
232 DEF_GM( return SkNEW(ConvexPolyEffect); ) | 234 DEF_GM( return SkNEW(ConvexPolyEffect); ) |
233 } | 235 } |
234 | 236 |
235 #endif | 237 #endif |
OLD | NEW |