void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); // Local matrix is ignored if we don't have local coords. If we have localcoords we only // batch with identical view matrices SkMatrix localMatrix; if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) { SkDebugf("Cannot invert\n"); return; } SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage, localMatrix, this->usesLocalCoords(), this->coverageIgnored())); batchTarget->initDraw(gp, pipeline); size_t vertexStride = gp->getVertexStride(); SkASSERT(canTweakAlphaForCoverage ? vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr) : vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAttr)); int innerVertexNum = 4; int outerVertexNum = this->miterStroke() ? 4 : 8; int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2; int indicesPerInstance = this->miterStroke() ? kMiterIndexCnt : kBevelIndexCnt; int instanceCount = fGeoData.count(); const SkAutoTUnref<const GrIndexBuffer> indexBuffer( GetIndexBuffer(batchTarget->resourceProvider(), this->miterStroke())); InstancedHelper helper; void* vertices = helper.init(batchTarget, kTriangles_GrPrimitiveType, vertexStride, indexBuffer, verticesPerInstance, indicesPerInstance, instanceCount); if (!vertices || !indexBuffer) { SkDebugf("Could not allocate vertices\n"); return; } for (int i = 0; i < instanceCount; i++) { const Geometry& args = fGeoData[i]; this->generateAAStrokeRectGeometry(vertices, i * verticesPerInstance * vertexStride, vertexStride, outerVertexNum, innerVertexNum, args.fColor, args.fDevOutside, args.fDevOutsideAssist, args.fDevInside, args.fMiterStroke, canTweakAlphaForCoverage); } helper.issueDraw(batchTarget); }
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); SkMatrix localMatrix; if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) { SkDebugf("Cannot invert\n"); return; } SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage, localMatrix, this->usesLocalCoords(), this->coverageIgnored())); batchTarget->initDraw(gp, pipeline); size_t vertexStride = gp->getVertexStride(); SkASSERT(canTweakAlphaForCoverage ? vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr) : vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAttr)); int instanceCount = fGeoData.count(); SkAutoTUnref<const GrIndexBuffer> indexBuffer(this->getIndexBuffer( batchTarget->resourceProvider())); InstancedHelper helper; void* vertices = helper.init(batchTarget, kTriangles_GrPrimitiveType, vertexStride, indexBuffer, kVertsPerAAFillRect, kIndicesPerAAFillRect, instanceCount); if (!vertices || !indexBuffer) { SkDebugf("Could not allocate vertices\n"); return; } for (int i = 0; i < instanceCount; i++) { const Geometry& args = fGeoData[i]; this->generateAAFillRectGeometry(vertices, i * kVertsPerAAFillRect * vertexStride, vertexStride, args.fColor, args.fViewMatrix, args.fRect, args.fDevRect, canTweakAlphaForCoverage); } helper.issueDraw(batchTarget); }