| Index: src/gpu/GrClipMaskManager.cpp
|
| ===================================================================
|
| --- src/gpu/GrClipMaskManager.cpp (revision 11314)
|
| +++ src/gpu/GrClipMaskManager.cpp (working copy)
|
| @@ -29,12 +29,11 @@
|
| using namespace GrReducedClip;
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -namespace {
|
| // set up the draw state to enable the aa clipping mask. Besides setting up the
|
| // stage matrix this also alters the vertex layout
|
| -void setup_drawstate_aaclip(GrGpu* gpu,
|
| - GrTexture* result,
|
| - const SkIRect &devBound) {
|
| +static void setup_drawstate_aaclip(GrGpu* gpu,
|
| + GrTexture* result,
|
| + const SkIRect &devBound) {
|
| GrDrawState* drawState = gpu->drawState();
|
| SkASSERT(drawState);
|
|
|
| @@ -58,26 +57,21 @@
|
| GrEffect::kPosition_CoordsType))->unref();
|
| }
|
|
|
| -bool path_needs_SW_renderer(GrContext* context,
|
| - GrGpu* gpu,
|
| - const SkPath& origPath,
|
| - const SkStrokeRec& stroke,
|
| - bool doAA) {
|
| - // the gpu alpha mask will draw the inverse paths as non-inverse to a temp buffer
|
| - SkTCopyOnFirstWrite<SkPath> path(origPath);
|
| - if (path->isInverseFillType()) {
|
| - path.writable()->toggleInverseFillType();
|
| - }
|
| - // last (false) parameter disallows use of the SW path renderer
|
| +static bool path_needs_SW_renderer(GrContext* context,
|
| + GrGpu* gpu,
|
| + const SkPath& origPath,
|
| + const SkStrokeRec& stroke,
|
| + bool doAA) {
|
| GrPathRendererChain::DrawType type = doAA ?
|
| GrPathRendererChain::kColorAntiAlias_DrawType :
|
| GrPathRendererChain::kColor_DrawType;
|
| + // the gpu alpha mask will draw the inverse paths as non-inverse to a temp buffer
|
| + SkPath::FillType fillType = SkPath::ConvertToNonInverseFillType(origPath.getFillType());
|
|
|
| - return NULL == context->getPathRenderer(*path, stroke, gpu, false, type);
|
| + // the 'false' parameter disallows use of the SW path renderer
|
| + return NULL == context->getPathRenderer(origPath, stroke, gpu, false, type, fillType);
|
| }
|
|
|
| -}
|
| -
|
| /*
|
| * This method traverses the clip stack to see if the GrSoftwarePathRenderer
|
| * will be used on any element. If so, it returns true to indicate that the
|
| @@ -267,9 +261,20 @@
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| +bool GrClipMaskManager::drawFilledPath(GrTexture* target,
|
| + GrPathRenderer* pathRenderer,
|
| + bool isAA) {
|
| + GrDrawState* drawState = fGpu->drawState();
|
| +
|
| + drawState->setRenderTarget(target->asRenderTarget());
|
| +
|
| + SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
|
| + pathRenderer->drawPath(stroke, fGpu, isAA);
|
| + return true;
|
| +}
|
| +
|
| bool GrClipMaskManager::drawElement(GrTexture* target,
|
| - const SkClipStack::Element* element,
|
| - GrPathRenderer* pr) {
|
| + const SkClipStack::Element* element) {
|
| GrDrawState* drawState = fGpu->drawState();
|
|
|
| drawState->setRenderTarget(target->asRenderTarget());
|
| @@ -290,21 +295,19 @@
|
| }
|
| 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;
|
| + type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_DrawType :
|
| + GrPathRendererChain::kColor_DrawType;
|
| + SkPath::FillType fillType = element->getPath().getFillType();
|
| + GrPathRenderer* pr = this->getContext()->getPathRenderer(
|
| + element->getPath(),
|
| + stroke, fGpu, false, type,
|
| + SkPath::ConvertToNonInverseFillType(fillType));
|
| if (NULL == pr) {
|
| - GrPathRendererChain::DrawType type;
|
| - type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_DrawType :
|
| - GrPathRendererChain::kColor_DrawType;
|
| - pr = this->getContext()->getPathRenderer(*path, stroke, fGpu, false, type);
|
| - }
|
| - if (NULL == pr) {
|
| return false;
|
| }
|
| - pr->drawPath(element->getPath(), stroke, fGpu, element->isAA());
|
| + pr->drawPath(stroke, fGpu, element->isAA());
|
| break;
|
| }
|
| default:
|
| @@ -325,15 +328,14 @@
|
| 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);
|
| + SkPath::FillType fillType = element->getPath().getFillType();
|
| + *pr = this->getContext()->getPathRenderer(element->getPath(),
|
| + stroke, fGpu, false, type,
|
| + SkPath::ConvertToNonInverseFillType(fillType));
|
| return NULL != *pr;
|
| }
|
| default:
|
| @@ -524,9 +526,13 @@
|
|
|
| drawState->setAlpha(invert ? 0x00 : 0xff);
|
|
|
| - if (!this->drawElement(dst, element, pr)) {
|
| - fAACache.reset();
|
| - return NULL;
|
| + if (NULL != pr) {
|
| + this->drawFilledPath(dst, pr, element->isAA());
|
| + } else {
|
| + if (!this->drawElement(dst, element)) {
|
| + fAACache.reset();
|
| + return NULL;
|
| + }
|
| }
|
|
|
| if (useTemp) {
|
| @@ -552,7 +558,7 @@
|
| drawState->disableStencil();
|
| }
|
| } else {
|
| - // all the remaining ops can just be directly draw into the accumulation buffer
|
| + // all the remaining ops can just be directly drawn into the accumulation buffer
|
| drawState->setAlpha(0xff);
|
| setup_boolean_blendcoeffs(drawState, op);
|
| this->drawElement(result, element);
|
| @@ -639,22 +645,19 @@
|
| SkRegion::Op op = element->getOp();
|
|
|
| GrPathRenderer* pr = NULL;
|
| - SkTCopyOnFirstWrite<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();
|
| - if (fillInverted) {
|
| - clipPath.writable()->toggleInverseFillType();
|
| - }
|
| - pr = this->getContext()->getPathRenderer(*clipPath,
|
| + fillInverted = element->getPath().isInverseFillType();
|
| + SkPath::FillType fill = element->getPath().getFillType();
|
| + pr = this->getContext()->getPathRenderer(element->getPath(),
|
| stroke,
|
| fGpu,
|
| false,
|
| GrPathRendererChain::kStencilOnly_DrawType,
|
| + SkPath::ConvertToNonInverseFillType(fill),
|
| &stencilSupport);
|
| if (NULL == pr) {
|
| return false;
|
| @@ -692,12 +695,12 @@
|
| fGpu->drawSimpleRect(element->getRect(), NULL);
|
| } else {
|
| SkASSERT(Element::kPath_Type == element->getType());
|
| - if (!clipPath->isEmpty()) {
|
| + if (NULL != pr) {
|
| if (canRenderDirectToStencil) {
|
| *drawState->stencil() = gDrawToStencil;
|
| - pr->drawPath(*clipPath, stroke, fGpu, false);
|
| + pr->drawPath(stroke, fGpu, false);
|
| } else {
|
| - pr->stencilPath(*clipPath, stroke, fGpu);
|
| + pr->stencilPath(stroke, fGpu);
|
| }
|
| }
|
| }
|
| @@ -715,7 +718,7 @@
|
| } else {
|
| SkASSERT(Element::kPath_Type == element->getType());
|
| SET_RANDOM_COLOR
|
| - pr->drawPath(*clipPath, stroke, fGpu, false);
|
| + pr->drawPath(stroke, fGpu, false);
|
| }
|
| } else {
|
| SET_RANDOM_COLOR
|
|
|