GPU "fix" for thin stroked rects

https://codereview.chromium.org/17845003/



git-svn-id: http://skia.googlecode.com/svn/trunk@9812 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
robertphillips@google.com 2013-06-28 17:57:06 +00:00
parent 5330e44796
commit 353f0971d8

View File

@ -470,13 +470,9 @@ void GrAARectRenderer::geometryFillAARect(GrGpu* gpu,
GrColor innerColor;
if (useVertexCoverage) {
innerColor = scale | (scale << 8) | (scale << 16) | (scale << 24);
innerColor = GrColorPackRGBA(scale, scale, scale, scale);
} else {
if (0xff == scale) {
innerColor = target->getDrawState().getColor();
} else {
innerColor = SkAlphaMulQ(target->getDrawState().getColor(), scale);
}
innerColor = SkAlphaMulQ(target->getDrawState().getColor(), scale);
}
verts += 4 * vsize;
@ -728,10 +724,19 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
GrPoint* fan2Pos = reinterpret_cast<GrPoint*>(verts + 8 * vsize);
GrPoint* fan3Pos = reinterpret_cast<GrPoint*>(verts + 12 * vsize);
// TODO: this only really works if the X & Y margins are the same all around
// the rect
SkScalar inset = SkMinScalar(SK_Scalar1, devOutside.fRight - devInside.fRight);
inset = SkMinScalar(inset, devInside.fLeft - devOutside.fLeft);
inset = SkMinScalar(inset, devInside.fTop - devOutside.fTop);
inset = SK_ScalarHalf * SkMinScalar(inset, devOutside.fBottom - devInside.fBottom);
SkASSERT(inset >= 0);
// outermost
set_inset_fan(fan0Pos, vsize, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
set_inset_fan(fan1Pos, vsize, devOutside, SK_ScalarHalf, SK_ScalarHalf);
set_inset_fan(fan2Pos, vsize, devInside, -SK_ScalarHalf, -SK_ScalarHalf);
// inner two
set_inset_fan(fan1Pos, vsize, devOutside, inset, inset);
set_inset_fan(fan2Pos, vsize, devInside, -inset, -inset);
// innermost
set_inset_fan(fan3Pos, vsize, devInside, SK_ScalarHalf, SK_ScalarHalf);
@ -741,13 +746,22 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
*reinterpret_cast<GrColor*>(verts + i * vsize) = 0;
}
int scale;
if (inset < SK_ScalarHalf) {
scale = SkScalarFloorToInt(512.0f * inset / (inset + SK_ScalarHalf));
SkASSERT(scale >= 0 && scale <= 255);
} else {
scale = 0xff;
}
// The inner two rects have full coverage
GrColor innerColor;
if (useVertexCoverage) {
innerColor = 0xffffffff;
innerColor = GrColorPackRGBA(scale, scale, scale, scale);
} else {
innerColor = target->getDrawState().getColor();
innerColor = SkAlphaMulQ(target->getDrawState().getColor(), scale);
}
verts += 4 * vsize;
for (int i = 0; i < 8; ++i) {
*reinterpret_cast<GrColor*>(verts + i * vsize) = innerColor;