From d09ab846789a33a969f9ea8428555270fe4de23e Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Wed, 15 May 2013 17:30:26 +0000 Subject: [PATCH] Don't make dst copies when color stage requires dst but color writes are disabled. R=robertphillips@google.com Review URL: https://codereview.chromium.org/15001035 git-svn-id: http://skia.googlecode.com/svn/trunk@9146 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/GrContext.cpp | 12 ++++++++---- src/gpu/GrDrawState.cpp | 10 ++++++++++ src/gpu/GrDrawState.h | 9 +-------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 068f32110e..64893b461a 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -973,12 +973,14 @@ void GrContext::drawRRect(const GrPaint& paint, GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW); GrDrawState::AutoStageDisable atr(fDrawState); - bool prAA = paint.isAntiAlias() && !this->getRenderTarget()->isMultisampled(); + bool useAA = paint.isAntiAlias() && + !this->getRenderTarget()->isMultisampled() && + !disable_coverage_aa_for_blend(target); - if (!fOvalRenderer->drawSimpleRRect(target, this, prAA, rect, stroke)) { + if (!fOvalRenderer->drawSimpleRRect(target, this, useAA, rect, stroke)) { SkPath path; path.addRRect(rect); - this->internalDrawPath(target, prAA, path, stroke); + this->internalDrawPath(target, useAA, path, stroke); } } @@ -991,7 +993,9 @@ void GrContext::drawOval(const GrPaint& paint, GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW); GrDrawState::AutoStageDisable atr(fDrawState); - bool useAA = paint.isAntiAlias() && !this->getRenderTarget()->isMultisampled(); + bool useAA = paint.isAntiAlias() && + !this->getRenderTarget()->isMultisampled() && + !disable_coverage_aa_for_blend(target); if (!fOvalRenderer->drawOval(target, this, useAA, oval, stroke)) { SkPath path; diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp index 90188ea788..591e157129 100644 --- a/src/gpu/GrDrawState.cpp +++ b/src/gpu/GrDrawState.cpp @@ -163,6 +163,16 @@ bool GrDrawState::validateVertexAttribs() const { return true; } +bool GrDrawState::willEffectReadDstColor() const { + int startStage = this->isColorWriteDisabled() ? this->getFirstCoverageStage() : 0; + for (int s = startStage; s < kNumStages; ++s) { + if (this->isStageEnabled(s) && (*this->getStage(s).getEffect())->willReadDstColor()) { + return true; + } + } + return false; +} + //////////////////////////////////////////////////////////////////////////////// bool GrDrawState::srcAlphaWillBeOne() const { diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h index 230b2faa47..80ad28eac5 100644 --- a/src/gpu/GrDrawState.h +++ b/src/gpu/GrDrawState.h @@ -451,14 +451,7 @@ public: /** * Checks whether any of the effects will read the dst pixel color. */ - bool willEffectReadDstColor() const { - for (int s = 0; s < kNumStages; ++s) { - if (this->isStageEnabled(s) && (*this->getStage(s).getEffect())->willReadDstColor()) { - return true; - } - } - return false; - } + bool willEffectReadDstColor() const; /// @}