| Index: src/gpu/GrClipMaskManager.cpp | 
| diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp | 
| index 77d5ea1d03fcc30c47ba42f3d7085cb3d236ec9a..43e88e7ed58ba8d0a6768a10026952a6db0e4cb8 100644 | 
| --- a/src/gpu/GrClipMaskManager.cpp | 
| +++ b/src/gpu/GrClipMaskManager.cpp | 
| @@ -26,6 +26,7 @@ | 
| #include "effects/GrTextureDomain.h" | 
|  | 
| typedef SkClipStack::Element Element; | 
| +typedef GrReducedClip::InitialState InitialState; | 
|  | 
| static const int kMaxAnalyticElements = 4; | 
|  | 
| @@ -237,40 +238,34 @@ bool GrClipMaskManager::SetupClipping(GrContext* context, | 
| return true; | 
| } | 
|  | 
| +    const SkScalar clipX = clip.origin().x(), | 
| +                   clipY = clip.origin().y(); | 
| +    SkRect devBounds = SkRect::MakeIWH(drawContext->width(), drawContext->height()); | 
| +    if (!devBounds.intersect(devBounds.makeOffset(-clipX, -clipY))) { | 
| +        return false; | 
| +    } | 
| +    if (origDevBounds && !devBounds.intersect(*origDevBounds)) { | 
| +        return false; | 
| +    } | 
| + | 
| GrReducedClip::ElementList elements; | 
| int32_t genID = 0; | 
| -    GrReducedClip::InitialState initialState = GrReducedClip::kAllIn_InitialState; | 
| SkIRect clipSpaceIBounds; | 
| bool requiresAA = false; | 
|  | 
| -    SkIRect clipSpaceReduceQueryBounds; | 
| -    SkRect devBounds; | 
| -    if (origDevBounds) { | 
| -        if (!devBounds.intersect(SkRect::MakeIWH(drawContext->width(), drawContext->height()), | 
| -                                 *origDevBounds)) { | 
| -            return false; | 
| -        } | 
| -        devBounds.roundOut(&clipSpaceReduceQueryBounds); | 
| -        clipSpaceReduceQueryBounds.offset(clip.origin()); | 
| -    } else { | 
| -        devBounds = SkRect::MakeIWH(drawContext->width(), drawContext->height()); | 
| -        clipSpaceReduceQueryBounds.setXYWH(0, 0, drawContext->width(), drawContext->height()); | 
| -        clipSpaceReduceQueryBounds.offset(clip.origin()); | 
| -    } | 
| -    GrReducedClip::ReduceClipStack(*clip.clipStack(), | 
| -                                    clipSpaceReduceQueryBounds, | 
| -                                    &elements, | 
| -                                    &genID, | 
| -                                    &initialState, | 
| -                                    &clipSpaceIBounds, | 
| -                                    &requiresAA); | 
| +    InitialState initialState = GrReducedClip::ReduceClipStack(*clip.clipStack(), | 
| +                                                               devBounds.makeOffset(clipX, clipY), | 
| +                                                               &elements, | 
| +                                                               &genID, | 
| +                                                               &clipSpaceIBounds, | 
| +                                                               &requiresAA); | 
| if (elements.isEmpty()) { | 
| if (GrReducedClip::kAllOut_InitialState == initialState) { | 
| return false; | 
| } else { | 
| SkIRect scissorSpaceIBounds(clipSpaceIBounds); | 
| scissorSpaceIBounds.offset(-clip.origin()); | 
| -            if (!GrClip::CanIgnoreScissor(scissorSpaceIBounds, devBounds)) { | 
| +            if (!GrClip::IsInsideClip(scissorSpaceIBounds, devBounds)) { | 
| out->makeScissored(scissorSpaceIBounds); | 
| } | 
| return true; | 
| @@ -286,8 +281,7 @@ bool GrClipMaskManager::SetupClipping(GrContext* context, | 
| // configuration's relative costs of switching RTs to generate a mask vs | 
| // longer shaders. | 
| if (elements.count() <= kMaxAnalyticElements) { | 
| -        SkVector clipToRTOffset = { SkIntToScalar(-clip.origin().fX), | 
| -                                    SkIntToScalar(-clip.origin().fY) }; | 
| +        SkVector clipToRTOffset = { SkIntToScalar(-clipX), SkIntToScalar(-clipY) }; | 
| // When there are multiple samples we want to do per-sample clipping, not compute a | 
| // fractional pixel coverage. | 
| bool disallowAnalyticAA = drawContext->isStencilBufferMultisampled(); | 
| @@ -303,7 +297,7 @@ bool GrClipMaskManager::SetupClipping(GrContext* context, | 
| &clipFP)) { | 
| SkIRect scissorSpaceIBounds(clipSpaceIBounds); | 
| scissorSpaceIBounds.offset(-clip.origin()); | 
| -            if (GrClip::CanIgnoreScissor(scissorSpaceIBounds, devBounds)) { | 
| +            if (GrClip::IsInsideClip(scissorSpaceIBounds, devBounds)) { | 
| out->makeFPBased(std::move(clipFP), SkRect::Make(scissorSpaceIBounds)); | 
| } else { | 
| out->makeScissoredFPBased(std::move(clipFP), scissorSpaceIBounds); | 
| @@ -370,7 +364,7 @@ bool GrClipMaskManager::SetupClipping(GrContext* context, | 
| // use both stencil and scissor test to the bounds for the final draw. | 
| SkIRect scissorSpaceIBounds(clipSpaceIBounds); | 
| scissorSpaceIBounds.offset(clipSpaceToStencilSpaceOffset); | 
| -    if (GrClip::CanIgnoreScissor(scissorSpaceIBounds, devBounds)) { | 
| +    if (GrClip::IsInsideClip(scissorSpaceIBounds, devBounds)) { | 
| out->makeStencil(true, devBounds); | 
| } else { | 
| out->makeScissoredStencil(scissorSpaceIBounds); | 
|  |