diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-16 15:28:54 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-16 15:28:54 +0000 |
commit | e7249bd5cacf7fc5c0fd8c00ef656acea1e42ab4 (patch) | |
tree | 36dc4803bfdd5174c8b516fe634baef148df1384 /src/gpu | |
parent | 0d944821934145055f293fc717418d25208b9836 (diff) |
Fix overrun in aa rect renderer
Review URL: http://codereview.appspot.com/6446146/
git-svn-id: http://skia.googlecode.com/svn/trunk@5126 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrAARectRenderer.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp index 5e3a017773..652adcb47c 100644 --- a/src/gpu/GrAARectRenderer.cpp +++ b/src/gpu/GrAARectRenderer.cpp @@ -153,10 +153,10 @@ void GrAARectRenderer::fillAARect(GrGpu* gpu, } void GrAARectRenderer::strokeAARect(GrGpu* gpu, - GrDrawTarget* target, - const GrRect& devRect, - const GrVec& devStrokeSize, - bool useVertexCoverage) { + GrDrawTarget* target, + const GrRect& devRect, + const GrVec& devStrokeSize, + bool useVertexCoverage) { const GrScalar& dx = devStrokeSize.fX; const GrScalar& dy = devStrokeSize.fY; const GrScalar rx = GrMul(dx, GR_ScalarHalf); @@ -191,6 +191,9 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu, 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. GrPoint* fan0Pos = reinterpret_cast<GrPoint*>(verts); GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize); GrPoint* fan2Pos = reinterpret_cast<GrPoint*>(verts + 8 * vsize); @@ -205,11 +208,13 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu, setInsetFan(fan3Pos, vsize, devRect, rx + GR_ScalarHalf, ry + GR_ScalarHalf); + // The outermost rect has 0 coverage verts += sizeof(GrPoint); for (int i = 0; i < 4; ++i) { *reinterpret_cast<GrColor*>(verts + i * vsize) = 0; } + // The inner two rects have full coverage GrColor innerColor; if (useVertexCoverage) { innerColor = 0xffffffff; @@ -221,8 +226,9 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu, *reinterpret_cast<GrColor*>(verts + i * vsize) = innerColor; } + // The innermost rect has full coverage verts += 8 * vsize; - for (int i = 0; i < 8; ++i) { + for (int i = 0; i < 4; ++i) { *reinterpret_cast<GrColor*>(verts + i * vsize) = 0; } |