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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; | 130 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; |
131 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(
edgeType, p)); | 131 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(
edgeType, p)); |
132 if (!fp) { | 132 if (!fp) { |
133 continue; | 133 continue; |
134 } | 134 } |
135 drawState->addCoverageProcessor(fp); | 135 drawState->addCoverageProcessor(fp); |
136 drawState->setIdentityViewMatrix(); | 136 drawState->setIdentityViewMatrix(); |
137 drawState->setRenderTarget(rt); | 137 drawState->setRenderTarget(rt); |
138 drawState->setColor(0xff000000); | 138 drawState->setColor(0xff000000); |
139 | 139 |
140 SkPoint verts[4]; | 140 // TODO hack |
| 141 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, 0); |
| 142 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices()); |
| 143 |
| 144 //SkPoint verts[4]; |
141 SkRect bounds = p.getBounds(); | 145 SkRect bounds = p.getBounds(); |
142 // 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 |
143 // conservative bounding geometry. | 147 // conservative bounding geometry. |
144 bounds.outset(5.f, 5.f); | 148 bounds.outset(5.f, 5.f); |
145 bounds.toQuad(verts); | 149 bounds.toQuad(verts); |
146 | 150 |
147 tt.target()->setVertexSourceToArray(verts, 4); | 151 //tt.target()->setVertexSourceToArray(verts, 4); |
148 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer(
)); | 152 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer(
)); |
149 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0, 4,
6); | 153 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0, 4,
6); |
150 | 154 |
151 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f); | 155 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f); |
152 } | 156 } |
153 | 157 |
154 // Draw AA and non AA paths using normal API for reference. | 158 // Draw AA and non AA paths using normal API for reference. |
155 canvas->save(); | 159 canvas->save(); |
156 canvas->translate(x, y); | 160 canvas->translate(x, y); |
157 SkPaint paint; | 161 SkPaint paint; |
(...skipping 26 matching lines...) Expand all Loading... |
184 if (!fp) { | 188 if (!fp) { |
185 continue; | 189 continue; |
186 } | 190 } |
187 | 191 |
188 GrDrawState* drawState = tt.target()->drawState(); | 192 GrDrawState* drawState = tt.target()->drawState(); |
189 drawState->addCoverageProcessor(fp); | 193 drawState->addCoverageProcessor(fp); |
190 drawState->setIdentityViewMatrix(); | 194 drawState->setIdentityViewMatrix(); |
191 drawState->setRenderTarget(rt); | 195 drawState->setRenderTarget(rt); |
192 drawState->setColor(0xff000000); | 196 drawState->setColor(0xff000000); |
193 | 197 |
194 SkPoint verts[4]; | 198 // TODO hack |
| 199 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, 0); |
| 200 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices()); |
| 201 |
| 202 //SkPoint verts[4]; |
195 SkRect bounds = rect; | 203 SkRect bounds = rect; |
196 bounds.outset(5.f, 5.f); | 204 bounds.outset(5.f, 5.f); |
197 bounds.toQuad(verts); | 205 bounds.toQuad(verts); |
198 | 206 |
199 tt.target()->setVertexSourceToArray(verts, 4); | 207 //tt.target()->setVertexSourceToArray(verts, 4); |
200 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer(
)); | 208 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer(
)); |
201 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0, 4,
6); | 209 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0, 4,
6); |
202 | 210 |
203 x += SkScalarCeilToScalar(rect.width() + 10.f); | 211 x += SkScalarCeilToScalar(rect.width() + 10.f); |
204 } | 212 } |
205 | 213 |
206 // Draw rect without and with AA using normal API for reference | 214 // Draw rect without and with AA using normal API for reference |
207 canvas->save(); | 215 canvas->save(); |
208 canvas->translate(x, y); | 216 canvas->translate(x, y); |
209 SkPaint paint; | 217 SkPaint paint; |
(...skipping 11 matching lines...) Expand all Loading... |
221 SkTLList<SkPath> fPaths; | 229 SkTLList<SkPath> fPaths; |
222 SkTLList<SkRect> fRects; | 230 SkTLList<SkRect> fRects; |
223 | 231 |
224 typedef GM INHERITED; | 232 typedef GM INHERITED; |
225 }; | 233 }; |
226 | 234 |
227 DEF_GM( return SkNEW(ConvexPolyEffect); ) | 235 DEF_GM( return SkNEW(ConvexPolyEffect); ) |
228 } | 236 } |
229 | 237 |
230 #endif | 238 #endif |
OLD | NEW |