Second small fragment from "Reduce dependence on GrSurface's origin field"

TBR=bsalomon@google.com
Change-Id: Ifcfe56b1117b64821b2bfc34ba36d120227d15fa
Reviewed-on: https://skia-review.googlesource.com/25802
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/core/SkColorSpaceXformImageGenerator.cpp b/src/core/SkColorSpaceXformImageGenerator.cpp
index 707de08..5cd1d1d 100644
--- a/src/core/SkColorSpaceXformImageGenerator.cpp
+++ b/src/core/SkColorSpaceXformImageGenerator.cpp
@@ -86,7 +86,8 @@
     }
 
     sk_sp<GrRenderTargetContext> renderTargetContext = ctx->makeDeferredRenderTargetContext(
-            SkBackingFit::kExact, fSrc.width(), fSrc.height(), kRGBA_8888_GrPixelConfig, nullptr);
+            SkBackingFit::kExact, fSrc.width(), fSrc.height(), kRGBA_8888_GrPixelConfig, nullptr,
+            0, kTopLeft_GrSurfaceOrigin);
     if (!renderTargetContext) {
         return nullptr;
     }
diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp
index 1f60380..7586132 100644
--- a/src/core/SkPictureImageGenerator.cpp
+++ b/src/core/SkPictureImageGenerator.cpp
@@ -110,7 +110,8 @@
     // TODO: respect the usage, by possibly creating a different (pow2) surface
     //
     SkImageInfo surfaceInfo = useXformCanvas ? info.makeColorSpace(nullptr) : info;
-    sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kYes, surfaceInfo));
+    sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kYes, surfaceInfo,
+                                                         0, kTopLeft_GrSurfaceOrigin, nullptr));
     if (!surface) {
         return nullptr;
     }
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index 44155a8..b553cc4 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -53,6 +53,8 @@
     void assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy*);
 
     /** Finds a texture by unique key. If the texture is found it is ref'ed and returned. */
+    // MDB TODO (caching): If this were actually caching proxies (rather than shallowly 
+    // wrapping GrSurface caching) we would not need the origin parameter.
     sk_sp<GrTextureProxy> findProxyByUniqueKey(const GrUniqueKey& key);
 
     /**
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index e171b78..2199529 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -217,6 +217,7 @@
             return false;
         }
         if (useCache) {
+            SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
             fResourceProvider->assignUniqueKeyToProxy(maskKey, proxy.get());
         }
     }
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index 276dc10..78d143b 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -24,7 +24,8 @@
     const SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
 
     sk_sp<GrRenderTargetContext> copyRTC = context->makeDeferredRenderTargetContextWithFallback(
-        SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(), nullptr);
+        SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(), nullptr,
+        0, inputProxy->origin());
     if (!copyRTC) {
         return nullptr;
     }
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 341b711..12390aa 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -124,10 +124,11 @@
 
     // We never want to perform color-space conversion during the decode
     sk_sp<GrRenderTargetContext> renderTargetContext(ctx->makeDeferredRenderTargetContext(
-                                                                          SkBackingFit::kExact,
-                                                                          desc.fWidth, desc.fHeight,
-                                                                          desc.fConfig, nullptr,
-                                                                          desc.fSampleCnt));
+                                                                    SkBackingFit::kExact,
+                                                                    desc.fWidth, desc.fHeight,
+                                                                    desc.fConfig, nullptr,
+                                                                    desc.fSampleCnt,
+                                                                    kTopLeft_GrSurfaceOrigin));
     if (!renderTargetContext) {
         return nullptr;
     }
diff --git a/src/gpu/ccpr/GrCCPRPathProcessor.cpp b/src/gpu/ccpr/GrCCPRPathProcessor.cpp
index bc2e45c..6efaecf 100644
--- a/src/gpu/ccpr/GrCCPRPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRPathProcessor.cpp
@@ -86,7 +86,7 @@
 }
 
 void GrCCPRPathProcessor::getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const {
-    b->add32((fFillType << 16) | this->atlas()->origin());
+    b->add32((fFillType << 16) | this->atlasProxy()->origin());
 }
 
 class GLSLPathProcessor : public GrGLSLGeometryProcessor {
@@ -161,10 +161,10 @@
     // Convert to atlas coordinates in order to do our texture lookup.
     v->codeAppendf("highp vec2 atlascoord = octocoord + vec2(%s);",
                    proc.getInstanceAttrib(InstanceAttribs::kAtlasOffset).fName);
-    if (kTopLeft_GrSurfaceOrigin == proc.atlas()->origin()) {
+    if (kTopLeft_GrSurfaceOrigin == proc.atlasProxy()->origin()) {
         v->codeAppendf("%s = atlascoord * %s;", texcoord.vsOut(), atlasAdjust);
     } else {
-        SkASSERT(kBottomLeft_GrSurfaceOrigin == proc.atlas()->origin());
+        SkASSERT(kBottomLeft_GrSurfaceOrigin == proc.atlasProxy()->origin());
         v->codeAppendf("%s = vec2(atlascoord.x * %s.x, 1 - atlascoord.y * %s.y);",
                        texcoord.vsOut(), atlasAdjust, atlasAdjust);
     }
diff --git a/src/gpu/ccpr/GrCCPRPathProcessor.h b/src/gpu/ccpr/GrCCPRPathProcessor.h
index a74455b..dbc1e58 100644
--- a/src/gpu/ccpr/GrCCPRPathProcessor.h
+++ b/src/gpu/ccpr/GrCCPRPathProcessor.h
@@ -58,6 +58,7 @@
                        const GrShaderCaps&);
 
     const char* name() const override { return "GrCCPRPathProcessor"; }
+    const GrSurfaceProxy* atlasProxy() const { return fAtlasAccess.proxy(); }
     const GrTexture* atlas() const { return fAtlasAccess.peekTexture(); }
     SkPath::FillType fillType() const { return fFillType; }
     const Attribute& getInstanceAttrib(InstanceAttribs attribID) const {
diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp
index 72817b2..d0c6e47 100644
--- a/src/gpu/effects/GrTextureStripAtlas.cpp
+++ b/src/gpu/effects/GrTextureStripAtlas.cpp
@@ -193,11 +193,6 @@
 }
 
 void GrTextureStripAtlas::lockTexture() {
-    GrSurfaceDesc texDesc;
-    texDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
-    texDesc.fWidth = fDesc.fWidth;
-    texDesc.fHeight = fDesc.fHeight;
-    texDesc.fConfig = fDesc.fConfig;
 
     static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
     GrUniqueKey key;
@@ -207,6 +202,12 @@
 
     sk_sp<GrTextureProxy> proxy = fDesc.fContext->resourceProvider()->findProxyByUniqueKey(key);
     if (!proxy) {
+        GrSurfaceDesc texDesc;
+        texDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
+        texDesc.fWidth  = fDesc.fWidth;
+        texDesc.fHeight = fDesc.fHeight;
+        texDesc.fConfig = fDesc.fConfig;
+
         proxy = GrSurfaceProxy::MakeDeferred(fDesc.fContext->resourceProvider(),
                                              texDesc, SkBackingFit::kExact,
                                              SkBudgeted::kYes,
@@ -215,6 +216,7 @@
             return;
         }
 
+        SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
         fDesc.fContext->resourceProvider()->assignUniqueKeyToProxy(key, proxy.get());
         // This is a new texture, so all of our cache info is now invalid
         this->initLRU();