Remove outputSwizzle from GrRenderTargetProxy.

Bug: skia:9556
Change-Id: Icbcc56c0eb0d0de0886874e0ed8c3f03c7318d02
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/249883
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index ee7c1cd..d75b464 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -919,8 +919,10 @@
     sk_sp<GrRenderTargetProxy> renderTargetProxy(sk_ref_sp(sProxy->asRenderTargetProxy()));
 
     GrSurfaceOrigin origin = renderTargetProxy->origin();
-    GrSwizzle texSwizzle = renderTargetProxy->textureSwizzle();
-    GrSwizzle outSwizzle = renderTargetProxy->outputSwizzle();
+    GrSwizzle texSwizzle = fContext->priv().caps()->getTextureSwizzle(sProxy->backendFormat(),
+                                                                      colorType);
+    GrSwizzle outSwizzle = fContext->priv().caps()->getOutputSwizzle(sProxy->backendFormat(),
+                                                                     colorType);
 
     return std::unique_ptr<GrRenderTargetContext>(
             new GrRenderTargetContext(fContext,
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index 33dd09d..ba2f7e9 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -198,9 +198,8 @@
     GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(tex->backendFormat(), colorType);
 
     if (tex->asRenderTarget()) {
-        GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(tex->backendFormat(), colorType);
         return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(
-                std::move(tex), origin, texSwizzle, outSwizzle, useAllocator));
+                std::move(tex), origin, texSwizzle, useAllocator));
     } else {
         return sk_sp<GrTextureProxy>(
                 new GrTextureProxy(std::move(tex), origin, texSwizzle, useAllocator));
@@ -473,10 +472,9 @@
         SkASSERT(renderTargetSampleCnt);
         // We know anything we instantiate later from this deferred path will be
         // both texturable and renderable
-        GrSwizzle outSwizzle = caps->getOutputSwizzle(format, colorType);
         return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(
                 *caps, format, copyDesc, renderTargetSampleCnt, origin, mipMapped, mipMapsStatus,
-                texSwizzle, outSwizzle, fit, budgeted, isProtected, surfaceFlags, useAllocator));
+                texSwizzle, fit, budgeted, isProtected, surfaceFlags, useAllocator));
     }
 
     return sk_sp<GrTextureProxy>(new GrTextureProxy(format, copyDesc, origin, mipMapped,
@@ -611,10 +609,9 @@
     SkASSERT(GrBudgetedType::kBudgeted != tex->resourcePriv().budgetedType());
 
     GrSwizzle texSwizzle = caps->getTextureSwizzle(tex->backendFormat(), colorType);
-    GrSwizzle outSwizzle = caps->getOutputSwizzle(tex->backendFormat(), colorType);
 
     return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(std::move(tex), origin, texSwizzle,
-                                                                outSwizzle, UseAllocator::kNo));
+                                                                UseAllocator::kNo));
 }
 
 sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendRenderTarget(
@@ -649,10 +646,9 @@
     SkASSERT(GrBudgetedType::kBudgeted != rt->resourcePriv().budgetedType());
 
     GrSwizzle texSwizzle = caps->getTextureSwizzle(rt->backendFormat(), grColorType);
-    GrSwizzle outSwizzle = caps->getOutputSwizzle(rt->backendFormat(), grColorType);
 
     return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(std::move(rt), origin, texSwizzle,
-                                                              outSwizzle, UseAllocator::kNo));
+                                                              UseAllocator::kNo));
 }
 
 sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendTextureAsRenderTarget(
@@ -683,10 +679,9 @@
     SkASSERT(GrBudgetedType::kBudgeted != rt->resourcePriv().budgetedType());
 
     GrSwizzle texSwizzle = caps->getTextureSwizzle(rt->backendFormat(), grColorType);
-    GrSwizzle outSwizzle = caps->getOutputSwizzle(rt->backendFormat(), grColorType);
 
     return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(rt), origin, texSwizzle,
-                                                         outSwizzle, UseAllocator::kNo));
+                                                         UseAllocator::kNo));
 }
 
 sk_sp<GrRenderTargetProxy> GrProxyProvider::wrapVulkanSecondaryCBAsRenderTarget(
@@ -716,7 +711,6 @@
 
     GrColorType colorType = SkColorTypeToGrColorType(imageInfo.colorType());
     GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(rt->backendFormat(), colorType);
-    GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(rt->backendFormat(), colorType);
 
     if (!this->caps()->isFormatAsColorTypeRenderable(colorType, rt->backendFormat(),
                                                      rt->numSamples())) {
@@ -725,7 +719,7 @@
 
     // All Vulkan surfaces uses top left origins.
     return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(
-            std::move(rt), kTopLeft_GrSurfaceOrigin, texSwizzle, outSwizzle, UseAllocator::kNo,
+            std::move(rt), kTopLeft_GrSurfaceOrigin, texSwizzle, UseAllocator::kNo,
             GrRenderTargetProxy::WrapsVkSecondaryCB::kYes));
 }
 
