Move GrRenderTargetPriv::maxWindowRectangles to GrRenderTargetContextPriv & GrRenderTargetProxy

This removes a reason to call accessRenderTarget on the GrRenderTargetContext

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4583

Change-Id: I6e8a53ffd5c1fea80f542b70e05744e2991f70f8
Reviewed-on: https://skia-review.googlesource.com/4583
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 669a9c2..133c4f7 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -273,14 +273,12 @@
         return false;
     }
 
-    GrRenderTarget* rt = renderTargetContext->accessRenderTarget();
-
     const SkScalar clipX = SkIntToScalar(fOrigin.x()),
                    clipY = SkIntToScalar(fOrigin.y());
 
     SkRect clipSpaceDevBounds = devBounds.makeOffset(clipX, clipY);
     const GrReducedClip reducedClip(*fStack, clipSpaceDevBounds,
-                                    rt->renderTargetPriv().maxWindowRectangles());
+                                    renderTargetContext->priv().maxWindowRectangles());
 
     if (reducedClip.hasIBounds() &&
         !GrClip::IsInsideClip(reducedClip.ibounds(), clipSpaceDevBounds)) {
@@ -357,6 +355,8 @@
         // if alpha clip mask creation fails fall through to the non-AA code paths
     }
 
+    GrRenderTarget* rt = renderTargetContext->accessRenderTarget();
+
     // use the stencil clip if we can't represent the clip as a rectangle.
     if (!context->resourceProvider()->attachStencilAttachment(rt)) {
         SkDebugf("WARNING: failed to attach stencil buffer for clip mask. Clip will be ignored.\n");
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index f15e3b0..f495cd3 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -118,8 +118,3 @@
     return specs;
 }
 
-int GrRenderTargetPriv::maxWindowRectangles() const {
-    return (this->flags() & Flags::kWindowRectsSupport) ?
-           fRenderTarget->getGpu()->caps()->maxWindowRectangles() : 0;
-}
-
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 4c86cbc..3bc6ad3 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -579,6 +579,11 @@
     this->internalDrawPath(clip, paint, viewMatrix, path, *style);
 }
 
+int GrRenderTargetContextPriv::maxWindowRectangles() const {
+    return fRenderTargetContext->fRenderTargetProxy->maxWindowRectangles(
+                                                    *fRenderTargetContext->fContext->caps());
+}
+
 void GrRenderTargetContextPriv::clearStencilClip(const GrFixedClip& clip, bool insideStencilMask) {
     ASSERT_SINGLE_OWNER_PRIV
     RETURN_IF_ABANDONED_PRIV
diff --git a/src/gpu/GrRenderTargetContextPriv.h b/src/gpu/GrRenderTargetContextPriv.h
index 83a334b..802cba0 100644
--- a/src/gpu/GrRenderTargetContextPriv.h
+++ b/src/gpu/GrRenderTargetContextPriv.h
@@ -80,6 +80,8 @@
 
     SkBudgeted isBudgeted() const;
 
+    int maxWindowRectangles() const;
+
     void testingOnly_drawBatch(const GrPaint&,
                                GrDrawBatch* batch,
                                const GrUserStencilSettings* = nullptr,
diff --git a/src/gpu/GrRenderTargetPriv.h b/src/gpu/GrRenderTargetPriv.h
index 19e7263..89f4d52 100644
--- a/src/gpu/GrRenderTargetPriv.h
+++ b/src/gpu/GrRenderTargetPriv.h
@@ -40,7 +40,6 @@
     typedef GrRenderTarget::Flags Flags;
 
     Flags flags() const { return fRenderTarget->fFlags; }
-    int maxWindowRectangles() const;
 
 private:
     explicit GrRenderTargetPriv(GrRenderTarget* renderTarget) : fRenderTarget(renderTarget) {}
diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp
index 669f422..8eb335d 100644
--- a/src/gpu/GrRenderTargetProxy.cpp
+++ b/src/gpu/GrRenderTargetProxy.cpp
@@ -36,6 +36,10 @@
     , fFlags(fTarget->asRenderTarget()->renderTargetPriv().flags()) {
 }
 
+int GrRenderTargetProxy::maxWindowRectangles(const GrCaps& caps) const {
+    return (fFlags & GrRenderTarget::Flags::kWindowRectsSupport) ? caps.maxWindowRectangles() : 0;
+}
+
 GrRenderTarget* GrRenderTargetProxy::instantiate(GrTextureProvider* texProvider) {
     SkASSERT(fDesc.fFlags & GrSurfaceFlags::kRenderTarget_GrSurfaceFlag);