In GrClipStackClip check whether op bounds are inside RT before checking for empty clip stack.

Also fixes the bounds of aa bevel stroked rectangles.

Change-Id: I4c80deb9066ebbf9514ce3d4b270ff566bf12e02
Reviewed-on: https://skia-review.googlesource.com/9786
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 96b4b88..b010981 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -250,15 +250,15 @@
 bool GrClipStackClip::apply(GrContext* context, GrRenderTargetContext* renderTargetContext,
                             bool useHWAA, bool hasUserStencilSettings, GrAppliedClip* out,
                             SkRect* bounds) const {
-    if (!fStack || fStack->isWideOpen()) {
-        return true;
-    }
-
     SkRect devBounds = SkRect::MakeIWH(renderTargetContext->width(), renderTargetContext->height());
     if (!devBounds.intersect(*bounds)) {
         return false;
     }
 
+    if (!fStack || fStack->isWideOpen()) {
+        return true;
+    }
+
     const GrReducedClip reducedClip(*fStack, devBounds,
                                     renderTargetContext->priv().maxWindowRectangles());
 
diff --git a/src/gpu/ops/GrAAStrokeRectOp.cpp b/src/gpu/ops/GrAAStrokeRectOp.cpp
index 3780752..b684782 100644
--- a/src/gpu/ops/GrAAStrokeRectOp.cpp
+++ b/src/gpu/ops/GrAAStrokeRectOp.cpp
@@ -138,7 +138,15 @@
         compute_rects(&info.fDevOutside, &info.fDevOutsideAssist, &info.fDevInside,
                       &info.fDegenerate, viewMatrix, rect, stroke.getWidth(), isMiter);
         info.fColor = color;
-        op->setBounds(info.fDevOutside, HasAABloat::kYes, IsZeroArea::kNo);
+        if (isMiter) {
+            op->setBounds(info.fDevOutside, HasAABloat::kYes, IsZeroArea::kNo);
+        } else {
+            // The outer polygon of the bevel stroke is an octagon specified by the points of a
+            // pair of overlapping rectangles where one is wide and the other is narrow.
+            SkRect bounds = info.fDevOutside;
+            bounds.joinPossiblyEmptyRect(info.fDevOutsideAssist);
+            op->setBounds(bounds, HasAABloat::kYes, IsZeroArea::kNo);
+        }
         op->fViewMatrix = viewMatrix;
         return std::unique_ptr<GrMeshDrawOp>(op);
     }