@@ -756,7 +750,6 @@
 
     GrColorType colorType = GrPixelConfigToColorType(desc.fConfig);
     GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(format, colorType);
-    GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(format, colorType);
 
     if (renderable == GrRenderable::kYes) {
         return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(*this->caps(),
@@ -768,7 +761,6 @@
                                                                     mipMapped,
                                                                     mipMapsStatus,
                                                                     texSwizzle,
-                                                                    outSwizzle,
                                                                     fit,
                                                                     budgeted,
                                                                     isProtected,
@@ -814,7 +806,6 @@
 
     GrColorType colorType = GrPixelConfigToColorType(desc.fConfig);
     GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(format, colorType);
-    GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(format, colorType);
 
     if (textureInfo) {
         // Wrapped vulkan secondary command buffers don't support texturing since we won't have an
@@ -822,8 +813,8 @@
         SkASSERT(!wrapsVkSecondaryCB);
         return sk_sp<GrRenderTargetProxy>(new GrTextureRenderTargetProxy(
                 *this->caps(), std::move(callback), format, desc, sampleCnt, origin,
-                textureInfo->fMipMapped, mipMapsStatus, texSwizzle, outSwizzle, fit, budgeted,
-                isProtected, surfaceFlags, useAllocator));
+                textureInfo->fMipMapped, mipMapsStatus, texSwizzle, fit, budgeted, isProtected,
+                surfaceFlags, useAllocator));
     }
 
     GrRenderTargetProxy::WrapsVkSecondaryCB vkSCB =
