Chromium Code Reviews| Index: src/gpu/GrClipMaskManager.cpp |
| diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp |
| index 83b3b01159b99fd61687f94114be9a0aaa09b447..ad277d79ff65687b4fa110d5c521a4c74dd57960 100644 |
| --- a/src/gpu/GrClipMaskManager.cpp |
| +++ b/src/gpu/GrClipMaskManager.cpp |
| @@ -94,13 +94,13 @@ bool GrClipMaskManager::useSWOnlyPath(const ElementList& elements) { |
| for (ElementList::Iter iter(elements.headIter()); iter.get(); iter.next()) { |
| const Element* element = iter.get(); |
| // rects can always be drawn directly w/o using the software path |
| - // so only paths need to be checked |
| - if (Element::kPath_Type == element->getType() && |
| - path_needs_SW_renderer(this->getContext(), fGpu, |
| - element->getPath(), |
| - stroke, |
| - element->isAA())) { |
| - return true; |
| + // Skip rrects once we're drawing them directly. |
| + if (Element::kRect_Type != element->getType()) { |
| + SkPath path; |
| + element->asPath(&path); |
| + if (path_needs_SW_renderer(this->getContext(), fGpu, path, stroke, element->isAA())) { |
| + return true; |
| + } |
| } |
| } |
| return false; |
| @@ -169,10 +169,11 @@ bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn, |
| return true; |
| } |
| } |
| + Element::Type type = elements.tail()->getType(); |
| + bool isAA = GR_AA_CLIP && elements.tail()->isAA(); |
| SkAutoTUnref<GrEffectRef> effect; |
| - if (SkClipStack::Element::kPath_Type == elements.tail()->getType()) { |
| + if (SkClipStack::Element::kPath_Type == type) { |
| const SkPath& path = elements.tail()->getPath(); |
| - bool isAA = GR_AA_CLIP && elements.tail()->isAA(); |
| if (rt->isMultisampled()) { |
| // A coverage effect for AA clipping won't play nicely with MSAA. |
| if (!isAA) { |
| @@ -188,13 +189,12 @@ bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn, |
| GrConvexPolyEffect::kFillNoAA_EdgeType; |
| effect.reset(GrConvexPolyEffect::Create(type, path, &offset)); |
| } |
| - } else if (GR_AA_CLIP && elements.tail()->isAA() && !rt->isMultisampled()) { |
| + } else if (isAA && SkClipStack::Element::kRect_Type == type && !rt->isMultisampled()) { |
| // We only handle AA/non-MSAA rects here. Coverage effect AA isn't MSAA friendly and |
| // non-AA rect clips are handled by the scissor. |
| - SkASSERT(SkClipStack::Element::kRect_Type == elements.tail()->getType()); |
| SkRect rect = elements.tail()->getRect(); |
| SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), |
| - SkIntToScalar(-clipDataIn->fOrigin.fY) }; |
| + SkIntToScalar(-clipDataIn->fOrigin.fY) }; |
| rect.offset(offset); |
| effect.reset(GrConvexPolyEffect::CreateForAAFillRect(rect)); |
| // This should never fail. |
| @@ -332,7 +332,11 @@ bool GrClipMaskManager::drawElement(GrTexture* target, |
| drawState->setRenderTarget(target->asRenderTarget()); |
| + // TODO: Draw rrects directly here. |
| switch (element->getType()) { |
| + case Element::kEmpty_Type: |
| + SkDEBUGFAIL("Should never get here with an empty element."); |
| + break; |
| case Element::kRect_Type: |
| // TODO: Do rects directly to the accumulator using a aa-rect GrEffect that covers the |
| // entire mask bounds and writes 0 outside the rect. |
| @@ -347,28 +351,25 @@ bool GrClipMaskManager::drawElement(GrTexture* target, |
| fGpu->drawSimpleRect(element->getRect(), NULL); |
| } |
| return true; |
| - case Element::kPath_Type: { |
| - SkTCopyOnFirstWrite<SkPath> path(element->getPath()); |
| - if (path->isInverseFillType()) { |
| - path.writable()->toggleInverseFillType(); |
| + default: { |
| + SkPath path; |
| + element->asPath(&path); |
| + if (path.isInverseFillType()) { |
| + path.toggleInverseFillType(); |
| } |
| SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); |
| if (NULL == pr) { |
| GrPathRendererChain::DrawType type; |
| type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_DrawType : |
| GrPathRendererChain::kColor_DrawType; |
| - pr = this->getContext()->getPathRenderer(*path, stroke, fGpu, false, type); |
| + pr = this->getContext()->getPathRenderer(path, stroke, fGpu, false, type); |
| } |
| if (NULL == pr) { |
| return false; |
| } |
| - pr->drawPath(element->getPath(), stroke, fGpu, element->isAA()); |
| + pr->drawPath(path, stroke, fGpu, element->isAA()); |
| break; |
| } |
| - default: |
| - // something is wrong if we're trying to draw an empty element. |
| - GrCrash("Unexpected element type"); |
| - return false; |
| } |
| return true; |
| } |
| @@ -700,18 +701,18 @@ bool GrClipMaskManager::createStencilClipMask(int32_t elementsGenID, |
| SkRegion::Op op = element->getOp(); |
| GrPathRenderer* pr = NULL; |
| - SkTCopyOnFirstWrite<SkPath> clipPath; |
| + SkPath clipPath; |
| if (Element::kRect_Type == element->getType()) { |
| stencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; |
| fillInverted = false; |
| } else { |
|
robertphillips
2014/02/14 20:36:01
Do we need path?
bsalomon
2014/02/14 21:20:57
Done.
|
| - SkASSERT(Element::kPath_Type == element->getType()); |
| - clipPath.init(element->getPath()); |
| - fillInverted = clipPath->isInverseFillType(); |
| + SkPath path; |
| + element->asPath(&clipPath); |
| + fillInverted = clipPath.isInverseFillType(); |
| if (fillInverted) { |
| - clipPath.writable()->toggleInverseFillType(); |
| + clipPath.toggleInverseFillType(); |
| } |
| - pr = this->getContext()->getPathRenderer(*clipPath, |
| + pr = this->getContext()->getPathRenderer(clipPath, |
| stroke, |
| fGpu, |
| false, |
| @@ -752,13 +753,12 @@ bool GrClipMaskManager::createStencilClipMask(int32_t elementsGenID, |
| *drawState->stencil() = gDrawToStencil; |
| fGpu->drawSimpleRect(element->getRect(), NULL); |
| } else { |
| - SkASSERT(Element::kPath_Type == element->getType()); |
| - if (!clipPath->isEmpty()) { |
| + if (!clipPath.isEmpty()) { |
| if (canRenderDirectToStencil) { |
| *drawState->stencil() = gDrawToStencil; |
| - pr->drawPath(*clipPath, stroke, fGpu, false); |
| + pr->drawPath(clipPath, stroke, fGpu, false); |
| } else { |
| - pr->stencilPath(*clipPath, stroke, fGpu); |
| + pr->stencilPath(clipPath, stroke, fGpu); |
| } |
| } |
| } |
| @@ -774,9 +774,8 @@ bool GrClipMaskManager::createStencilClipMask(int32_t elementsGenID, |
| SET_RANDOM_COLOR |
| fGpu->drawSimpleRect(element->getRect(), NULL); |
| } else { |
| - SkASSERT(Element::kPath_Type == element->getType()); |
| SET_RANDOM_COLOR |
| - pr->drawPath(*clipPath, stroke, fGpu, false); |
| + pr->drawPath(clipPath, stroke, fGpu, false); |
| } |
| } else { |
| SET_RANDOM_COLOR |