ccpr: Clean up GrCoverageCountingPathRenderer

Extracts all the nested classes to their own files and detangles
their interactions. Encapsulates the per-flush resources in their in
their own separate class.

Bug: skia:
Change-Id: Ic134b627f6b66cb2ce1e5d6f896ac6b2f75f6fa2
Reviewed-on: https://skia-review.googlesource.com/126845
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ccpr/GrCCClipPath.cpp b/src/gpu/ccpr/GrCCClipPath.cpp
new file mode 100644
index 0000000..6b8a96c
--- /dev/null
+++ b/src/gpu/ccpr/GrCCClipPath.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrCCClipPath.h"
+
+#include "GrOnFlushResourceProvider.h"
+#include "GrProxyProvider.h"
+#include "GrTexture.h"
+#include "ccpr/GrCCPerFlushResources.h"
+
+void GrCCClipPath::init(GrProxyProvider* proxyProvider,
+                        const SkPath& deviceSpacePath, const SkIRect& accessRect,
+                        int rtWidth, int rtHeight) {
+    SkASSERT(!this->isInitialized());
+
+    fAtlasLazyProxy = proxyProvider->createFullyLazyProxy(
+            [this](GrResourceProvider* resourceProvider) {
+                if (!resourceProvider) {
+                    return sk_sp<GrTexture>();
+                }
+                SkASSERT(fHasAtlas);
+                SkASSERT(!fHasAtlasTransform);
+
+                GrTextureProxy* textureProxy = fAtlas ? fAtlas->textureProxy() : nullptr;
+                if (!textureProxy || !textureProxy->instantiate(resourceProvider)) {
+                    fAtlasScale = fAtlasTranslate = {0, 0};
+                    SkDEBUGCODE(fHasAtlasTransform = true);
+                    return sk_sp<GrTexture>();
+                }
+
+                SkASSERT(kTopLeft_GrSurfaceOrigin == textureProxy->origin());
+
+                fAtlasScale = {1.f / textureProxy->width(), 1.f / textureProxy->height()};
+                fAtlasTranslate = {fAtlasOffsetX * fAtlasScale.x(),
+                                   fAtlasOffsetY * fAtlasScale.y()};
+                SkDEBUGCODE(fHasAtlasTransform = true);
+
+                return sk_ref_sp(textureProxy->priv().peekTexture());
+            },
+            GrProxyProvider::Renderable::kYes, kTopLeft_GrSurfaceOrigin, kAlpha_half_GrPixelConfig);
+
+    fDeviceSpacePath = deviceSpacePath;
+    fDeviceSpacePath.getBounds().roundOut(&fPathDevIBounds);
+    fAccessRect = accessRect;
+}
+
+void GrCCClipPath::placePathInAtlas(GrCCPerFlushResources* resources,
+                                    GrOnFlushResourceProvider* onFlushRP) {
+    SkASSERT(this->isInitialized());
+    SkASSERT(!fHasAtlas);
+    fAtlas = resources->addDeviceSpacePathToAtlas(*onFlushRP->caps(), fAccessRect, fDeviceSpacePath,
+                                                  fPathDevIBounds, &fAtlasOffsetX, &fAtlasOffsetY);
+    SkDEBUGCODE(fHasAtlas = true);
+}