@@ -831,8 +822,8 @@
                                : GrRenderTargetProxy::WrapsVkSecondaryCB::kNo;
 
     return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(
-            std::move(callback), format, desc, sampleCnt, origin, texSwizzle, outSwizzle, fit,
-            budgeted, isProtected, surfaceFlags, useAllocator, vkSCB));
+            std::move(callback), format, desc, sampleCnt, origin, texSwizzle, fit, budgeted,
+            isProtected, surfaceFlags, useAllocator, vkSCB));
 }
 
 sk_sp<GrTextureProxy> GrProxyProvider::MakeFullyLazyProxy(LazyInstantiateCallback&& callback,
@@ -857,13 +848,12 @@
 
     GrColorType colorType = GrPixelConfigToColorType(desc.fConfig);
     GrSwizzle texSwizzle = caps.getTextureSwizzle(format, colorType);
-    GrSwizzle outSwizzle = caps.getOutputSwizzle(format, colorType);
 
     if (GrRenderable::kYes == renderable) {
         return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(
                 caps, std::move(callback), format, desc, renderTargetSampleCnt, origin,
-                GrMipMapped::kNo, GrMipMapsStatus::kNotAllocated, texSwizzle, outSwizzle,
-                SkBackingFit::kApprox, SkBudgeted::kYes, isProtected, surfaceFlags, useAllocator));
+                GrMipMapped::kNo, GrMipMapsStatus::kNotAllocated, texSwizzle, SkBackingFit::kApprox,
+                SkBudgeted::kYes, isProtected, surfaceFlags, useAllocator));
     } else {
         return sk_sp<GrTextureProxy>(new GrTextureProxy(
                 std::move(callback), format, desc, origin, GrMipMapped::kNo,
diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp
index c3c92e8..fa7f669 100644
--- a/src/gpu/GrRenderTargetProxy.cpp
+++ b/src/gpu/GrRenderTargetProxy.cpp
@@ -27,7 +27,6 @@
                                          int sampleCount,
                                          GrSurfaceOrigin origin,
                                          const GrSwizzle& textureSwizzle,
-                                         const GrSwizzle& outputSwizzle,
                                          SkBackingFit fit,
                                          SkBudgeted budgeted,
                                          GrProtected isProtected,
@@ -36,8 +35,7 @@
         : INHERITED(format, desc, GrRenderable::kYes, origin, textureSwizzle, fit, budgeted,
                     isProtected, surfaceFlags, useAllocator)
         , fSampleCnt(sampleCount)
-        , fWrapsVkSecondaryCB(WrapsVkSecondaryCB::kNo)
-        , fOutputSwizzle(outputSwizzle) {}
+        , fWrapsVkSecondaryCB(WrapsVkSecondaryCB::kNo) {}
 
 // Lazy-callback version
 GrRenderTargetProxy::GrRenderTargetProxy(LazyInstantiateCallback&& callback,
@@ -46,7 +44,6 @@
                                          int sampleCount,
                                          GrSurfaceOrigin origin,
                                          const GrSwizzle& textureSwizzle,
-                                         const GrSwizzle& outputSwizzle,
                                          SkBackingFit fit,
                                          SkBudgeted budgeted,
                                          GrProtected isProtected,
@@ -56,20 +53,17 @@
         : INHERITED(std::move(callback), format, desc, GrRenderable::kYes, origin, textureSwizzle,
                     fit, budgeted, isProtected, surfaceFlags, useAllocator)
         , fSampleCnt(sampleCount)
-        , fWrapsVkSecondaryCB(wrapsVkSecondaryCB)
-        , fOutputSwizzle(outputSwizzle) {}
+        , fWrapsVkSecondaryCB(wrapsVkSecondaryCB) {}
 
 // Wrapped version
 GrRenderTargetProxy::GrRenderTargetProxy(sk_sp<GrSurface> surf,
                                          GrSurfaceOrigin origin,
                                          const GrSwizzle& textureSwizzle,
-                                         const GrSwizzle& outputSwizzle,
                                          UseAllocator useAllocator,
                                          WrapsVkSecondaryCB wrapsVkSecondaryCB)
         : INHERITED(std::move(surf), origin, textureSwizzle, SkBackingFit::kExact, useAllocator)
         , fSampleCnt(fTarget->asRenderTarget()->numSamples())
-        , fWrapsVkSecondaryCB(wrapsVkSecondaryCB)
-        , fOutputSwizzle(outputSwizzle) {
+        , fWrapsVkSecondaryCB(wrapsVkSecondaryCB) {
     // The kRequiresManualMSAAResolve flag better not be set if we are not multisampled or if
     // MSAA resolve should happen automatically.
     //
diff --git a/src/gpu/GrRenderTargetProxy.h b/src/gpu/GrRenderTargetProxy.h
index 944fe81..a234a4d 100644
--- a/src/gpu/GrRenderTargetProxy.h
+++ b/src/gpu/GrRenderTargetProxy.h
@@ -59,8 +59,6 @@
 
     int maxWindowRectangles(const GrCaps& caps) const;
 
-    const GrSwizzle& outputSwizzle() const { return fOutputSwizzle; }
-
     bool wrapsVkSecondaryCB() const { return fWrapsVkSecondaryCB == WrapsVkSecondaryCB::kYes; }
 
     void markMSAADirty(const SkIRect& dirtyRect) {
@@ -99,7 +97,6 @@
                         int sampleCount,
                         GrSurfaceOrigin,
                         const GrSwizzle& textureSwizzle,
-                        const GrSwizzle& outputSwizzle,
                         SkBackingFit,
                         SkBudgeted,
                         GrProtected,
@@ -124,7 +121,6 @@
                         int sampleCount,
                         GrSurfaceOrigin,
                         const GrSwizzle& textureSwizzle,
-                        const GrSwizzle& outputSwizzle,
                         SkBackingFit,
                         SkBudgeted,
                         GrProtected,
@@ -136,7 +132,6 @@
     GrRenderTargetProxy(sk_sp<GrSurface>,
                         GrSurfaceOrigin,
                         const GrSwizzle& textureSwizzle,
-                        const GrSwizzle& outputSwizzle,
                         UseAllocator,
                         WrapsVkSecondaryCB = WrapsVkSecondaryCB::kNo);
 
@@ -164,14 +159,14 @@
     int8_t             fSampleCnt;
     int8_t             fNumStencilSamples = 0;
     WrapsVkSecondaryCB fWrapsVkSecondaryCB;
-    GrSwizzle          fOutputSwizzle;
     SkIRect            fMSAADirtyRect = SkIRect::MakeEmpty();
-    // This is to fix issue in large comment above. Without the padding we end 6 bytes into a 16
-    // byte range, so the GrTextureProxy ends up starting 8 byte aligned by not 16. We add the
-    // padding here to get us right up to the 16 byte alignment (technically any padding of 3-10
-    // bytes would work since it always goes up to 8 byte alignment, but we use 10 to more explicit
-    // about what we're doing).
-    char               fDummyPadding[10];
+    // This is to fix issue in large comment above. Without the padding we can end up with the
+    // GrTextureProxy starting 8 byte aligned by not 16. This happens when the RT ends at bytes 1-8.
+    // Note: with the virtual inheritance an 8 byte pointer is at the start of GrRenderTargetProxy.
+    //
+    // In the current world we end the RT proxy at 12 bytes. Technically any padding between 0-4
+    // will work, but we use 4 to be more explicit about getting it to 16 byte alignment.
+    char               fDummyPadding[4];
 
     typedef GrSurfaceProxy INHERITED;
 };
diff --git a/src/gpu/GrTextureRenderTargetProxy.cpp b/src/gpu/GrTextureRenderTargetProxy.cpp
index 0c1a2cc..1e3addd 100644
--- a/src/gpu/GrTextureRenderTargetProxy.cpp
+++ b/src/gpu/GrTextureRenderTargetProxy.cpp
@@ -28,7 +28,6 @@
                                                        GrMipMapped mipMapped,
                                                        GrMipMapsStatus mipMapsStatus,
                                                        const GrSwizzle& texSwizzle,
-                                                       const GrSwizzle& outSwizzle,
                                                        SkBackingFit fit,
                                                        SkBudgeted budgeted,
                                                        GrProtected isProtected,
@@ -37,8 +36,8 @@
         : GrSurfaceProxy(format, desc, GrRenderable::kYes, origin, texSwizzle, fit, budgeted,
                          isProtected, surfaceFlags, useAllocator)
         // for now textures w/ data are always wrapped
-        , GrRenderTargetProxy(caps, format, desc, sampleCnt, origin, texSwizzle, outSwizzle, fit,
-                              budgeted, isProtected, surfaceFlags, useAllocator)
+        , GrRenderTargetProxy(caps, format, desc, sampleCnt, origin, texSwizzle, fit, budgeted,
+                              isProtected, surfaceFlags, useAllocator)
         , GrTextureProxy(format, desc, origin, mipMapped, mipMapsStatus, texSwizzle, fit, budgeted,
                          isProtected, surfaceFlags, useAllocator) {
     this->initSurfaceFlags(caps);
@@ -54,7 +53,6 @@
                                                        GrMipMapped mipMapped,
                                                        GrMipMapsStatus mipMapsStatus,
                                                        const GrSwizzle& texSwizzle,
-                                                       const GrSwizzle& outSwizzle,
                                                        SkBackingFit fit,
                                                        SkBudgeted budgeted,
                                                        GrProtected isProtected,
@@ -65,8 +63,8 @@
         // Since we have virtual inheritance, we initialize GrSurfaceProxy directly. Send null
         // callbacks to the texture and RT proxies simply to route to the appropriate constructors.
         , GrRenderTargetProxy(LazyInstantiateCallback(), format, desc, sampleCnt, origin,
-                              texSwizzle, outSwizzle, fit, budgeted, isProtected, surfaceFlags,
-                              useAllocator, WrapsVkSecondaryCB::kNo)
+                              texSwizzle, fit, budgeted, isProtected, surfaceFlags, useAllocator,
+                              WrapsVkSecondaryCB::kNo)
         , GrTextureProxy(LazyInstantiateCallback(), format, desc, origin, mipMapped, mipMapsStatus,
                          texSwizzle, fit, budgeted, isProtected, surfaceFlags, useAllocator) {
     this->initSurfaceFlags(caps);
@@ -78,10 +76,9 @@
 GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(sk_sp<GrSurface> surf,
                                                        GrSurfaceOrigin origin,
                                                        const GrSwizzle& texSwizzle,
-                                                       const GrSwizzle& outSwizzle,
                                                        UseAllocator useAllocator)
         : GrSurfaceProxy(surf, origin, texSwizzle, SkBackingFit::kExact, useAllocator)
-        , GrRenderTargetProxy(surf, origin, texSwizzle, outSwizzle, useAllocator)
+        , GrRenderTargetProxy(surf, origin, texSwizzle, useAllocator)
         , GrTextureProxy(surf, origin, texSwizzle, useAllocator) {
     SkASSERT(surf->asTexture());
     SkASSERT(surf->asRenderTarget());
diff --git a/src/gpu/GrTextureRenderTargetProxy.h b/src/gpu/GrTextureRenderTargetProxy.h
index 46c273d..68e68f7 100644
--- a/src/gpu/GrTextureRenderTargetProxy.h
+++ b/src/gpu/GrTextureRenderTargetProxy.h
@@ -36,7 +36,6 @@
                                GrMipMapped,
                                GrMipMapsStatus,
                                const GrSwizzle& textureSwizzle,
-                               const GrSwizzle& outputSwizzle,
                                SkBackingFit,
                                SkBudgeted,
                                GrProtected,
@@ -53,7 +52,6 @@
                                GrMipMapped,
                                GrMipMapsStatus,
                                const GrSwizzle& textureSwizzle,
-                               const GrSwizzle& outputSwizzle,
                                SkBackingFit,
                                SkBudgeted,
                                GrProtected,
@@ -64,7 +62,6 @@
     GrTextureRenderTargetProxy(sk_sp<GrSurface>,
                                GrSurfaceOrigin,
                                const GrSwizzle& textureSwizzle,
-                               const GrSwizzle& outputSwizzle,
                                UseAllocator);
 
     void initSurfaceFlags(const GrCaps&);