aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-06-03 06:34:58 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-03 06:34:59 -0700
commit8af0523b38f25993c8b1ba3a3562b9f9ac87162d (patch)
tree8a07e2b1acc809b1ec313e5de738c7f169e1bf4e
parent5fb3392c3ea4eace911f9153eabc34bfba3463f4 (diff)
Fall back to using clip effect for outer rect in drawdrrect
R=jvanverth@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/310483010
-rw-r--r--expectations/gm/ignored-tests.txt4
-rw-r--r--src/gpu/GrDrawState.h2
-rw-r--r--src/gpu/GrOvalRenderer.cpp40
3 files changed, 41 insertions, 5 deletions
diff --git a/expectations/gm/ignored-tests.txt b/expectations/gm/ignored-tests.txt
index 2c1cd1ac95..e107d5ef9a 100644
--- a/expectations/gm/ignored-tests.txt
+++ b/expectations/gm/ignored-tests.txt
@@ -49,6 +49,10 @@ downsamplebitmap_image_high_mandrill_512.png
filterbitmap_checkerboard_192_192
downsamplebitmap_text_high_72.00pt
+# bsalomon: Slight anti-aliasing changes in gpu version of this test
+# https://codereview.chromium.org/306063002/
+drrect
+
# These are part of picture-version 27 -- removal of SkUnitMapp
# just need to be rebaselined
scaled_tilemode_bitmap
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 78739ec680..6cefd97761 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -411,6 +411,8 @@ public:
}
}
+ bool isSet() const { return NULL != fDrawState; }
+
private:
GrDrawState* fDrawState;
int fColorEffectCnt;
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 45564bcce0..8a76646b5b 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -884,7 +884,10 @@ GrIndexBuffer* GrOvalRenderer::rRectIndexBuffer(GrGpu* gpu) {
}
bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, GrContext* context, bool useAA,
- const SkRRect& outer, const SkRRect& origInner) {
+ const SkRRect& origOuter, const SkRRect& origInner) {
+ bool applyAA = useAA &&
+ !target->getDrawState().getRenderTarget()->isMultisampled() &&
+ !target->shouldDisableCoverageAAForBlend();
GrDrawState::AutoRestoreEffects are;
if (!origInner.isEmpty()) {
SkTCopyOnFirstWrite<SkRRect> inner(origInner);
@@ -893,9 +896,6 @@ bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, GrContext* context, bool u
return false;
}
}
- bool applyAA = useAA &&
- !target->getDrawState().getRenderTarget()->isMultisampled() &&
- !target->shouldDisableCoverageAAForBlend();
GrEffectEdgeType edgeType = applyAA ? kInverseFillAA_GrEffectEdgeType :
kInverseFillBW_GrEffectEdgeType;
GrEffectRef* effect = GrRRectEffect::Create(edgeType, *inner);
@@ -907,7 +907,37 @@ bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, GrContext* context, bool u
}
SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle);
- return this->drawRRect(target, context, useAA, outer, fillRec);
+ if (this->drawRRect(target, context, useAA, origOuter, fillRec)) {
+ return true;
+ }
+
+ SkASSERT(!origOuter.isEmpty());
+ SkTCopyOnFirstWrite<SkRRect> outer(origOuter);
+ if (!context->getMatrix().isIdentity()) {
+ if (!origOuter.transform(context->getMatrix(), outer.writable())) {
+ return false;
+ }
+ }
+ GrEffectEdgeType edgeType = applyAA ? kFillAA_GrEffectEdgeType :
+ kFillBW_GrEffectEdgeType;
+ GrEffectRef* effect = GrRRectEffect::Create(edgeType, *outer);
+ if (NULL == effect) {
+ return false;
+ }
+ if (!are.isSet()) {
+ are.set(target->drawState());
+ }
+ GrDrawState::AutoViewMatrixRestore avmr;
+ if (!avmr.setIdentity(target->drawState())) {
+ return false;
+ }
+ target->drawState()->addCoverageEffect(effect)->unref();
+ SkRect bounds = outer->getBounds();
+ if (applyAA) {
+ bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
+ }
+ target->drawRect(bounds, NULL, NULL, NULL);
+ return true;
}
bool GrOvalRenderer::drawRRect(GrDrawTarget* target, GrContext* context, bool useAA,