diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-14 19:47:47 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-14 19:47:47 +0000 |
commit | afd1cba5237eba5394ee011106eede9f6c8074c8 (patch) | |
tree | ae3476c89ddbefbba945d7c84b4033ec842400c4 | |
parent | 26515baa9088db6076ede090d88904774713f855 (diff) |
Re-add isIRect test for AA rect drawing
https://codereview.chromium.org/14820035/
git-svn-id: http://skia.googlecode.com/svn/trunk@9128 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/gpu/GrAARectRenderer.h | 5 | ||||
-rw-r--r-- | src/gpu/GrAARectRenderer.cpp | 17 | ||||
-rw-r--r-- | src/gpu/GrClipMaskManager.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 23 |
4 files changed, 36 insertions, 10 deletions
diff --git a/include/gpu/GrAARectRenderer.h b/include/gpu/GrAARectRenderer.h index 0dd538e3ca..549c2ca96e 100644 --- a/include/gpu/GrAARectRenderer.h +++ b/include/gpu/GrAARectRenderer.h @@ -42,6 +42,7 @@ public: GrDrawTarget* target, const GrRect& rect, const SkMatrix& combinedMatrix, + const GrRect& devRect, bool useVertexCoverage) { #ifdef SHADER_AA_FILL_RECT if (combinedMatrix.rectStaysRect()) { @@ -54,7 +55,7 @@ public: #else this->geometryFillAARect(gpu, target, rect, combinedMatrix, - useVertexCoverage); + devRect, useVertexCoverage); #endif } @@ -62,6 +63,7 @@ public: GrDrawTarget* target, const GrRect& rect, const SkMatrix& combinedMatrix, + const GrRect& devRect, const GrVec& devStrokeSize, bool useVertexCoverage); @@ -80,6 +82,7 @@ private: GrDrawTarget* target, const GrRect& rect, const SkMatrix& combinedMatrix, + const GrRect& devRect, bool useVertexCoverage); void shaderFillAARect(GrGpu* gpu, diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp index f9ed13f872..c1870dd46b 100644 --- a/src/gpu/GrAARectRenderer.cpp +++ b/src/gpu/GrAARectRenderer.cpp @@ -364,6 +364,7 @@ void GrAARectRenderer::geometryFillAARect(GrGpu* gpu, GrDrawTarget* target, const GrRect& rect, const SkMatrix& combinedMatrix, + const GrRect& devRect, bool useVertexCoverage) { GrDrawState* drawState = target->drawState(); @@ -389,8 +390,13 @@ void GrAARectRenderer::geometryFillAARect(GrGpu* gpu, GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize); if (combinedMatrix.rectStaysRect()) { + // Temporarily #if'ed out. We don't want to pass in the devRect but + // right now it is computed in GrContext::apply_aa_to_rect and we don't + // want to throw away the work +#if 0 SkRect devRect; combinedMatrix.mapRect(&devRect, rect); +#endif set_inset_fan(fan0Pos, vsize, devRect, -SK_ScalarHalf, -SK_ScalarHalf); set_inset_fan(fan1Pos, vsize, devRect, SK_ScalarHalf, SK_ScalarHalf); @@ -628,6 +634,7 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu, GrDrawTarget* target, const GrRect& rect, const SkMatrix& combinedMatrix, + const GrRect& devRect, const GrVec& devStrokeSize, bool useVertexCoverage) { GrDrawState* drawState = target->drawState(); @@ -637,8 +644,13 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu, const SkScalar rx = SkScalarMul(dx, SK_ScalarHalf); const SkScalar ry = SkScalarMul(dy, SK_ScalarHalf); + // Temporarily #if'ed out. We don't want to pass in the devRect but + // right now it is computed in GrContext::apply_aa_to_rect and we don't + // want to throw away the work +#if 0 SkRect devRect; combinedMatrix.mapRect(&devRect, rect); +#endif SkScalar spare; { @@ -648,8 +660,9 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu, } if (spare <= 0) { - devRect.inset(-rx, -ry); - this->fillAARect(gpu, target, devRect, SkMatrix::I(), useVertexCoverage); + GrRect r(devRect); + r.outset(rx, ry); + this->fillAARect(gpu, target, r, SkMatrix::I(), r, useVertexCoverage); return; } diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp index 164e1f8687..c022b34d62 100644 --- a/src/gpu/GrClipMaskManager.cpp +++ b/src/gpu/GrClipMaskManager.cpp @@ -282,6 +282,7 @@ bool GrClipMaskManager::drawElement(GrTexture* target, fGpu, element->getRect(), SkMatrix::I(), + element->getRect(), false); } else { fGpu->drawSimpleRect(element->getRect(), NULL); diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index a865d81729..6b98d13028 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -680,11 +680,17 @@ static void setStrokeRectStrip(GrPoint verts[10], GrRect rect, verts[9] = verts[1]; } +static bool isIRect(const GrRect& r) { + return SkScalarIsInt(r.fLeft) && SkScalarIsInt(r.fTop) && + SkScalarIsInt(r.fRight) && SkScalarIsInt(r.fBottom); +} + static bool apply_aa_to_rect(GrDrawTarget* target, const GrRect& rect, SkScalar strokeWidth, const SkMatrix* matrix, SkMatrix* combinedMatrix, + GrRect* devRect, bool* useVertexCoverage) { // we use a simple coverage ramp to do aa on axis-aligned rects // we check if the rect will be axis-aligned, and the rect won't land on @@ -754,11 +760,13 @@ static bool apply_aa_to_rect(GrDrawTarget* target, #endif } - if (0 == rect.width() || 0 == rect.height()) { - return false; - } + combinedMatrix->mapRect(devRect, rect); - return true; + if (strokeWidth < 0) { + return !isIRect(*devRect); + } else { + return true; + } } void GrContext::drawRect(const GrPaint& paint, @@ -770,12 +778,13 @@ void GrContext::drawRect(const GrPaint& paint, GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW); GrDrawState::AutoStageDisable atr(fDrawState); + GrRect devRect; SkMatrix combinedMatrix; bool useVertexCoverage; bool needAA = paint.isAntiAlias() && !this->getRenderTarget()->isMultisampled(); bool doAA = needAA && apply_aa_to_rect(target, rect, width, matrix, - &combinedMatrix, + &combinedMatrix, &devRect, &useVertexCoverage); if (doAA) { GrDrawState::AutoDeviceCoordDraw adcd(target->drawState()); @@ -792,12 +801,12 @@ void GrContext::drawRect(const GrPaint& paint, strokeSize.set(SK_Scalar1, SK_Scalar1); } fAARectRenderer->strokeAARect(this->getGpu(), target, - rect, combinedMatrix, + rect, combinedMatrix, devRect, strokeSize, useVertexCoverage); } else { // filled AA rect fAARectRenderer->fillAARect(this->getGpu(), target, - rect, combinedMatrix, + rect, combinedMatrix, devRect, useVertexCoverage); } return; |