diff options
author | joshualitt <joshualitt@chromium.org> | 2015-08-19 11:50:51 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-19 11:50:51 -0700 |
commit | 9be0b002caaf4f44e04873351f957c3e97922457 (patch) | |
tree | a17d8fa592b0e0920207aa8c68561529a416df7d /src/gpu/GrDrawContext.cpp | |
parent | f5822825ec2d5dd24ab476fdd42db2a6573f9756 (diff) |
stop dropping AA when rect stays rect
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/1bef9f59c566cc54c2259cc4d0171c115157cd1c
Review URL: https://codereview.chromium.org/1295523002
Diffstat (limited to 'src/gpu/GrDrawContext.cpp')
-rw-r--r-- | src/gpu/GrDrawContext.cpp | 42 |
1 files changed, 9 insertions, 33 deletions
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp index 3033611146..8b95647631 100644 --- a/src/gpu/GrDrawContext.cpp +++ b/src/gpu/GrDrawContext.cpp @@ -204,35 +204,6 @@ 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) { return point.fX >= rect.fLeft && point.fX <= rect.fRight && point.fY >= rect.fTop && point.fY <= rect.fBottom; @@ -297,13 +268,18 @@ void GrDrawContext::drawRect(GrRenderTarget* rt, } GrColor color = paint.getColor(); - SkRect devBoundRect; bool needAA = paint.isAntiAlias() && !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); - bool doAA = needAA && apply_aa_to_rect(fDrawTarget, &pipelineBuilder, &devBoundRect, rect, - width, viewMatrix, color); - if (doAA) { + // The fill path can handle rotation but not skew + // 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; if (width >= 0) { batch.reset(GrRectBatchFactory::CreateStrokeAA(color, viewMatrix, rect, devBoundRect, |