Clean up clipping code a bit

Review URL: https://codereview.chromium.org/913693002
diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp
index 2d8c94f..e0c3db0 100644
--- a/src/core/SkClipStack.cpp
+++ b/src/core/SkClipStack.cpp
@@ -420,12 +420,6 @@
     }
 
     if (!fDoAA) {
-        // Here we mimic a non-anti-aliased scanline system. If there is
-        // no anti-aliasing we can integerize the bounding box to exclude
-        // fractional parts that won't be rendered.
-        // Note: the left edge is handled slightly differently below. We
-        // are a bit more generous in the rounding since we don't want to
-        // risk missing the left pixels when fLeft is very close to .5
         fFiniteBound.set(SkScalarFloorToScalar(fFiniteBound.fLeft+0.45f),
                          SkScalarRoundToScalar(fFiniteBound.fTop),
                          SkScalarRoundToScalar(fFiniteBound.fRight),
@@ -622,25 +616,6 @@
     }
 }
 
-bool SkClipStack::intersectRectWithClip(SkRect* rect) const {
-    SkASSERT(rect);
-
-    SkRect bounds;
-    SkClipStack::BoundsType bt;
-    this->getBounds(&bounds, &bt);
-    if (bt == SkClipStack::kInsideOut_BoundsType) {
-        if (bounds.contains(*rect)) {
-            return false;
-        } else {
-            // If rect's x values are both within bound's x range we
-            // could clip here. Same for y. But we don't bother to check.
-            return true;
-        }
-    } else {
-        return rect->intersect(bounds);
-    }
-}
-
 bool SkClipStack::quickContains(const SkRect& rect) const {
 
     Iter iter(*this, Iter::kTop_IterStart);
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;