Revert of stop dropping AA when rect stays rect (patchset #8 id:140001 of https://codereview.chromium.org/1295523002/ )

Reason for revert:
breaks layout tests

Original issue's description:
> stop dropping AA when rect stays rect
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/1bef9f59c566cc54c2259cc4d0171c115157cd1c

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

Review URL: https://codereview.chromium.org/1295813005
This commit is contained in:
joshualitt 2015-08-14 11:36:03 -07:00 committed by Commit bot
parent f5fb939867
commit a83eeaddd3

View File

@ -204,6 +204,35 @@ void GrDrawContext::drawPaint(GrRenderTarget* rt,
} }
} }
static inline bool is_irect(const SkRect& r) {
return SkScalarIsInt(r.fLeft) && SkScalarIsInt(r.fTop) &&
SkScalarIsInt(r.fRight) && SkScalarIsInt(r.fBottom);
}
static bool apply_aa_to_rect(GrDrawTarget* target,
GrPipelineBuilder* pipelineBuilder,
SkRect* devBoundRect,
const SkRect& rect,
SkScalar strokeWidth,
const SkMatrix& combinedMatrix,
GrColor color) {
if (pipelineBuilder->getRenderTarget()->isUnifiedMultisampled() ||
!combinedMatrix.preservesAxisAlignment()) {
return false;
}
combinedMatrix.mapRect(devBoundRect, rect);
if (!combinedMatrix.rectStaysRect()) {
return true;
}
if (strokeWidth < 0) {
return !is_irect(*devBoundRect);
}
return true;
}
static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& point) { static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& point) {
return point.fX >= rect.fLeft && point.fX <= rect.fRight && return point.fX >= rect.fLeft && point.fX <= rect.fRight &&
point.fY >= rect.fTop && point.fY <= rect.fBottom; point.fY >= rect.fTop && point.fY <= rect.fBottom;
@ -268,18 +297,13 @@ void GrDrawContext::drawRect(GrRenderTarget* rt,
} }
GrColor color = paint.getColor(); GrColor color = paint.getColor();
SkRect devBoundRect;
bool needAA = paint.isAntiAlias() && bool needAA = paint.isAntiAlias() &&
!pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled();
bool doAA = needAA && apply_aa_to_rect(fDrawTarget, &pipelineBuilder, &devBoundRect, rect,
width, viewMatrix, color);
// The fill path can handle rotation but not skew if (doAA) {
// The stroke path needs the rect to remain axis aligned (no rotation or skew)
// None of our draw rect calls can handle perspective yet
SkASSERT(!viewMatrix.hasPerspective());
bool canApplyAA = width >=0 ? viewMatrix.rectStaysRect() : viewMatrix.preservesRightAngles();
if (needAA && canApplyAA) {
SkRect devBoundRect;
viewMatrix.mapRect(&devBoundRect, rect);
SkAutoTUnref<GrDrawBatch> batch; SkAutoTUnref<GrDrawBatch> batch;
if (width >= 0) { if (width >= 0) {
batch.reset(GrRectBatchFactory::CreateStrokeAA(color, viewMatrix, rect, devBoundRect, batch.reset(GrRectBatchFactory::CreateStrokeAA(color, viewMatrix, rect, devBoundRect,