Revert of AA stroke rects batch (patchset #6 id:100001 of https://codereview.chromium.org/912483004/)

Reason for revert:
breaks in debug nanobench

Original issue's description:
> AA stroke rects batch
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/68c7b6aa98816badbbb69ef65a84a932b8dd58f3
>
> Committed: https://skia.googlesource.com/skia/+/b0fb935bd544b0c6f68c692c7e1ee40876184a1a

TBR=bsalomon@google.com,robertphillips@google.com,joshualitt@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/924533004
This commit is contained in:
joshualitt 2015-02-12 15:03:49 -08:00 committed by Commit bot
parent dd2198701b
commit 84b13dfde1

View File

@ -109,15 +109,16 @@ public:
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
SkMatrix localMatrix; SkMatrix localMatrix;
if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) { if (!this->viewMatrix().invert(&localMatrix)) {
SkDebugf("Cannot invert\n"); SkDebugf("Cannot invert\n");
return; return;
} }
SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage, const GrGeometryProcessor* gp = create_fill_rect_gp(canTweakAlphaForCoverage,
localMatrix)); localMatrix);
batchTarget->initDraw(gp, pipeline); batchTarget->initDraw(gp, pipeline);
gp->unref();
// TODO this is hacky, but the only way we have to initialize the GP is to use the // 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 // GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
@ -141,7 +142,7 @@ public:
const GrVertexBuffer* vertexBuffer; const GrVertexBuffer* vertexBuffer;
int firstVertex; int firstVertex;
void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
vertexCount, vertexCount,
&vertexBuffer, &vertexBuffer,
&firstVertex); &firstVertex);
@ -149,13 +150,13 @@ public:
for (int i = 0; i < instanceCount; i++) { for (int i = 0; i < instanceCount; i++) {
const Geometry& args = fGeoData[i]; const Geometry& args = fGeoData[i];
this->generateAAFillRectGeometry(vertices, this->generateAAFillRectGeometry(vertices,
i * kVertsPerAAFillRect * vertexStride, i * kVertsPerAAFillRect * vertexStride,
vertexStride, vertexStride,
args.fColor, args.fColor,
args.fViewMatrix, args.fViewMatrix,
args.fRect, args.fRect,
args.fDevRect, args.fDevRect,
canTweakAlphaForCoverage); canTweakAlphaForCoverage);
} }
GrDrawTarget::DrawInfo drawInfo; GrDrawTarget::DrawInfo drawInfo;
@ -199,10 +200,15 @@ private:
bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE {
AAFillRectBatch* that = t->cast<AAFillRectBatch>(); AAFillRectBatch* that = t->cast<AAFillRectBatch>();
if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage()) {
return false;
}
SkASSERT(this->canTweakAlphaForCoverage() == that->canTweakAlphaForCoverage() && if (this->colorIgnored() != that->colorIgnored()) {
this->usesLocalCoords() == that->usesLocalCoords() && return false;
this->colorIgnored() == that->colorIgnored()); }
SkASSERT(this->usesLocalCoords() == that->usesLocalCoords());
// We apply the viewmatrix to the rect points on the cpu. However, if the pipeline uses // 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 // 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 // using vertex attributes in these cases, but haven't investigated that
@ -540,318 +546,25 @@ void GrAARectRenderer::strokeAARect(GrDrawTarget* target,
devOutsideAssist, devInside, miterStroke); devOutsideAssist, devInside, miterStroke);
} }
class AAStrokeRectBatch : public GrBatch { static const GrGeometryProcessor* create_rect_gp(const GrPipelineBuilder& pipelneBuilder,
public: GrColor color,
// TODO support AA rotated stroke rects by copying around view matrices CoverageAttribType* type,
struct Geometry { const SkMatrix& localMatrix) {
GrColor fColor; uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType;
SkRect fDevOutside; const GrGeometryProcessor* gp;
SkRect fDevOutsideAssist; if (pipelneBuilder.canTweakAlphaForCoverage()) {
SkRect fDevInside; gp = GrDefaultGeoProcFactory::Create(flags, color, SkMatrix::I(), localMatrix);
bool fMiterStroke; SkASSERT(gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::PositionColorAttr));
}; *type = kUseColor_CoverageAttribType;
} else {
static GrBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix, flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
const GrIndexBuffer* indexBuffer) { gp = GrDefaultGeoProcFactory::Create(flags, color, SkMatrix::I(), localMatrix,
return SkNEW_ARGS(AAStrokeRectBatch, (geometry, viewMatrix, indexBuffer)); 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 initBatchOpt(const GrBatchOpt& batchOpt) {
fBatchOpt = batchOpt;
}
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;
}
// 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;
}
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();
}
}
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);
}
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;
}
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;
}
if (this->color() != that->color()) {
fBatch.fColor = GrColor_ILLEGAL;
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
return true;
}
void generateAAStrokeRectGeometry(void* vertices,
size_t offset,
size_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;
// 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);
} 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;
}
}
// 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;
}
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;
}
}
}
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, void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target,
@ -862,21 +575,134 @@ void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target,
const SkRect& devOutsideAssist, const SkRect& devOutsideAssist,
const SkRect& devInside, const SkRect& devInside,
bool miterStroke) { bool miterStroke) {
SkMatrix localMatrix;
if (!viewMatrix.invert(&localMatrix)) {
SkDebugf("Cannot invert\n");
return;
}
CoverageAttribType type;
SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(*pipelineBuilder, color, &type,
localMatrix));
int innerVertexNum = 4;
int outerVertexNum = miterStroke ? 4 : 8;
int totalVertexNum = (outerVertexNum + innerVertexNum) * 2;
size_t vstride = gp->getVertexStride();
GrDrawTarget::AutoReleaseGeometry geo(target, totalVertexNum, vstride, 0);
if (!geo.succeeded()) {
SkDebugf("Failed to get space for vertices!\n");
return;
}
GrIndexBuffer* indexBuffer = this->aaStrokeRectIndexBuffer(miterStroke); GrIndexBuffer* indexBuffer = this->aaStrokeRectIndexBuffer(miterStroke);
if (NULL == indexBuffer) { if (NULL == indexBuffer) {
SkDebugf("Failed to create index buffer!\n"); SkDebugf("Failed to create index buffer!\n");
return; return;
} }
AAStrokeRectBatch::Geometry geometry; intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices());
geometry.fColor = color;
geometry.fDevOutside = devOutside;
geometry.fDevOutsideAssist = devOutsideAssist;
geometry.fDevInside = devInside;
geometry.fMiterStroke = miterStroke;
SkAutoTUnref<GrBatch> batch(AAStrokeRectBatch::Create(geometry, viewMatrix, indexBuffer)); // We create vertices for four nested rectangles. There are two ramps from 0 to full
target->drawBatch(pipelineBuilder, batch); // 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
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);
}
// 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;
}
}
// 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;
}
float innerCoverage = GrNormalizeByteToFloat(scale);
GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, scale);
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 {
*reinterpret_cast<GrColor*>(verts + i * vstride) = scaledColor;
}
}
// 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 {
*reinterpret_cast<GrColor*>(verts + i * vstride) = 0;
}
}
target->setIndexSourceToBuffer(indexBuffer);
target->drawIndexedInstances(pipelineBuilder,
gp,
kTriangles_GrPrimitiveType,
1,
totalVertexNum,
aa_stroke_rect_index_count(miterStroke));
target->resetIndexSource();
} }
void GrAARectRenderer::fillAANestedRects(GrDrawTarget* target, void GrAARectRenderer::fillAANestedRects(GrDrawTarget* target,