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