Chromium Code Reviews| Index: src/gpu/GrDrawContext.cpp |
| diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp |
| index ec26672b37286b5589214ea248bff558a65440c7..10c7cad7cf4dbec299b68f2c9503846d752d704a 100644 |
| --- a/src/gpu/GrDrawContext.cpp |
| +++ b/src/gpu/GrDrawContext.cpp |
| @@ -225,6 +225,14 @@ static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po |
| point.fY >= rect.fTop && point.fY <= rect.fBottom; |
| } |
| +static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { |
| + return viewMatrix.preservesRightAngles(); |
| +} |
| + |
| +static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt) { |
| + return paint.isAntiAlias() && !rt->isUnifiedMultisampled(); |
| +} |
| + |
| void GrDrawContext::drawRect(const GrClip& clip, |
| const GrPaint& paint, |
| const SkMatrix& viewMatrix, |
| @@ -282,13 +290,13 @@ void GrDrawContext::drawRect(const GrClip& clip, |
| } |
| GrColor color = paint.getColor(); |
| - bool needAA = paint.isAntiAlias() && |
| - !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); |
| + bool needAA = should_apply_coverage_aa(paint, pipelineBuilder.getRenderTarget()); |
| // 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 AA draw rect calls can handle perspective yet |
| - bool canApplyAA = width >=0 ? viewMatrix.rectStaysRect() : viewMatrix.preservesRightAngles(); |
| + bool canApplyAA = width >=0 ? viewMatrix.rectStaysRect() : |
|
joshualitt
2015/11/05 19:53:12
view_matrix_ok_for_aa_stroke_rect? Though I guess
bsalomon
2015/11/05 20:10:37
I only pulled the other one out in order to share
|
| + view_matrix_ok_for_aa_fill_rect(viewMatrix); |
| if (needAA && canApplyAA) { |
| SkASSERT(!viewMatrix.hasPerspective()); |
| @@ -333,11 +341,21 @@ void GrDrawContext::fillRectToRect(const GrClip& clip, |
| AutoCheckFlush acf(fDrawingManager); |
| GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); |
| - this->getDrawTarget()->drawNonAARect(pipelineBuilder, |
| - paint.getColor(), |
| - viewMatrix, |
| - rectToDraw, |
| - localRect); |
| + if (should_apply_coverage_aa(paint, fRenderTarget) && |
| + view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
|
robertphillips
2015/11/05 20:13:24
SkAutoTUnref<GrDrawBatch> batch( ...
?
bsalomon
2015/11/06 15:24:25
I relent
|
| + GrDrawBatch* batch = GrAAFillRectBatch::CreateWithLocalRect( |
|
joshualitt
2015/11/05 19:53:12
Is there a reason not to use SkAutoTUnref here?
bsalomon
2015/11/05 20:10:37
I already had to branch on nullptr
|
| + paint.getColor(), viewMatrix, rectToDraw, localRect); |
| + if (batch) { |
| + this->drawBatch(&pipelineBuilder, batch); |
| + batch->unref(); |
| + } |
| + } else { |
| + this->getDrawTarget()->drawNonAARect(pipelineBuilder, |
| + paint.getColor(), |
|
joshualitt
2015/11/05 19:53:12
extra spaces
bsalomon
2015/11/05 20:10:37
will fix
bsalomon
2015/11/06 15:24:25
Done.
|
| + viewMatrix, |
| + rectToDraw, |
| + localRect); |
| + } |
| } |
| void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, |
| @@ -351,11 +369,18 @@ void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, |
| AutoCheckFlush acf(fDrawingManager); |
| GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); |
| - this->getDrawTarget()->drawNonAARect(pipelineBuilder, |
| - paint.getColor(), |
| - viewMatrix, |
| - rectToDraw, |
| - localMatrix); |
| + if (should_apply_coverage_aa(paint, pipelineBuilder.getRenderTarget()) && |
| + view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
| + SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create( |
| + paint.getColor(), viewMatrix, localMatrix, rectToDraw)); |
| + this->drawBatch(&pipelineBuilder, batch); |
|
joshualitt
2015/11/05 19:53:12
Its outside the scope of this CL but it'd be nice
bsalomon
2015/11/05 20:10:37
You mean not have GrDrawContext create GrBatches a
|
| + } else { |
| + this->getDrawTarget()->drawNonAARect(pipelineBuilder, |
| + paint.getColor(), |
| + viewMatrix, |
| + rectToDraw, |
| + localMatrix); |
| + } |
| } |
| void GrDrawContext::drawVertices(const GrClip& clip, |
| @@ -632,8 +657,7 @@ void GrDrawContext::drawPath(const GrClip& clip, |
| GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); |
| if (!strokeInfo.isDashed()) { |
| - bool useCoverageAA = paint.isAntiAlias() && |
| - !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); |
| + bool useCoverageAA = should_apply_coverage_aa(paint, pipelineBuilder.getRenderTarget()); |
| if (useCoverageAA && strokeInfo.getWidth() < 0 && !path.isConvex()) { |
| // Concave AA paths are expensive - try to avoid them for special cases |