OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrAARectRenderer.h" | 8 #include "GrAARectRenderer.h" |
9 #include "GrBatch.h" | 9 #include "GrBatch.h" |
10 #include "GrBatchTarget.h" | 10 #include "GrBatchTarget.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 init.getOverrideColorIfSet(&fGeoData[0].fColor); | 87 init.getOverrideColorIfSet(&fGeoData[0].fColor); |
88 | 88 |
89 // setup batch properties | 89 // setup batch properties |
90 fBatch.fColorIgnored = !init.readsColor(); | 90 fBatch.fColorIgnored = !init.readsColor(); |
91 fBatch.fColor = fGeoData[0].fColor; | 91 fBatch.fColor = fGeoData[0].fColor; |
92 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 92 fBatch.fUsesLocalCoords = init.readsLocalCoords(); |
93 fBatch.fCoverageIgnored = !init.readsCoverage(); | 93 fBatch.fCoverageIgnored = !init.readsCoverage(); |
94 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); | 94 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); |
95 } | 95 } |
96 | 96 |
97 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 97 void generateGeometry(GrBatchTarget* batchTarget) override { |
98 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); | 98 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); |
99 | 99 |
100 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakA
lphaForCoverage, | 100 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakA
lphaForCoverage, |
101 this->vie
wMatrix(), | 101 this->vie
wMatrix(), |
102 this->use
sLocalCoords(), | 102 this->use
sLocalCoords(), |
103 this->cov
erageIgnored())); | 103 this->cov
erageIgnored())); |
104 if (!gp) { | 104 if (!gp) { |
105 SkDebugf("Couldn't create GrGeometryProcessor\n"); | 105 SkDebugf("Couldn't create GrGeometryProcessor\n"); |
106 return; | 106 return; |
107 } | 107 } |
108 | 108 |
109 batchTarget->initDraw(gp, pipeline); | 109 batchTarget->initDraw(gp, this->pipeline()); |
110 | 110 |
111 size_t vertexStride = gp->getVertexStride(); | 111 size_t vertexStride = gp->getVertexStride(); |
112 SkASSERT(canTweakAlphaForCoverage ? | 112 SkASSERT(canTweakAlphaForCoverage ? |
113 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt
tr) : | 113 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt
tr) : |
114 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo
verageAttr)); | 114 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo
verageAttr)); |
115 int instanceCount = fGeoData.count(); | 115 int instanceCount = fGeoData.count(); |
116 | 116 |
117 SkAutoTUnref<const GrIndexBuffer> indexBuffer(this->getIndexBuffer( | 117 SkAutoTUnref<const GrIndexBuffer> indexBuffer(this->getIndexBuffer( |
118 batchTarget->resourceProvider())); | 118 batchTarget->resourceProvider())); |
119 InstancedHelper helper; | 119 InstancedHelper helper; |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 437 |
438 // setup batch properties | 438 // setup batch properties |
439 fBatch.fColorIgnored = !init.readsColor(); | 439 fBatch.fColorIgnored = !init.readsColor(); |
440 fBatch.fColor = fGeoData[0].fColor; | 440 fBatch.fColor = fGeoData[0].fColor; |
441 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 441 fBatch.fUsesLocalCoords = init.readsLocalCoords(); |
442 fBatch.fCoverageIgnored = !init.readsCoverage(); | 442 fBatch.fCoverageIgnored = !init.readsCoverage(); |
443 fBatch.fMiterStroke = fGeoData[0].fMiterStroke; | 443 fBatch.fMiterStroke = fGeoData[0].fMiterStroke; |
444 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); | 444 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); |
445 } | 445 } |
446 | 446 |
447 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 447 void generateGeometry(GrBatchTarget* batchTarget) override { |
448 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); | 448 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); |
449 | 449 |
450 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakA
lphaForCoverage, | 450 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakA
lphaForCoverage, |
451 this->vie
wMatrix(), | 451 this->vie
wMatrix(), |
452 this->use
sLocalCoords(), | 452 this->use
sLocalCoords(), |
453 this->cov
erageIgnored())); | 453 this->cov
erageIgnored())); |
454 if (!gp) { | 454 if (!gp) { |
455 SkDebugf("Couldn't create GrGeometryProcessor\n"); | 455 SkDebugf("Couldn't create GrGeometryProcessor\n"); |
456 return; | 456 return; |
457 } | 457 } |
458 | 458 |
459 batchTarget->initDraw(gp, pipeline); | 459 batchTarget->initDraw(gp, this->pipeline()); |
460 | 460 |
461 size_t vertexStride = gp->getVertexStride(); | 461 size_t vertexStride = gp->getVertexStride(); |
462 | 462 |
463 SkASSERT(canTweakAlphaForCoverage ? | 463 SkASSERT(canTweakAlphaForCoverage ? |
464 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt
tr) : | 464 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt
tr) : |
465 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo
verageAttr)); | 465 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo
verageAttr)); |
466 int innerVertexNum = 4; | 466 int innerVertexNum = 4; |
467 int outerVertexNum = this->miterStroke() ? 4 : 8; | 467 int outerVertexNum = this->miterStroke() ? 4 : 8; |
468 int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2; | 468 int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2; |
469 int indicesPerInstance = this->miterStroke() ? kMiterIndexCnt : kBevelIn
dexCnt; | 469 int indicesPerInstance = this->miterStroke() ? kMiterIndexCnt : kBevelIn
dexCnt; |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 geo.fColor = GrRandomColor(random); | 848 geo.fColor = GrRandomColor(random); |
849 geo.fDevOutside = outside; | 849 geo.fDevOutside = outside; |
850 geo.fDevOutsideAssist = outsideAssist; | 850 geo.fDevOutsideAssist = outsideAssist; |
851 geo.fDevInside = inside; | 851 geo.fDevInside = inside; |
852 geo.fMiterStroke = miterStroke; | 852 geo.fMiterStroke = miterStroke; |
853 | 853 |
854 return AAStrokeRectBatch::Create(geo, GrTest::TestMatrix(random)); | 854 return AAStrokeRectBatch::Create(geo, GrTest::TestMatrix(random)); |
855 } | 855 } |
856 | 856 |
857 #endif | 857 #endif |
OLD | NEW |