Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: src/gpu/GrClipMaskManager.cpp

Issue 163683002: Store SkRRects in SkClipStack (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix unhandled enum value warning in unit test Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkClipStack.cpp ('k') | src/gpu/GrReducedClip.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrClipMaskManager.cpp
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 83b3b01159b99fd61687f94114be9a0aaa09b447..8a7aac247aaaf8ea45ff892c6391eac97d7406a8 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;
}
@@ -379,25 +380,22 @@ bool GrClipMaskManager::canStencilAndDrawElement(GrTexture* target,
GrDrawState* drawState = fGpu->drawState();
drawState->setRenderTarget(target->asRenderTarget());
- switch (element->getType()) {
- case Element::kRect_Type:
- return true;
- case Element::kPath_Type: {
- SkTCopyOnFirstWrite<SkPath> path(element->getPath());
- if (path->isInverseFillType()) {
- path.writable()->toggleInverseFillType();
- }
- SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
- GrPathRendererChain::DrawType type = element->isAA() ?
- GrPathRendererChain::kStencilAndColorAntiAlias_DrawType :
- GrPathRendererChain::kStencilAndColor_DrawType;
- *pr = this->getContext()->getPathRenderer(*path, stroke, fGpu, false, type);
- return NULL != *pr;
+ if (Element::kRect_Type == element->getType()) {
+ return true;
+ } else {
+ // We shouldn't get here with an empty clip element.
+ SkASSERT(Element::kEmpty_Type != element->getType());
+ SkPath path;
+ element->asPath(&path);
+ if (path.isInverseFillType()) {
+ path.toggleInverseFillType();
}
- default:
- // something is wrong if we're trying to draw an empty element.
- GrCrash("Unexpected element type");
- return false;
+ SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
+ GrPathRendererChain::DrawType type = element->isAA() ?
+ GrPathRendererChain::kStencilAndColorAntiAlias_DrawType :
+ GrPathRendererChain::kStencilAndColor_DrawType;
+ *pr = this->getContext()->getPathRenderer(path, stroke, fGpu, false, type);
+ return NULL != *pr;
}
}
@@ -700,18 +698,17 @@ 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 {
- SkASSERT(Element::kPath_Type == element->getType());
- clipPath.init(element->getPath());
- fillInverted = clipPath->isInverseFillType();
+ 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 +749,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 +770,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
« no previous file with comments | « src/core/SkClipStack.cpp ('k') | src/gpu/GrReducedClip.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698