| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrOvalRenderer.h" | 8 #include "GrOvalRenderer.h" |
| 9 | 9 |
| 10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
| (...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { | 1001 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { |
| 1002 SkMatrix invert; | 1002 SkMatrix invert; |
| 1003 if (!this->viewMatrix().invert(&invert)) { | 1003 if (!this->viewMatrix().invert(&invert)) { |
| 1004 return; | 1004 return; |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 // Setup geometry processor | 1007 // Setup geometry processor |
| 1008 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), | 1008 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), |
| 1009 this->str
oke(), | 1009 this->str
oke(), |
| 1010 invert)); | 1010 invert)); |
| 1011 SkASSERT(gp->getVertexStride() == sizeof(EllipseVertex)); | |
| 1012 | 1011 |
| 1013 batchTarget->initDraw(gp, pipeline); | 1012 batchTarget->initDraw(gp, pipeline); |
| 1014 | 1013 |
| 1015 // TODO this is hacky, but the only way we have to initialize the GP is
to use the | 1014 // TODO this is hacky, but the only way we have to initialize the GP is
to use the |
| 1016 // GrPipelineInfo struct so we can generate the correct shader. Once we
have GrBatch | 1015 // GrPipelineInfo struct so we can generate the correct shader. Once we
have GrBatch |
| 1017 // everywhere we can remove this nastiness | 1016 // everywhere we can remove this nastiness |
| 1018 GrPipelineInfo init; | 1017 GrPipelineInfo init; |
| 1019 init.fColorIgnored = fBatch.fColorIgnored; | 1018 init.fColorIgnored = fBatch.fColorIgnored; |
| 1020 init.fOverrideColor = GrColor_ILLEGAL; | 1019 init.fOverrideColor = GrColor_ILLEGAL; |
| 1021 init.fCoverageIgnored = fBatch.fCoverageIgnored; | 1020 init.fCoverageIgnored = fBatch.fCoverageIgnored; |
| 1022 init.fUsesLocalCoords = this->usesLocalCoords(); | 1021 init.fUsesLocalCoords = this->usesLocalCoords(); |
| 1023 gp->initBatchTracker(batchTarget->currentBatchTracker(), init); | 1022 gp->initBatchTracker(batchTarget->currentBatchTracker(), init); |
| 1024 | 1023 |
| 1025 int instanceCount = fGeoData.count(); | 1024 int instanceCount = fGeoData.count(); |
| 1026 int vertexCount = kVertsPerEllipse * instanceCount; | 1025 int vertexCount = kVertsPerEllipse * instanceCount; |
| 1027 size_t vertexStride = gp->getVertexStride(); | 1026 size_t vertexStride = gp->getVertexStride(); |
| 1028 SkASSERT(vertexStride == sizeof(CircleVertex)); | 1027 SkASSERT(vertexStride == sizeof(EllipseVertex)); |
| 1029 | 1028 |
| 1030 const GrVertexBuffer* vertexBuffer; | 1029 const GrVertexBuffer* vertexBuffer; |
| 1031 int firstVertex; | 1030 int firstVertex; |
| 1032 | 1031 |
| 1033 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, | 1032 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, |
| 1034 vertexCount, | 1033 vertexCount, |
| 1035 &vertexBuffer, | 1034 &vertexBuffer, |
| 1036 &firstVertex); | 1035 &firstVertex); |
| 1037 | 1036 |
| 1038 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(vertices); | 1037 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(vertices); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; | 1298 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
| 1300 fBatch.fCoverageIgnored = init.fCoverageIgnored; | 1299 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
| 1301 } | 1300 } |
| 1302 | 1301 |
| 1303 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { | 1302 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { |
| 1304 // Setup geometry processor | 1303 // Setup geometry processor |
| 1305 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c
olor(), | 1304 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c
olor(), |
| 1306 this->v
iewMatrix(), | 1305 this->v
iewMatrix(), |
| 1307 this->m
ode())); | 1306 this->m
ode())); |
| 1308 | 1307 |
| 1309 SkASSERT(gp->getVertexStride() == sizeof(DIEllipseVertex)); | |
| 1310 | |
| 1311 batchTarget->initDraw(gp, pipeline); | 1308 batchTarget->initDraw(gp, pipeline); |
| 1312 | 1309 |
| 1313 // TODO this is hacky, but the only way we have to initialize the GP is
to use the | 1310 // TODO this is hacky, but the only way we have to initialize the GP is
to use the |
| 1314 // GrPipelineInfo struct so we can generate the correct shader. Once we
have GrBatch | 1311 // GrPipelineInfo struct so we can generate the correct shader. Once we
have GrBatch |
| 1315 // everywhere we can remove this nastiness | 1312 // everywhere we can remove this nastiness |
| 1316 GrPipelineInfo init; | 1313 GrPipelineInfo init; |
| 1317 init.fColorIgnored = fBatch.fColorIgnored; | 1314 init.fColorIgnored = fBatch.fColorIgnored; |
| 1318 init.fOverrideColor = GrColor_ILLEGAL; | 1315 init.fOverrideColor = GrColor_ILLEGAL; |
| 1319 init.fCoverageIgnored = fBatch.fCoverageIgnored; | 1316 init.fCoverageIgnored = fBatch.fCoverageIgnored; |
| 1320 init.fUsesLocalCoords = this->usesLocalCoords(); | 1317 init.fUsesLocalCoords = this->usesLocalCoords(); |
| 1321 gp->initBatchTracker(batchTarget->currentBatchTracker(), init); | 1318 gp->initBatchTracker(batchTarget->currentBatchTracker(), init); |
| 1322 | 1319 |
| 1323 int instanceCount = fGeoData.count(); | 1320 int instanceCount = fGeoData.count(); |
| 1324 int vertexCount = kVertsPerEllipse * instanceCount; | 1321 int vertexCount = kVertsPerEllipse * instanceCount; |
| 1325 size_t vertexStride = gp->getVertexStride(); | 1322 size_t vertexStride = gp->getVertexStride(); |
| 1326 SkASSERT(vertexStride == sizeof(CircleVertex)); | 1323 SkASSERT(vertexStride == sizeof(DIEllipseVertex)); |
| 1327 | 1324 |
| 1328 const GrVertexBuffer* vertexBuffer; | 1325 const GrVertexBuffer* vertexBuffer; |
| 1329 int firstVertex; | 1326 int firstVertex; |
| 1330 | 1327 |
| 1331 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, | 1328 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, |
| 1332 vertexCount, | 1329 vertexCount, |
| 1333 &vertexBuffer, | 1330 &vertexBuffer, |
| 1334 &firstVertex); | 1331 &firstVertex); |
| 1335 | 1332 |
| 1336 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(vertices); | 1333 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(vertices); |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2238 geometry.fInnerXRadius = innerXRadius; | 2235 geometry.fInnerXRadius = innerXRadius; |
| 2239 geometry.fInnerYRadius = innerYRadius; | 2236 geometry.fInnerYRadius = innerYRadius; |
| 2240 geometry.fStroke = isStrokeOnly; | 2237 geometry.fStroke = isStrokeOnly; |
| 2241 geometry.fDevBounds = bounds; | 2238 geometry.fDevBounds = bounds; |
| 2242 | 2239 |
| 2243 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); | 2240 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); |
| 2244 target->drawBatch(pipelineBuilder, batch, &bounds); | 2241 target->drawBatch(pipelineBuilder, batch, &bounds); |
| 2245 } | 2242 } |
| 2246 return true; | 2243 return true; |
| 2247 } | 2244 } |
| OLD | NEW |