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
diff --git a/include/gpu/GrAARectRenderer.h b/include/gpu/GrAARectRenderer.h
index 0dd538e..549c2ca 100644
--- a/include/gpu/GrAARectRenderer.h
+++ b/include/gpu/GrAARectRenderer.h
@@ -42,6 +42,7 @@
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 @@
#else
this->geometryFillAARect(gpu, target,
rect, combinedMatrix,
- useVertexCoverage);
+ devRect, useVertexCoverage);
#endif
}
@@ -62,6 +63,7 @@
GrDrawTarget* target,
const GrRect& rect,
const SkMatrix& combinedMatrix,
+ const GrRect& devRect,
const GrVec& devStrokeSize,
bool useVertexCoverage);
@@ -80,6 +82,7 @@
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 f9ed13f..c1870dd 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -364,6 +364,7 @@
GrDrawTarget* target,
const GrRect& rect,
const SkMatrix& combinedMatrix,
+ const GrRect& devRect,
bool useVertexCoverage) {
GrDrawState* drawState = target->drawState();
@@ -389,8 +390,13 @@
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 @@
GrDrawTarget* target,
const GrRect& rect,
const SkMatrix& combinedMatrix,
+ const GrRect& devRect,
const GrVec& devStrokeSize,
bool useVertexCoverage) {
GrDrawState* drawState = target->drawState();
@@ -637,8 +644,13 @@
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 @@
}
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 164e1f8..c022b34d 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -282,6 +282,7 @@
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 a865d81..6b98d13 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -680,11 +680,17 @@
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 @@
#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 @@
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 @@
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;