diff options
author | 2015-02-12 13:02:57 -0800 | |
---|---|---|
committer | 2015-02-12 13:02:57 -0800 | |
commit | cd963666006f7171e1dc2156ecf5016d53a7af5b (patch) | |
tree | abddb431d0651a9162df82105f4139493ad6fa35 /src/gpu/GrAARectRenderer.cpp | |
parent | c63de323e14148563a9e978eaa42a9a63b44adc1 (diff) |
Revert of AA stroke rects batch (patchset #5 id:80001 of https://codereview.chromium.org/912483004/)
Reason for revert:
breaks windows
Original issue's description:
> AA stroke rects batch
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/68c7b6aa98816badbbb69ef65a84a932b8dd58f3
TBR=bsalomon@google.com,robertphillips@google.com,joshualitt@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/921923002
Diffstat (limited to 'src/gpu/GrAARectRenderer.cpp')
-rw-r--r-- | src/gpu/GrAARectRenderer.cpp | 478 |
1 files changed, 152 insertions, 326 deletions
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp index 9ac2be2cbc..420c9e7c5a 100644 --- a/src/gpu/GrAARectRenderer.cpp +++ b/src/gpu/GrAARectRenderer.cpp @@ -109,15 +109,16 @@ public: bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); SkMatrix localMatrix; - if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) { + if (!this->viewMatrix().invert(&localMatrix)) { SkDebugf("Cannot invert\n"); return; } - SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage, - localMatrix)); + const GrGeometryProcessor* gp = create_fill_rect_gp(canTweakAlphaForCoverage, + localMatrix); batchTarget->initDraw(gp, pipeline); + gp->unref(); // TODO this is hacky, but the only way we have to initialize the GP is to use the // GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch @@ -141,7 +142,7 @@ public: const GrVertexBuffer* vertexBuffer; int firstVertex; - void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, + void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, vertexCount, &vertexBuffer, &firstVertex); @@ -149,13 +150,13 @@ public: 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); + i * kVertsPerAAFillRect * vertexStride, + vertexStride, + args.fColor, + args.fViewMatrix, + args.fRect, + args.fDevRect, + canTweakAlphaForCoverage); } GrDrawTarget::DrawInfo drawInfo; @@ -199,10 +200,15 @@ private: bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { AAFillRectBatch* that = t->cast<AAFillRectBatch>(); + if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage()) { + return false; + } - SkASSERT(this->canTweakAlphaForCoverage() == that->canTweakAlphaForCoverage() && - this->usesLocalCoords() == that->usesLocalCoords() && - this->colorIgnored() == that->colorIgnored()); + if (this->colorIgnored() != that->colorIgnored()) { + return false; + } + + SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); // We apply the viewmatrix to the rect points on the cpu. However, if the pipeline uses // local coords then we won't be able to batch. We could actually upload the viewmatrix // using vertex attributes in these cases, but haven't investigated that @@ -540,343 +546,163 @@ void GrAARectRenderer::strokeAARect(GrDrawTarget* target, devOutsideAssist, devInside, miterStroke); } -class AAStrokeRectBatch : public GrBatch { -public: - // TODO support AA rotated stroke rects by copying around view matrices - struct Geometry { - GrColor fColor; - SkRect fDevOutside; - SkRect fDevOutsideAssist; - SkRect fDevInside; - bool fMiterStroke; - }; - - static GrBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix, - const GrIndexBuffer* indexBuffer) { - return SkNEW_ARGS(AAStrokeRectBatch, (geometry, viewMatrix, indexBuffer)); +static const GrGeometryProcessor* create_rect_gp(const GrPipelineBuilder& pipelneBuilder, + GrColor color, + CoverageAttribType* type, + const SkMatrix& localMatrix) { + uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; + const GrGeometryProcessor* gp; + if (pipelneBuilder.canTweakAlphaForCoverage()) { + gp = GrDefaultGeoProcFactory::Create(flags, color, SkMatrix::I(), localMatrix); + SkASSERT(gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::PositionColorAttr)); + *type = kUseColor_CoverageAttribType; + } else { + flags |= GrDefaultGeoProcFactory::kCoverage_GPType; + gp = GrDefaultGeoProcFactory::Create(flags, color, SkMatrix::I(), localMatrix, + GrColorIsOpaque(color)); + SkASSERT(gp->getVertexStride()==sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAttr)); + *type = kUseCoverage_CoverageAttribType; } + return gp; +} - const char* name() const SK_OVERRIDE { return "AAStrokeRect"; } - - void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { - // When this is called on a batch, there is only one geometry bundle - if (!this->canTweakAlphaForCoverage() && GrColorIsOpaque(fGeoData[0].fColor)) { - out->setUnknownOpaqueFourComponents(); - } else { - out->setUnknownFourComponents(); - } - } - void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE { - if (this->canTweakAlphaForCoverage()) { - // uniform coverage - out->setKnownSingleComponent(0xff); - } else { - out->setUnknownSingleComponent(); - } +void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target, + GrPipelineBuilder* pipelineBuilder, + GrColor color, + const SkMatrix& viewMatrix, + const SkRect& devOutside, + const SkRect& devOutsideAssist, + const SkRect& devInside, + bool miterStroke) { + SkMatrix localMatrix; + if (!viewMatrix.invert(&localMatrix)) { + SkDebugf("Cannot invert\n"); + return; } - void initBatchOpt(const GrBatchOpt& batchOpt) { - fBatchOpt = batchOpt; - } + CoverageAttribType type; + SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(*pipelineBuilder, color, &type, + localMatrix)); - void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { - // Handle any color overrides - if (init.fColorIgnored) { - fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; - } + int innerVertexNum = 4; + int outerVertexNum = miterStroke ? 4 : 8; + int totalVertexNum = (outerVertexNum + innerVertexNum) * 2; - // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; - fBatch.fColor = fGeoData[0].fColor; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; - fBatch.fMiterStroke = fGeoData[0].fMiterStroke; + size_t vstride = gp->getVertexStride(); + GrDrawTarget::AutoReleaseGeometry geo(target, totalVertexNum, vstride, 0); + if (!geo.succeeded()) { + SkDebugf("Failed to get space for vertices!\n"); + return; } - - void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) SK_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)); - - batchTarget->initDraw(gp, pipeline); - - // TODO this is hacky, but the only way we have to initialize the GP is to use the - // GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch - // everywhere we can remove this nastiness - GrPipelineInfo init; - init.fColorIgnored = fBatch.fColorIgnored; - init.fOverrideColor = GrColor_ILLEGAL; - init.fCoverageIgnored = fBatch.fCoverageIgnored; - init.fUsesLocalCoords = this->usesLocalCoords(); - gp->initBatchTracker(batchTarget->currentBatchTracker(), init); - - 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 totalVertexNum = (outerVertexNum + innerVertexNum) * 2; - - int instanceCount = fGeoData.count(); - int vertexCount = totalVertexNum * instanceCount; - - const GrVertexBuffer* vertexBuffer; - int firstVertex; - - void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, - vertexCount, - &vertexBuffer, - &firstVertex); - - for (int i = 0; i < instanceCount; i++) { - const Geometry& args = fGeoData[i]; - this->generateAAStrokeRectGeometry(vertices, - i * totalVertexNum * vertexStride, - vertexStride, - outerVertexNum, - innerVertexNum, - args.fColor, - args.fDevOutside, - args.fDevOutsideAssist, - args.fDevInside, - args.fMiterStroke, - canTweakAlphaForCoverage); - } - - GrDrawTarget::DrawInfo drawInfo; - drawInfo.setPrimitiveType(kTriangles_GrPrimitiveType); - drawInfo.setStartVertex(0); - drawInfo.setStartIndex(0); - drawInfo.setVerticesPerInstance(totalVertexNum); - drawInfo.setIndicesPerInstance(aa_stroke_rect_index_count(this->miterStroke())); - drawInfo.adjustStartVertex(firstVertex); - drawInfo.setVertexBuffer(vertexBuffer); - drawInfo.setIndexBuffer(fIndexBuffer); - - int maxInstancesPerDraw = kNumBevelStrokeRectsInIndexBuffer; - - while (instanceCount) { - drawInfo.setInstanceCount(SkTMin(instanceCount, maxInstancesPerDraw)); - drawInfo.setVertexCount(drawInfo.instanceCount() * drawInfo.verticesPerInstance()); - drawInfo.setIndexCount(drawInfo.instanceCount() * drawInfo.indicesPerInstance()); - - batchTarget->draw(drawInfo); - - drawInfo.setStartVertex(drawInfo.startVertex() + drawInfo.vertexCount()); - instanceCount -= drawInfo.instanceCount(); - } + GrIndexBuffer* indexBuffer = this->aaStrokeRectIndexBuffer(miterStroke); + if (NULL == indexBuffer) { + SkDebugf("Failed to create index buffer!\n"); + return; } - SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } - -private: - AAStrokeRectBatch(const Geometry& geometry, const SkMatrix& viewMatrix, - const GrIndexBuffer* indexBuffer) - : fIndexBuffer(indexBuffer) { - this->initClassID<AAStrokeRectBatch>(); - fBatch.fViewMatrix = viewMatrix; - fGeoData.push_back(geometry); + intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices()); + + // We create vertices for four nested rectangles. There are two ramps from 0 to full + // coverage, one on the exterior of the stroke and the other on the interior. + // The following pointers refer to the four rects, from outermost to innermost. + SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts); + SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + outerVertexNum * vstride); + SkPoint* fan2Pos = reinterpret_cast<SkPoint*>(verts + 2 * outerVertexNum * vstride); + SkPoint* fan3Pos = reinterpret_cast<SkPoint*>(verts + (2 * outerVertexNum + innerVertexNum) * vstride); + +#ifndef SK_IGNORE_THIN_STROKED_RECT_FIX + // TODO: this only really works if the X & Y margins are the same all around + // the rect (or if they are all >= 1.0). + SkScalar inset = SkMinScalar(SK_Scalar1, devOutside.fRight - devInside.fRight); + inset = SkMinScalar(inset, devInside.fLeft - devOutside.fLeft); + inset = SkMinScalar(inset, devInside.fTop - devOutside.fTop); + if (miterStroke) { + inset = SK_ScalarHalf * SkMinScalar(inset, devOutside.fBottom - devInside.fBottom); + } else { + inset = SK_ScalarHalf * SkMinScalar(inset, devOutsideAssist.fBottom - devInside.fBottom); } + SkASSERT(inset >= 0); +#else + SkScalar inset = SK_ScalarHalf; +#endif - GrColor color() const { return fBatch.fColor; } - bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } - bool canTweakAlphaForCoverage() const { return fBatchOpt.fCanTweakAlphaForCoverage; } - bool colorIgnored() const { return fBatch.fColorIgnored; } - const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } - bool miterStroke() const { return fBatch.fMiterStroke; } - - bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { - AAStrokeRectBatch* that = t->cast<AAStrokeRectBatch>(); - - // TODO batch across miterstroke changes - if (this->miterStroke() != that->miterStroke()) { - return false; - } + if (miterStroke) { + // outermost + set_inset_fan(fan0Pos, vstride, devOutside, -SK_ScalarHalf, -SK_ScalarHalf); + // inner two + set_inset_fan(fan1Pos, vstride, devOutside, inset, inset); + set_inset_fan(fan2Pos, vstride, devInside, -inset, -inset); + // innermost + set_inset_fan(fan3Pos, vstride, devInside, SK_ScalarHalf, SK_ScalarHalf); + } else { + SkPoint* fan0AssistPos = reinterpret_cast<SkPoint*>(verts + 4 * vstride); + SkPoint* fan1AssistPos = reinterpret_cast<SkPoint*>(verts + (outerVertexNum + 4) * vstride); + // outermost + set_inset_fan(fan0Pos, vstride, devOutside, -SK_ScalarHalf, -SK_ScalarHalf); + set_inset_fan(fan0AssistPos, vstride, devOutsideAssist, -SK_ScalarHalf, -SK_ScalarHalf); + // outer one of the inner two + set_inset_fan(fan1Pos, vstride, devOutside, inset, inset); + set_inset_fan(fan1AssistPos, vstride, devOutsideAssist, inset, inset); + // inner one of the inner two + set_inset_fan(fan2Pos, vstride, devInside, -inset, -inset); + // innermost + set_inset_fan(fan3Pos, vstride, devInside, SK_ScalarHalf, SK_ScalarHalf); + } - SkASSERT(this->canTweakAlphaForCoverage() == that->canTweakAlphaForCoverage() && - this->usesLocalCoords() == that->usesLocalCoords() && - this->colorIgnored() == that->colorIgnored()); - // We apply the viewmatrix to the rect points on the cpu. However, if the pipeline uses - // local coords then we won't be able to batch. We could actually upload the viewmatrix - // using vertex attributes in these cases, but haven't investigated that - if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->viewMatrix())) { - return false; + // Make verts point to vertex color and then set all the color and coverage vertex attrs values. + // The outermost rect has 0 coverage + verts += sizeof(SkPoint); + for (int i = 0; i < outerVertexNum; ++i) { + if (kUseCoverage_CoverageAttribType == type) { + *reinterpret_cast<GrColor*>(verts + i * vstride) = color; + *reinterpret_cast<float*>(verts + i * vstride + sizeof(GrColor)) = 0; + } else { + *reinterpret_cast<GrColor*>(verts + i * vstride) = 0; } + } - if (this->color() != that->color()) { - fBatch.fColor = GrColor_ILLEGAL; - } - fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin()); - return true; + // scale is the coverage for the the inner two rects. + int scale; + if (inset < SK_ScalarHalf) { + scale = SkScalarFloorToInt(512.0f * inset / (inset + SK_ScalarHalf)); + SkASSERT(scale >= 0 && scale <= 255); + } else { + scale = 0xff; } - void generateAAStrokeRectGeometry(void* vertices, - uint32_t offset, - uint32_t vertexStride, - int outerVertexNum, - int innerVertexNum, - GrColor color, - const SkRect& devOutside, - const SkRect& devOutsideAssist, - const SkRect& devInside, - bool miterStroke, - bool tweakAlphaForCoverage) const { - intptr_t verts = reinterpret_cast<intptr_t>(vertices) + offset; + float innerCoverage = GrNormalizeByteToFloat(scale); + GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, scale); - // We create vertices for four nested rectangles. There are two ramps from 0 to full - // coverage, one on the exterior of the stroke and the other on the interior. - // The following pointers refer to the four rects, from outermost to innermost. - SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts); - SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + outerVertexNum * vertexStride); - SkPoint* fan2Pos = reinterpret_cast<SkPoint*>(verts + 2 * outerVertexNum * vertexStride); - SkPoint* fan3Pos = reinterpret_cast<SkPoint*>(verts + - (2 * outerVertexNum + innerVertexNum) * - vertexStride); - - #ifndef SK_IGNORE_THIN_STROKED_RECT_FIX - // TODO: this only really works if the X & Y margins are the same all around - // the rect (or if they are all >= 1.0). - SkScalar inset = SkMinScalar(SK_Scalar1, devOutside.fRight - devInside.fRight); - inset = SkMinScalar(inset, devInside.fLeft - devOutside.fLeft); - inset = SkMinScalar(inset, devInside.fTop - devOutside.fTop); - if (miterStroke) { - inset = SK_ScalarHalf * SkMinScalar(inset, devOutside.fBottom - devInside.fBottom); + verts += outerVertexNum * vstride; + for (int i = 0; i < outerVertexNum + innerVertexNum; ++i) { + if (kUseCoverage_CoverageAttribType == type) { + *reinterpret_cast<GrColor*>(verts + i * vstride) = color; + *reinterpret_cast<float*>(verts + i * vstride + sizeof(GrColor)) = innerCoverage; } else { - inset = SK_ScalarHalf * SkMinScalar(inset, devOutsideAssist.fBottom - - devInside.fBottom); - } - SkASSERT(inset >= 0); - #else - SkScalar inset = SK_ScalarHalf; - #endif - - if (miterStroke) { - // outermost - set_inset_fan(fan0Pos, vertexStride, devOutside, -SK_ScalarHalf, -SK_ScalarHalf); - // inner two - set_inset_fan(fan1Pos, vertexStride, devOutside, inset, inset); - set_inset_fan(fan2Pos, vertexStride, devInside, -inset, -inset); - // innermost - set_inset_fan(fan3Pos, vertexStride, devInside, SK_ScalarHalf, SK_ScalarHalf); - } else { - SkPoint* fan0AssistPos = reinterpret_cast<SkPoint*>(verts + 4 * vertexStride); - SkPoint* fan1AssistPos = reinterpret_cast<SkPoint*>(verts + - (outerVertexNum + 4) * - vertexStride); - // outermost - set_inset_fan(fan0Pos, vertexStride, devOutside, -SK_ScalarHalf, -SK_ScalarHalf); - set_inset_fan(fan0AssistPos, vertexStride, devOutsideAssist, -SK_ScalarHalf, - -SK_ScalarHalf); - // outer one of the inner two - set_inset_fan(fan1Pos, vertexStride, devOutside, inset, inset); - set_inset_fan(fan1AssistPos, vertexStride, devOutsideAssist, inset, inset); - // inner one of the inner two - set_inset_fan(fan2Pos, vertexStride, devInside, -inset, -inset); - // innermost - set_inset_fan(fan3Pos, vertexStride, devInside, SK_ScalarHalf, SK_ScalarHalf); - } - - // Make verts point to vertex color and then set all the color and coverage vertex attrs - // values. The outermost rect has 0 coverage - verts += sizeof(SkPoint); - for (int i = 0; i < outerVertexNum; ++i) { - if (tweakAlphaForCoverage) { - *reinterpret_cast<GrColor*>(verts + i * vertexStride) = 0; - } else { - *reinterpret_cast<GrColor*>(verts + i * vertexStride) = color; - *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)) = 0; - } + *reinterpret_cast<GrColor*>(verts + i * vstride) = scaledColor; } + } - // scale is the coverage for the the inner two rects. - int scale; - if (inset < SK_ScalarHalf) { - scale = SkScalarFloorToInt(512.0f * inset / (inset + SK_ScalarHalf)); - SkASSERT(scale >= 0 && scale <= 255); + // The innermost rect has 0 coverage + verts += (outerVertexNum + innerVertexNum) * vstride; + for (int i = 0; i < innerVertexNum; ++i) { + if (kUseCoverage_CoverageAttribType == type) { + *reinterpret_cast<GrColor*>(verts + i * vstride) = color; + *reinterpret_cast<GrColor*>(verts + i * vstride + sizeof(GrColor)) = 0; } else { - scale = 0xff; - } - - float innerCoverage = GrNormalizeByteToFloat(scale); - GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, scale); - - verts += outerVertexNum * vertexStride; - for (int i = 0; i < outerVertexNum + innerVertexNum; ++i) { - if (tweakAlphaForCoverage) { - *reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor; - } else { - *reinterpret_cast<GrColor*>(verts + i * vertexStride) = color; - *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)) = - innerCoverage; - } - } - - // The innermost rect has 0 coverage - verts += (outerVertexNum + innerVertexNum) * vertexStride; - for (int i = 0; i < innerVertexNum; ++i) { - if (tweakAlphaForCoverage) { - *reinterpret_cast<GrColor*>(verts + i * vertexStride) = 0; - } else { - *reinterpret_cast<GrColor*>(verts + i * vertexStride) = color; - *reinterpret_cast<GrColor*>(verts + i * vertexStride + sizeof(GrColor)) = 0; - } + *reinterpret_cast<GrColor*>(verts + i * vstride) = 0; } } - struct BatchTracker { - SkMatrix fViewMatrix; - GrColor fColor; - bool fUsesLocalCoords; - bool fColorIgnored; - bool fCoverageIgnored; - bool fMiterStroke; - }; - - GrBatchOpt fBatchOpt; - BatchTracker fBatch; - const GrIndexBuffer* fIndexBuffer; - SkSTArray<1, Geometry, true> fGeoData; -}; - - -void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target, - GrPipelineBuilder* pipelineBuilder, - GrColor color, - const SkMatrix& viewMatrix, - const SkRect& devOutside, - const SkRect& devOutsideAssist, - const SkRect& devInside, - bool miterStroke) { - GrIndexBuffer* indexBuffer = this->aaStrokeRectIndexBuffer(miterStroke); - if (NULL == indexBuffer) { - SkDebugf("Failed to create index buffer!\n"); - return; - } - - AAStrokeRectBatch::Geometry geometry; - geometry.fColor = color; - geometry.fDevOutside = devOutside; - geometry.fDevOutsideAssist = devOutsideAssist; - geometry.fDevInside = devInside; - geometry.fMiterStroke = miterStroke; - - SkAutoTUnref<GrBatch> batch(AAStrokeRectBatch::Create(geometry, viewMatrix, indexBuffer)); - target->drawBatch(pipelineBuilder, batch); + target->setIndexSourceToBuffer(indexBuffer); + target->drawIndexedInstances(pipelineBuilder, + gp, + kTriangles_GrPrimitiveType, + 1, + totalVertexNum, + aa_stroke_rect_index_count(miterStroke)); + target->resetIndexSource(); } void GrAARectRenderer::fillAANestedRects(GrDrawTarget* target, |