diff options
author | 2015-02-10 08:16:55 -0800 | |
---|---|---|
committer | 2015-02-10 08:16:55 -0800 | |
commit | e85a32d4f8ce7fb9b6aaae89137dbf3766d833f2 (patch) | |
tree | 3b6a65e0ef71425284e4cf4f1f40faf58255ec55 /src/gpu | |
parent | ac928f27ab632784d6b9572901201caa2908caa5 (diff) |
Clean up clipping code a bit
Review URL: https://codereview.chromium.org/913693002
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrClipMaskManager.cpp | 5 | ||||
-rw-r--r-- | src/gpu/GrSoftwarePathRenderer.cpp | 7 | ||||
-rw-r--r-- | src/gpu/GrTextContext.cpp | 10 | ||||
-rw-r--r-- | src/gpu/effects/GrConfigConversionEffect.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 30 |
5 files changed, 22 insertions, 32 deletions
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp index 0226ac1b76..f69c8717f8 100644 --- a/src/gpu/GrClipMaskManager.cpp +++ b/src/gpu/GrClipMaskManager.cpp @@ -23,7 +23,6 @@ #include "effects/GrRRectEffect.h" #include "effects/GrTextureDomain.h" -#define GR_AA_CLIP 1 typedef SkClipStack::Element Element; //////////////////////////////////////////////////////////////////////////////// @@ -153,7 +152,7 @@ bool GrClipMaskManager::installClipEffects(GrPipelineBuilder* pipelineBuilder, if (!skip) { GrPrimitiveEdgeType edgeType; - if (GR_AA_CLIP && iter.get()->isAA()) { + if (iter.get()->isAA()) { if (rt->isMultisampled()) { // Coverage based AA clips don't place nicely with MSAA. failed = true; @@ -276,7 +275,6 @@ bool GrClipMaskManager::setupClipping(GrPipelineBuilder* pipelineBuilder, } } -#if GR_AA_CLIP // If MSAA is enabled we can do everything in the stencil buffer. if (0 == rt->numSamples() && requiresAA) { GrTexture* result = NULL; @@ -314,7 +312,6 @@ bool GrClipMaskManager::setupClipping(GrPipelineBuilder* pipelineBuilder, } // if alpha clip mask creation fails fall through to the non-AA code paths } -#endif // GR_AA_CLIP // Either a hard (stencil buffer) clip was explicitly requested or an anti-aliased clip couldn't // be created. In either case, free up the texture in the anti-aliased mask cache. diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp index 4fb7538b03..364c214a60 100644 --- a/src/gpu/GrSoftwarePathRenderer.cpp +++ b/src/gpu/GrSoftwarePathRenderer.cpp @@ -49,13 +49,11 @@ bool get_path_and_clip_bounds(const GrDrawTarget* target, if (NULL == rt) { return false; } - *devPathBounds = SkIRect::MakeWH(rt->width(), rt->height()); target->getClip()->getConservativeBounds(rt, devClipBounds); - // TODO: getConservativeBounds already intersects with the - // render target's bounding box. Remove this next line - if (!devPathBounds->intersect(*devClipBounds)) { + if (devClipBounds->isEmpty()) { + *devPathBounds = SkIRect::MakeWH(rt->width(), rt->height()); return false; } @@ -64,6 +62,7 @@ bool get_path_and_clip_bounds(const GrDrawTarget* target, matrix.mapRect(&pathSBounds, path.getBounds()); SkIRect pathIBounds; pathSBounds.roundOut(&pathIBounds); + *devPathBounds = *devClipBounds; if (!devPathBounds->intersect(pathIBounds)) { // set the correct path bounds, as this would be used later. *devPathBounds = pathIBounds; diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp index e62136507c..bc544ad4a0 100644 --- a/src/gpu/GrTextContext.cpp +++ b/src/gpu/GrTextContext.cpp @@ -24,15 +24,9 @@ GrTextContext::~GrTextContext() { void GrTextContext::init(const GrPaint& grPaint, const SkPaint& skPaint) { const GrClipData* clipData = fContext->getClip(); - SkRect devConservativeBound; - clipData->fClipStack->getConservativeBounds( - -clipData->fOrigin.fX, - -clipData->fOrigin.fY, - fContext->getRenderTarget()->width(), + clipData->getConservativeBounds(fContext->getRenderTarget()->width(), fContext->getRenderTarget()->height(), - &devConservativeBound); - - devConservativeBound.roundOut(&fClipRect); + &fClipRect); fDrawTarget = fContext->getTextTarget(); diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index ec44d08b01..7aad50f5f8 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -156,6 +156,8 @@ GrGLFragmentProcessor* GrConfigConversionEffect::createGLInstance() const { return SkNEW_ARGS(GrGLConfigConversionEffect, (*this)); } + + void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context, PMConversion* pmToUPMRule, PMConversion* upmToPMRule) { diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 6419aa6b52..21d2f6327b 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1327,13 +1327,13 @@ GrIndexBuffer* GrGLGpu::onCreateIndexBuffer(size_t size, bool dynamic) { void GrGLGpu::flushScissor(const GrScissorState& scissorState, const GrGLIRect& rtViewport, GrSurfaceOrigin rtOrigin) { - if (scissorState.fEnabled) { + if (scissorState.enabled()) { GrGLIRect scissor; scissor.setRelativeTo(rtViewport, - scissorState.fRect.fLeft, - scissorState.fRect.fTop, - scissorState.fRect.width(), - scissorState.fRect.height(), + scissorState.rect().fLeft, + scissorState.rect().fTop, + scissorState.rect().width(), + scissorState.rect().height(), rtOrigin); // if the scissor fully contains the viewport then we fall through and // disable the scissor test. @@ -1489,9 +1489,8 @@ void GrGLGpu::onClear(GrRenderTarget* target, const SkIRect* rect, GrColor color this->flushRenderTarget(glRT, rect); GrScissorState scissorState; - scissorState.fEnabled = SkToBool(rect); - if (scissorState.fEnabled) { - scissorState.fRect = *rect; + if (rect) { + scissorState.set(*rect); } this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); @@ -1602,8 +1601,7 @@ void GrGLGpu::onClearStencilClip(GrRenderTarget* target, const SkIRect& rect, bo this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); GrScissorState scissorState; - scissorState.fEnabled = true; - scissorState.fRect = rect; + scissorState.set(rect); this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); GL_CALL(StencilMask((uint32_t) clipStencilMask)); @@ -1930,18 +1928,18 @@ void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) { fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; const GrGLIRect& vp = rt->getViewport(); const SkIRect dirtyRect = rt->getResolveRect(); - GrGLIRect r; - r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, - dirtyRect.width(), dirtyRect.height(), target->origin()); if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { // Apple's extension uses the scissor as the blit bounds. GrScissorState scissorState; - scissorState.fEnabled = true; - scissorState.fRect = dirtyRect; - this->flushScissor(scissorState, rt->getViewport(), rt->origin()); + scissorState.set(dirtyRect); + this->flushScissor(scissorState, vp, rt->origin()); GL_CALL(ResolveMultisampleFramebuffer()); } else { + GrGLIRect r; + r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, + dirtyRect.width(), dirtyRect.height(), target->origin()); + int right = r.fLeft + r.fWidth; int top = r.fBottom + r.fHeight; |