From 3ab14ca950d98a5c4d4c4a5f96ea8b0c984e0116 Mon Sep 17 00:00:00 2001 From: robertphillips Date: Sun, 10 Jul 2016 11:49:39 -0700 Subject: [PATCH] Fix misplaced guard This fixes an error in https://codereview.chromium.org/2125333002 (Add choke point for modifying non-AA rect draws (e.g., applying clipping)). In GrDrawContext::drawRect, when we need to draw a filled rect, we always want to call drawFilledRect when useDrawInsteadOfClear is false. With the buggy code I believe we were falling back to drawing a path. TBR=bsalomon@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2135883002 Review-Url: https://codereview.chromium.org/2135883002 --- src/gpu/GrDrawContext.cpp | 48 ++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp index aa7057510c..a86e01e72b 100644 --- a/src/gpu/GrDrawContext.cpp +++ b/src/gpu/GrDrawContext.cpp @@ -337,31 +337,33 @@ void GrDrawContext::drawRect(const GrClip& clip, AutoCheckFlush acf(fDrawingManager); const SkStrokeRec& stroke = style->strokeRec(); - if (stroke.getStyle() == SkStrokeRec::kFill_Style && - !fContext->caps()->useDrawInsteadOfClear()) { - // Check if this is a full RT draw and can be replaced with a clear. We don't bother - // checking cases where the RT is fully inside a stroke. - SkRect rtRect; - fRenderTarget->getBoundsRect(&rtRect); - // Does the clip contain the entire RT? - if (clip.quickContains(rtRect)) { - SkMatrix invM; - if (!viewMatrix.invert(&invM)) { - return; - } - // Does the rect bound the RT? - SkPoint srcSpaceRTQuad[4]; - invM.mapRectToQuad(srcSpaceRTQuad, rtRect); - if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && - rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && - rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && - rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { - // Will it blend? - GrColor clearColor; - if (paint.isConstantBlendedColor(&clearColor)) { - this->getDrawTarget()->clear(nullptr, clearColor, true, this); + if (stroke.getStyle() == SkStrokeRec::kFill_Style) { + + if (!fContext->caps()->useDrawInsteadOfClear()) { + // Check if this is a full RT draw and can be replaced with a clear. We don't bother + // checking cases where the RT is fully inside a stroke. + SkRect rtRect; + fRenderTarget->getBoundsRect(&rtRect); + // Does the clip contain the entire RT? + if (clip.quickContains(rtRect)) { + SkMatrix invM; + if (!viewMatrix.invert(&invM)) { return; } + // Does the rect bound the RT? + SkPoint srcSpaceRTQuad[4]; + invM.mapRectToQuad(srcSpaceRTQuad, rtRect); + if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && + rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && + rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && + rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { + // Will it blend? + GrColor clearColor; + if (paint.isConstantBlendedColor(&clearColor)) { + this->getDrawTarget()->clear(nullptr, clearColor, true, this); + return; + } + } } }