Pass description of GrSurface to GrSurfaceProxy lazy callbacks.

Also make GrDynamicAtlas directly use the GrSurface callback type rather
than go through a springboard.

Change-Id: I3e3c155bbc1e2e794e0d6828b0ea3c64c6a7f3e9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/283226
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/core/SkDeferredDisplayListRecorder.cpp b/src/core/SkDeferredDisplayListRecorder.cpp
index f45baa0..d2e14d7 100644
--- a/src/core/SkDeferredDisplayListRecorder.cpp
+++ b/src/core/SkDeferredDisplayListRecorder.cpp
@@ -153,7 +153,8 @@
     GrSwizzle readSwizzle = caps->getReadSwizzle(fCharacterization.backendFormat(), grColorType);
 
     sk_sp<GrRenderTargetProxy> proxy = proxyProvider->createLazyRenderTargetProxy(
-            [lazyProxyData](GrResourceProvider* resourceProvider) {
+            [lazyProxyData](GrResourceProvider* resourceProvider,
+                            const GrSurfaceProxy::LazySurfaceDesc&) {
                 // The proxy backing the destination surface had better have been instantiated
                 // prior to the proxy backing the DLL's surface. Steal its GrRenderTarget.
                 SkASSERT(lazyProxyData->fReplayDest->peekSurface());
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index 4e603f3..08e5f52 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -117,8 +117,6 @@
     AHardwareBuffer* hardwareBuffer = fHardwareBuffer;
     AHardwareBuffer_acquire(hardwareBuffer);
 
-    const bool isProtectedContent = fIsProtectedContent;
-
     class AutoAHBRelease {
     public:
         AutoAHBRelease(AHardwareBuffer* ahb) : fAhb(ahb) {}
@@ -140,21 +138,25 @@
     };
 
     sk_sp<GrTextureProxy> texProxy = proxyProvider->createLazyProxy(
-            [direct, buffer = AutoAHBRelease(hardwareBuffer), width, height, isProtectedContent,
-             backendFormat](
-                    GrResourceProvider* resourceProvider) -> GrSurfaceProxy::LazyCallbackResult {
+            [direct, buffer = AutoAHBRelease(hardwareBuffer)](
+                    GrResourceProvider* resourceProvider,
+                    const GrSurfaceProxy::LazySurfaceDesc& desc)
+                    -> GrSurfaceProxy::LazyCallbackResult {
                 GrAHardwareBufferUtils::DeleteImageProc deleteImageProc = nullptr;
                 GrAHardwareBufferUtils::UpdateImageProc updateImageProc = nullptr;
                 GrAHardwareBufferUtils::TexImageCtx texImageCtx = nullptr;
 
+                bool isProtected = desc.fProtected == GrProtected::kYes;
                 GrBackendTexture backendTex =
-                        GrAHardwareBufferUtils::MakeBackendTexture(direct, buffer.get(),
-                                                                   width, height,
+                        GrAHardwareBufferUtils::MakeBackendTexture(direct,
+                                                                   buffer.get(),
+                                                                   desc.fDimensions.width(),
+                                                                   desc.fDimensions.height(),
                                                                    &deleteImageProc,
                                                                    &updateImageProc,
                                                                    &texImageCtx,
-                                                                   isProtectedContent,
-                                                                   backendFormat,
+                                                                   isProtected,
+                                                                   desc.fFormat,
                                                                    false);
                 if (!backendTex.isValid()) {
                     return {};
@@ -179,7 +181,7 @@
             },
             backendFormat, {width, height}, GrRenderable::kNo, 1, GrMipMapped::kNo,
             GrMipMapsStatus::kNotAllocated, GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact,
-            SkBudgeted::kNo, GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes);
+            SkBudgeted::kNo, GrProtected(fIsProtectedContent), GrSurfaceProxy::UseAllocator::kYes);
 
     GrSwizzle readSwizzle = context->priv().caps()->getReadSwizzle(backendFormat, grColorType);
 
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 24ccf07..54d4c75 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -161,7 +161,8 @@
     // be deleted before we actually execute the lambda.
     sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
             [refHelper = fRefHelper, releaseProcHelper, backendTexture = fBackendTexture](
-                    GrResourceProvider* resourceProvider) -> GrSurfaceProxy::LazyCallbackResult {
+                    GrResourceProvider* resourceProvider,
+                    const GrSurfaceProxy::LazySurfaceDesc&) -> GrSurfaceProxy::LazyCallbackResult {
                 if (refHelper->fSemaphore) {
                     resourceProvider->priv().gpu()->waitSemaphore(refHelper->fSemaphore.get());
                 }
diff --git a/src/gpu/GrDynamicAtlas.cpp b/src/gpu/GrDynamicAtlas.cpp
index 1ad8c6c..00d0947 100644
--- a/src/gpu/GrDynamicAtlas.cpp
+++ b/src/gpu/GrDynamicAtlas.cpp
@@ -46,8 +46,10 @@
 };
 
 sk_sp<GrTextureProxy> GrDynamicAtlas::MakeLazyAtlasProxy(
-        const LazyInstantiateAtlasCallback& callback, GrColorType colorType,
-        InternalMultisample internalMultisample, const GrCaps& caps,
+        LazyInstantiateAtlasCallback&& callback,
+        GrColorType colorType,
+        InternalMultisample internalMultisample,
+        const GrCaps& caps,
         GrSurfaceProxy::UseAllocator useAllocator) {
     GrBackendFormat format = caps.getDefaultBackendFormat(colorType, GrRenderable::kYes);
 
@@ -56,12 +58,8 @@
         sampleCount = caps.internalMultisampleCount(format);
     }
 
-    auto instantiate = [cb = std::move(callback), format, sampleCount](GrResourceProvider* rp) {
-        return cb(rp, format, sampleCount);
-    };
-
     sk_sp<GrTextureProxy> proxy =
-            GrProxyProvider::MakeFullyLazyProxy(std::move(instantiate), format, GrRenderable::kYes,
+            GrProxyProvider::MakeFullyLazyProxy(std::move(callback), format, GrRenderable::kYes,
                                                 sampleCount, GrProtected::kNo, caps, useAllocator);
 
     return proxy;
@@ -85,12 +83,11 @@
     fTopNode = nullptr;
     fDrawBounds.setEmpty();
     fTextureProxy = MakeLazyAtlasProxy(
-            [this](GrResourceProvider* resourceProvider, const GrBackendFormat& format,
-                   int sampleCount) {
+            [this](GrResourceProvider* resourceProvider, const LazyAtlasDesc& desc) {
                 if (!fBackingTexture) {
                     fBackingTexture = resourceProvider->createTexture(
-                            {fWidth, fHeight}, format, GrRenderable::kYes, sampleCount,
-                            GrMipMapped::kNo, SkBudgeted::kYes, GrProtected::kNo);
+                            {fWidth, fHeight}, desc.fFormat, desc.fRenderable, desc.fSampleCnt,
+                            desc.fMipMapped, desc.fBudgeted, desc.fProtected);
                 }
                 return GrSurfaceProxy::LazyCallbackResult(fBackingTexture);
             },
diff --git a/src/gpu/GrDynamicAtlas.h b/src/gpu/GrDynamicAtlas.h
index 609dd5b..7a7780c 100644
--- a/src/gpu/GrDynamicAtlas.h
+++ b/src/gpu/GrDynamicAtlas.h
@@ -27,23 +27,25 @@
     static constexpr GrSurfaceOrigin kTextureOrigin = kTopLeft_GrSurfaceOrigin;
     static constexpr int kPadding = 1;  // Amount of padding below and to the right of each path.
 
-    using LazyInstantiateAtlasCallback = std::function<GrSurfaceProxy::LazyCallbackResult(
-            GrResourceProvider*, const GrBackendFormat&, int sampleCount)>;
+    using LazyAtlasDesc = GrSurfaceProxy::LazySurfaceDesc;
+    using LazyInstantiateAtlasCallback = GrSurfaceProxy::LazyInstantiateCallback;
 
     enum class InternalMultisample : bool {
         kNo = false,
         kYes = true
     };
 
-    static sk_sp<GrTextureProxy> MakeLazyAtlasProxy(const LazyInstantiateAtlasCallback&,
-                                                    GrColorType colorType, InternalMultisample,
-                                                    const GrCaps&, GrSurfaceProxy::UseAllocator);
+    static sk_sp<GrTextureProxy> MakeLazyAtlasProxy(LazyInstantiateAtlasCallback&&,
+                                                    GrColorType colorType,
+                                                    InternalMultisample,
+                                                    const GrCaps&,
+                                                    GrSurfaceProxy::UseAllocator);
 
     GrDynamicAtlas(GrColorType colorType, InternalMultisample, SkISize initialSize,
                    int maxAtlasSize, const GrCaps&);
     virtual ~GrDynamicAtlas();
 
-    void reset(SkISize initialSize, const GrCaps& caps);
+    void reset(SkISize initialSize, const GrCaps& desc);
 
     GrTextureProxy* textureProxy() const { return fTextureProxy.get(); }
     bool isInstantiated() const { return fTextureProxy->isInstantiated(); }
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index 60ada6c..cf20dd1 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -317,12 +317,13 @@
     }
 
     sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
-            [dims, format, bitmap, fit, colorType, budgeted](GrResourceProvider* resourceProvider) {
+            [bitmap](GrResourceProvider* resourceProvider, const LazySurfaceDesc& desc) {
+                SkASSERT(desc.fMipMapped == GrMipMapped::kNo);
                 GrMipLevel mipLevel = { bitmap.getPixels(), bitmap.rowBytes() };
-
+                auto colorType = SkColorTypeToGrColorType(bitmap.colorType());
                 return LazyCallbackResult(resourceProvider->createTexture(
-                        dims, format, colorType, GrRenderable::kNo, 1, budgeted, fit,
-                        GrProtected::kNo, mipLevel));
+                        desc.fDimensions, desc.fFormat, colorType, desc.fRenderable,
+                        desc.fSampleCnt, desc.fBudgeted, desc.fFit, desc.fProtected, mipLevel));
             },
             format, dims, GrRenderable::kNo, 1, GrMipMapped::kNo, GrMipMapsStatus::kNotAllocated,
             GrInternalSurfaceFlags::kNone, fit, budgeted, GrProtected::kNo, UseAllocator::kYes);
@@ -352,14 +353,14 @@
     auto dims = bitmap.dimensions();
 
     sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
-            [dims, format, bitmap, mipmaps, budgeted](GrResourceProvider* resourceProvider) {
+            [bitmap, mipmaps](GrResourceProvider* resourceProvider, const LazySurfaceDesc& desc) {
                 const int mipLevelCount = mipmaps->countLevels() + 1;
                 std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]);
+                auto colorType = SkColorTypeToGrColorType(bitmap.colorType());
 
                 texels[0].fPixels = bitmap.getPixels();
                 texels[0].fRowBytes = bitmap.rowBytes();
 
-                auto colorType = SkColorTypeToGrColorType(bitmap.colorType());
                 for (int i = 1; i < mipLevelCount; ++i) {
                     SkMipMap::Level generatedMipLevel;
                     mipmaps->getLevel(i - 1, &generatedMipLevel);
@@ -369,8 +370,8 @@
                     SkASSERT(generatedMipLevel.fPixmap.colorType() == bitmap.colorType());
                 }
                 return LazyCallbackResult(resourceProvider->createTexture(
-                        dims, format, colorType, GrRenderable::kNo, 1, budgeted, GrProtected::kNo,
-                        texels.get(), mipLevelCount));
+                        desc.fDimensions, desc.fFormat, colorType, GrRenderable::kNo, 1,
+                        desc.fBudgeted, GrProtected::kNo, texels.get(), mipLevelCount));
             },
             format, dims, GrRenderable::kNo, 1, GrMipMapped::kYes, GrMipMapsStatus::kValid,
             GrInternalSurfaceFlags::kNone, SkBackingFit::kExact, budgeted, GrProtected::kNo,
@@ -457,10 +458,10 @@
                                                                 : GrMipMapsStatus::kNotAllocated;
 
     sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
-            [dimensions, format, budgeted, mipMapped, isProtected,
-             data](GrResourceProvider* resourceProvider) {
+            [data](GrResourceProvider* resourceProvider, const LazySurfaceDesc& desc) {
                 return LazyCallbackResult(resourceProvider->createCompressedTexture(
-                    dimensions, format, budgeted, mipMapped, isProtected, data.get()));
+                        desc.fDimensions, desc.fFormat, desc.fBudgeted, desc.fMipMapped,
+                        desc.fProtected, data.get()));
             },
             format, dimensions, GrRenderable::kNo, 1, mipMapped, mipMapsStatus,
             GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact, SkBudgeted::kYes,
diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h
index 27cbf6a..a275f29 100644
--- a/src/gpu/GrProxyProvider.h
+++ b/src/gpu/GrProxyProvider.h
@@ -148,6 +148,7 @@
                                                                    const GrVkDrawableInfo&);
 
     using LazyInstantiationKeyMode = GrSurfaceProxy::LazyInstantiationKeyMode;
+    using LazySurfaceDesc = GrSurfaceProxy::LazySurfaceDesc;
     using LazyCallbackResult = GrSurfaceProxy::LazyCallbackResult;
     using LazyInstantiateCallback = GrSurfaceProxy::LazyInstantiateCallback;
 
diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp
index 824a599..ea635e9 100644
--- a/src/gpu/GrRenderTargetProxy.cpp
+++ b/src/gpu/GrRenderTargetProxy.cpp
@@ -127,6 +127,22 @@
     return surface->resourcePriv().refsWrappedObjects();
 }
 
+GrSurfaceProxy::LazySurfaceDesc GrRenderTargetProxy::callbackDesc() const {
+    // We only expect exactly sized lazy RT proxies.
+    SkASSERT(!this->isFullyLazy());
+    SkASSERT(this->isFunctionallyExact());
+    return {
+            this->dimensions(),
+            SkBackingFit::kExact,
+            GrRenderable::kYes,
+            GrMipMapped::kNo,
+            this->numSamples(),
+            this->backendFormat(),
+            this->isProtected(),
+            this->isBudgeted(),
+    };
+}
+
 #ifdef SK_DEBUG
 void GrRenderTargetProxy::onValidateSurface(const GrSurface* surface) {
     // We do not check that surface->asTexture returns null since, when replaying DDLs we
diff --git a/src/gpu/GrRenderTargetProxy.h b/src/gpu/GrRenderTargetProxy.h
index 8f58bb4..de21acc 100644
--- a/src/gpu/GrRenderTargetProxy.h
+++ b/src/gpu/GrRenderTargetProxy.h
@@ -143,6 +143,8 @@
     size_t onUninstantiatedGpuMemorySize(const GrCaps&) const override;
     SkDEBUGCODE(void onValidateSurface(const GrSurface*) override;)
 
+            LazySurfaceDesc callbackDesc() const override;
+
     // WARNING: Be careful when adding or removing fields here. ASAN is likely to trigger warnings
     // when instantiating GrTextureRenderTargetProxy. The std::function in GrSurfaceProxy makes
     // each class in the diamond require 16 byte alignment. Clang appears to layout the fields for
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index b6abd53..4df6c33 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -391,7 +391,7 @@
     bool syncKey = true;
     bool releaseCallback = false;
     if (!surface) {
-        auto result = fProxy->fLazyInstantiateCallback(resourceProvider);
+        auto result = fProxy->fLazyInstantiateCallback(resourceProvider, fProxy->callbackDesc());
         surface = std::move(result.fSurface);
         syncKey = result.fKeyMode == GrSurfaceProxy::LazyInstantiationKeyMode::kSynced;
         releaseCallback = surface && result.fReleaseCallback;
diff --git a/src/gpu/GrSurfaceProxy.h b/src/gpu/GrSurfaceProxy.h
index 4412505..0bbd936 100644
--- a/src/gpu/GrSurfaceProxy.h
+++ b/src/gpu/GrSurfaceProxy.h
@@ -62,6 +62,21 @@
         kSynced
     };
 
+    /**
+     * Specifies the expected properties of the GrSurface returned by a lazy instantiation
+     * callback. The dimensions will be negative in the case of a fully lazy proxy.
+     */
+    struct LazySurfaceDesc {
+        SkISize fDimensions;
+        SkBackingFit fFit;
+        GrRenderable fRenderable;
+        GrMipMapped fMipMapped;
+        int fSampleCnt;
+        const GrBackendFormat& fFormat;
+        GrProtected fProtected;
+        SkBudgeted fBudgeted;
+    };
+
     struct LazyCallbackResult {
         LazyCallbackResult() = default;
         LazyCallbackResult(const LazyCallbackResult&) = default;
@@ -85,7 +100,8 @@
         bool fReleaseCallback = true;
     };
 
-    using LazyInstantiateCallback = std::function<LazyCallbackResult(GrResourceProvider*)>;
+    using LazyInstantiateCallback =
+            std::function<LazyCallbackResult(GrResourceProvider*, const LazySurfaceDesc&)>;
 
     enum class UseAllocator {
         /**
@@ -410,6 +426,8 @@
 
     virtual size_t onUninstantiatedGpuMemorySize(const GrCaps&) const = 0;
 
+    virtual LazySurfaceDesc callbackDesc() const = 0;
+
     bool                   fIgnoredByResourceAllocator = false;
     GrProtected            fIsProtected;
 
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp
index 573d777..fa7e064 100644
--- a/src/gpu/GrTextureProxy.cpp
+++ b/src/gpu/GrTextureProxy.cpp
@@ -171,6 +171,28 @@
     fProxyProvider = nullptr;
 }
 
+GrSurfaceProxy::LazySurfaceDesc GrTextureProxy::callbackDesc() const {
+    SkISize dims;
+    SkBackingFit fit;
+    if (this->isFullyLazy()) {
+        fit = SkBackingFit::kApprox;
+        dims = {-1, -1};
+    } else {
+        fit = this->isFunctionallyExact() ? SkBackingFit::kExact : SkBackingFit::kApprox;
+        dims = this->dimensions();
+    }
+    return {
+            dims,
+            fit,
+            GrRenderable::kNo,
+            fMipMapped,
+            1,
+            this->backendFormat(),
+            this->isProtected(),
+            this->isBudgeted(),
+    };
+}
+
 #ifdef SK_DEBUG
 void GrTextureProxy::onValidateSurface(const GrSurface* surface) {
     SkASSERT(!surface->asRenderTarget());
diff --git a/src/gpu/GrTextureProxy.h b/src/gpu/GrTextureProxy.h
index f951546..06afa9a 100644
--- a/src/gpu/GrTextureProxy.h
+++ b/src/gpu/GrTextureProxy.h
@@ -176,6 +176,8 @@
     GrUniqueKey      fUniqueKey;
     GrProxyProvider* fProxyProvider; // only set when fUniqueKey is valid
 
+    LazySurfaceDesc callbackDesc() const override;
+
     // Only used for proxies whose contents are being prepared on a worker thread. This object
     // stores the texture data, allowing the proxy to remain uninstantiated until flush. At that
     // point, the proxy is instantiated, and this data is used to perform an ASAP upload.
diff --git a/src/gpu/GrTextureRenderTargetProxy.cpp b/src/gpu/GrTextureRenderTargetProxy.cpp
index 93e5f17..e7b6e18 100644
--- a/src/gpu/GrTextureRenderTargetProxy.cpp
+++ b/src/gpu/GrTextureRenderTargetProxy.cpp
@@ -143,6 +143,28 @@
     return surface;
 }
 
+GrSurfaceProxy::LazySurfaceDesc GrTextureRenderTargetProxy::callbackDesc() const {
+    SkISize dims;
+    SkBackingFit fit;
+    if (this->isFullyLazy()) {
+        fit = SkBackingFit::kApprox;
+        dims = {-1, -1};
+    } else {
+        fit = this->isFunctionallyExact() ? SkBackingFit::kExact : SkBackingFit::kApprox;
+        dims = this->dimensions();
+    }
+    return {
+            dims,
+            fit,
+            GrRenderable::kYes,
+            this->mipMapped(),
+            this->numSamples(),
+            this->backendFormat(),
+            this->isProtected(),
+            this->isBudgeted(),
+    };
+}
+
 #ifdef SK_DEBUG
 void GrTextureRenderTargetProxy::onValidateSurface(const GrSurface* surface) {
     // Anything checked here should also be checking the GrTextureProxy version
diff --git a/src/gpu/GrTextureRenderTargetProxy.h b/src/gpu/GrTextureRenderTargetProxy.h
index bd52d80..585f60c 100644
--- a/src/gpu/GrTextureRenderTargetProxy.h
+++ b/src/gpu/GrTextureRenderTargetProxy.h
@@ -64,7 +64,7 @@
     sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
 
     size_t onUninstantiatedGpuMemorySize(const GrCaps&) const override;
-
+    LazySurfaceDesc callbackDesc() const override;
     SkDEBUGCODE(void onValidateSurface(const GrSurface*) override;)
 };
 
diff --git a/src/gpu/ccpr/GrCCAtlas.h b/src/gpu/ccpr/GrCCAtlas.h
index f37910d..f20ef3f 100644
--- a/src/gpu/ccpr/GrCCAtlas.h
+++ b/src/gpu/ccpr/GrCCAtlas.h
@@ -68,13 +68,15 @@
                 : GrCCPathProcessor::CoverageMode::kLiteral;
     }
 
-
-    static sk_sp<GrTextureProxy> MakeLazyAtlasProxy(const LazyInstantiateAtlasCallback& callback,
-                                                    CoverageType coverageType, const GrCaps& caps,
+    static sk_sp<GrTextureProxy> MakeLazyAtlasProxy(LazyInstantiateAtlasCallback&& callback,
+                                                    CoverageType coverageType,
+                                                    const GrCaps& caps,
                                                     GrSurfaceProxy::UseAllocator useAllocator) {
-        return GrDynamicAtlas::MakeLazyAtlasProxy(callback, CoverageTypeToColorType(coverageType),
+        return GrDynamicAtlas::MakeLazyAtlasProxy(std::move(callback),
+                                                  CoverageTypeToColorType(coverageType),
                                                   CoverageTypeHasInternalMultisample(coverageType),
-                                                  caps, useAllocator);
+                                                  caps,
+                                                  useAllocator);
     }
 
     GrCCAtlas(CoverageType, const Specs&, const GrCaps&);
diff --git a/src/gpu/ccpr/GrCCClipPath.cpp b/src/gpu/ccpr/GrCCClipPath.cpp
index 20368e6..b2a2c07 100644
--- a/src/gpu/ccpr/GrCCClipPath.cpp
+++ b/src/gpu/ccpr/GrCCClipPath.cpp
@@ -19,8 +19,7 @@
     SkASSERT(!this->isInitialized());
 
     fAtlasLazyProxy = GrCCAtlas::MakeLazyAtlasProxy(
-            [this](GrResourceProvider* resourceProvider, const GrBackendFormat& format,
-                   int sampleCount) {
+            [this](GrResourceProvider* resourceProvider, const GrCCAtlas::LazyAtlasDesc& desc) {
                 SkASSERT(fHasAtlas);
                 SkASSERT(!fHasAtlasTransform);
 
@@ -34,8 +33,6 @@
 
                 sk_sp<GrTexture> texture = sk_ref_sp(textureProxy->peekTexture());
                 SkASSERT(texture);
-                SkASSERT(texture->backendFormat() == format);
-                SkASSERT(texture->asRenderTarget()->numSamples() == sampleCount);
 
                 fAtlasScale = {1.f / texture->width(), 1.f / texture->height()};
                 fAtlasTranslate.set(fDevToAtlasOffset.fX * fAtlasScale.x(),
diff --git a/src/gpu/ccpr/GrCCClipPath.h b/src/gpu/ccpr/GrCCClipPath.h
index 32e5ae4..0f3fef2 100644
--- a/src/gpu/ccpr/GrCCClipPath.h
+++ b/src/gpu/ccpr/GrCCClipPath.h
@@ -37,8 +37,10 @@
     }
 
     bool isInitialized() const { return fAtlasLazyProxy != nullptr; }
-    void init(const SkPath& deviceSpacePath, const SkIRect& accessRect,
-              GrCCAtlas::CoverageType atlasCoverageType, const GrCaps&);
+    void init(const SkPath& deviceSpacePath,
+              const SkIRect& desc,
+              GrCCAtlas::CoverageType atlasCoverageType,
+              const GrCaps&);
 
     void addAccess(const SkIRect& accessRect) {
         SkASSERT(this->isInitialized());
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index ced41b0..e156e4e 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -402,7 +402,8 @@
             }
         }
 
-        GrSurfaceProxy::LazyCallbackResult operator()(GrResourceProvider* resourceProvider) {
+        GrSurfaceProxy::LazyCallbackResult operator()(GrResourceProvider* resourceProvider,
+                                                      const GrSurfaceProxy::LazySurfaceDesc&) {
             // We use the unique key in a way that is unrelated to the SkImage-based key that the
             // proxy may receive, hence kUnsynced.
             static constexpr auto kKeySyncMode =
diff --git a/src/image/SkSurface_GpuMtl.mm b/src/image/SkSurface_GpuMtl.mm
index 6c74adf..b560235 100644
--- a/src/image/SkSurface_GpuMtl.mm
+++ b/src/image/SkSurface_GpuMtl.mm
@@ -50,23 +50,22 @@
     texInfo.fTextureType = GrTextureType::k2D;
 
     sk_sp<GrRenderTargetProxy> proxy = proxyProvider->createLazyRenderTargetProxy(
-            [layer, drawable, sampleCnt](GrResourceProvider* resourceProvider) {
+            [layer, drawable](GrResourceProvider* resourceProvider,
+                              const GrSurfaceProxy::LazySurfaceDesc& desc) {
                 CAMetalLayer* metalLayer = (__bridge CAMetalLayer*)layer;
                 id<CAMetalDrawable> currentDrawable = [metalLayer nextDrawable];
 
-                SkISize dims = {(int)metalLayer.drawableSize.width,
-                                (int)metalLayer.drawableSize.height};
-
                 GrMtlGpu* mtlGpu = (GrMtlGpu*) resourceProvider->priv().gpu();
                 sk_sp<GrRenderTarget> surface;
                 if (metalLayer.framebufferOnly) {
-                    surface = GrMtlRenderTarget::MakeWrappedRenderTarget(mtlGpu, dims, sampleCnt,
-                                                                         currentDrawable.texture);
+                    surface = GrMtlRenderTarget::MakeWrappedRenderTarget(
+                            mtlGpu, desc.fDimensions, desc.fSampleCnt, currentDrawable.texture);
                 } else {
                     surface = GrMtlTextureRenderTarget::MakeWrappedTextureRenderTarget(
-                            mtlGpu, dims, sampleCnt, currentDrawable.texture, GrWrapCacheable::kNo);
+                            mtlGpu, desc.fDimensions, desc.fSampleCnt, currentDrawable.texture,
+                            GrWrapCacheable::kNo);
                 }
-                if (surface && sampleCnt > 1) {
+                if (surface && desc.fSampleCnt > 1) {
                     surface->setRequiresManualMSAAResolve();
                 }
 
@@ -122,22 +121,22 @@
     texInfo.fTextureType = GrTextureType::k2D;
 
     sk_sp<GrRenderTargetProxy> proxy = proxyProvider->createLazyRenderTargetProxy(
-            [view, sampleCnt](GrResourceProvider* resourceProvider) {
+            [view](GrResourceProvider* resourceProvider,
+                   const GrSurfaceProxy::LazySurfaceDesc& desc) {
                 MTKView* mtkView = (__bridge MTKView*)view;
                 id<CAMetalDrawable> currentDrawable = [mtkView currentDrawable];
 
-                SkISize dims = {(int)mtkView.drawableSize.width, (int)mtkView.drawableSize.height};
-
                 GrMtlGpu* mtlGpu = (GrMtlGpu*) resourceProvider->priv().gpu();
                 sk_sp<GrRenderTarget> surface;
                 if (mtkView.framebufferOnly) {
-                    surface = GrMtlRenderTarget::MakeWrappedRenderTarget(mtlGpu, dims, sampleCnt,
-                                                                         currentDrawable.texture);
+                    surface = GrMtlRenderTarget::MakeWrappedRenderTarget(
+                            mtlGpu, desc.fDimensions, desc.fSampleCnt, currentDrawable.texture);
                 } else {
                     surface = GrMtlTextureRenderTarget::MakeWrappedTextureRenderTarget(
-                            mtlGpu, dims, sampleCnt, currentDrawable.texture, GrWrapCacheable::kNo);
+                            mtlGpu, desc.fDimensions, desc.fSampleCnt, currentDrawable.texture,
+                            GrWrapCacheable::kNo);
                 }
-                if (surface && sampleCnt > 1) {
+                if (surface && desc.fSampleCnt > 1) {
                     surface->setRequiresManualMSAAResolve();
                 }