Clean up clipping code a bit
Review URL: https://codereview.chromium.org/913693002
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 0226ac1..f69c871 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 @@
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 @@
}
}
-#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 @@
}
// 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 4fb7538..364c214 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -49,13 +49,11 @@
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 @@
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 e621365..bc544ad 100644
--- a/src/gpu/GrTextContext.cpp
+++ b/src/gpu/GrTextContext.cpp
@@ -24,15 +24,9 @@
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 ec44d08..7aad50f 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -156,6 +156,8 @@
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 6419aa6..21d2f63 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1327,13 +1327,13 @@
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 @@
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 @@
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 @@
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;