Revert "New variant of SkImage::MakeFromYUVATextures."

This reverts commit fea12238ed9643f3f6d826681c7d1e3031c6ffe5.

Reason for revert: MSAN/SwiftShader failure

Original change's description:
> New variant of SkImage::MakeFromYUVATextures.
>
> Takes a new type GrYUVATextures. This a set of GrBackendTextures and
> SkYUVAInfo that have been pre-validated to be compatible.
>
> Bug: skia:10632
>
> Change-Id: Id252f8662ede0f268e88fd40dc1b0b8f4ab6345f
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317762
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Jim Van Verth <jvanverth@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

TBR=jvanverth@google.com,bsalomon@google.com,robertphillips@google.com

Change-Id: I5350d4f9b1eda0503fb0af9db8575a734bdc811f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10632
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/327922
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index e5209ec..a019c11 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -6,12 +6,8 @@
 
 Milestone 88
 ------------
-  * <insert new release notes here>
 
-  * New variant of SkImage::MakeFromYUVATextures. Takes a new type GrYUVATextures
-    which wraps an SkYUVAInfo and compatible set of GrBackendTextures. The provides
-    a more complete and structured specification of the planar configuration. Previous
-    version is deprecated.
+  * <insert new release notes here>
 
   * SkTPin() removed from public API.
 
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 6c494a2..63acc5f 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -19,7 +19,6 @@
   "$_include/gpu/GrDriverBugWorkarounds.h",
   "$_include/gpu/GrRecordingContext.h",
   "$_include/gpu/GrTypes.h",
-  "$_include/gpu/GrYUVABackendTextures.h",
 
   # Private includes
   "$_include/private/GrContext.h",
@@ -270,7 +269,6 @@
   "$_src/gpu/GrWindowRectsState.h",
   "$_src/gpu/GrXferProcessor.cpp",
   "$_src/gpu/GrXferProcessor.h",
-  "$_src/gpu/GrYUVABackendTextures.cpp",
 
   # Ops
   "$_src/gpu/effects/GrBezierEffect.cpp",
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 3f63a1b..990d37c 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -38,7 +38,6 @@
 class GrDirectContext;
 class GrRecordingContext;
 class GrContextThreadSafeProxy;
-class GrYUVABackendTextures;
 
 struct SkYUVAIndex;
 
@@ -409,30 +408,7 @@
                                                  SkAlphaType alphaType = kPremul_SkAlphaType,
                                                  sk_sp<SkColorSpace> colorSpace = nullptr);
 
-    /** Creates an SkImage from YUV[A] planar textures. This requires that the textures stay valid
-        for the lifetime of the image. The ReleaseContext can be used to know when it is safe to
-        either delete or overwrite the textures. If ReleaseProc is provided it is also called before
-        return on failure.
-
-        @param context            GPU context
-        @param yuvaTextures       A set of textures containing YUVA data and a description of the
-                                  data and transformation to RGBA.
-        @param imageColorSpace    range of colors of the resulting image after conversion to RGB;
-                                  may be nullptr
-        @param textureReleaseProc called when the backend textures can be released
-        @param releaseContext     state passed to textureReleaseProc
-        @return                   created SkImage, or nullptr
-    */
-    static sk_sp<SkImage> MakeFromYUVATextures(GrRecordingContext* context,
-                                               const GrYUVABackendTextures& yuvaTextures,
-                                               sk_sp<SkColorSpace> imageColorSpace = nullptr,
-                                               TextureReleaseProc textureReleaseProc = nullptr,
-                                               ReleaseContext releaseContext = nullptr);
-
-    /**
-        Deprecated. Use version that takes GrYUVABackendTextures.
-
-        Creates an SkImage by storing the specified YUVA planes into an image, to be rendered
+    /** Creates an SkImage by storing the specified YUVA planes into an image, to be rendered
         via multitexturing.
 
         When all the provided backend textures can be released 'textureReleaseProc' will be called
diff --git a/include/core/SkYUVAInfo.h b/include/core/SkYUVAInfo.h
index 0c0cb51..da94ef7 100644
--- a/include/core/SkYUVAInfo.h
+++ b/include/core/SkYUVAInfo.h
@@ -39,8 +39,6 @@
      * this expands.
      */
     enum class PlanarConfig {
-        kUnknown,
-
         kY_U_V_444,    ///< Plane 0: Y, Plane 1: U,  Plane 2: V
         kY_U_V_422,    ///< Plane 0: Y, Plane 1: U,  Plane 2: V
         kY_U_V_420,    ///< Plane 0: Y, Plane 1: U,  Plane 2: V
@@ -179,12 +177,10 @@
     bool operator==(const SkYUVAInfo& that) const;
     bool operator!=(const SkYUVAInfo& that) const { return !(*this == that); }
 
-    bool isValid() const { return fPlanarConfig != PlanarConfig::kUnknown; }
-
 private:
     SkISize fDimensions = {0, 0};
 
-    PlanarConfig fPlanarConfig = PlanarConfig::kUnknown;
+    PlanarConfig fPlanarConfig = PlanarConfig::kY_U_V_444;
 
     SkYUVColorSpace fYUVColorSpace = SkYUVColorSpace::kIdentity_SkYUVColorSpace;
 
@@ -200,8 +196,6 @@
 
 constexpr int SkYUVAInfo::NumPlanes(PlanarConfig planarConfig) {
     switch (planarConfig) {
-        case PlanarConfig::kUnknown:      return 0;
-
         case PlanarConfig::kY_U_V_444:    return 3;
         case PlanarConfig::kY_U_V_422:    return 3;
         case PlanarConfig::kY_U_V_420:    return 3;
@@ -229,9 +223,6 @@
 
 constexpr int SkYUVAInfo::NumChannelsInPlane(PlanarConfig config, int i) {
     switch (config) {
-        case PlanarConfig::kUnknown:
-            return 0;
-
         case SkYUVAInfo::PlanarConfig::kY_U_V_444:
         case SkYUVAInfo::PlanarConfig::kY_U_V_422:
         case SkYUVAInfo::PlanarConfig::kY_U_V_420:
diff --git a/include/gpu/GrYUVABackendTextures.h b/include/gpu/GrYUVABackendTextures.h
deleted file mode 100644
index 347d00d..0000000
--- a/include/gpu/GrYUVABackendTextures.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrYUVABackendTextures_DEFINED
-#define GrYUVABackendTextures_DEFINED
-
-#include "include/core/SkYUVAInfo.h"
-#include "include/gpu/GrBackendSurface.h"
-
-#include <tuple>
-
-struct SkYUVASizeInfo;
-struct SkYUVAIndex;
-
-/**
- * A set of GrBackendTextures that hold the planar data for a SkYUVAInfo.
- */
-class SK_API GrYUVABackendTextures {
-public:
-    GrYUVABackendTextures() = default;
-    GrYUVABackendTextures(const GrYUVABackendTextures&) = delete;
-    GrYUVABackendTextures(GrYUVABackendTextures&&) = default;
-
-    GrYUVABackendTextures& operator=(const GrYUVABackendTextures&) = delete;
-    GrYUVABackendTextures& operator=(GrYUVABackendTextures&&) = default;
-
-    GrYUVABackendTextures(const SkYUVAInfo&,
-                          const GrBackendTexture[SkYUVAInfo::kMaxPlanes],
-                          GrSurfaceOrigin textureOrigin);
-
-    const std::array<GrBackendTexture, SkYUVAInfo::kMaxPlanes>& textures() const {
-        return fTextures;
-    }
-
-    GrBackendTexture texture(int i) const {
-        SkASSERT(i >= 0 && i < SkYUVAInfo::kMaxPlanes);
-        return fTextures[static_cast<size_t>(i)];
-    }
-
-    const SkYUVAInfo& yuvaInfo() const { return fYUVAInfo; }
-
-    int numPlanes() const { return fYUVAInfo.numPlanes(); }
-
-    GrSurfaceOrigin textureOrigin() const { return fTextureOrigin; }
-
-    bool isValid() const { return fYUVAInfo.isValid(); }
-
-    bool toYUVAIndices(SkYUVAIndex[SkYUVAIndex::kIndexCount]) const;
-
-private:
-    SkYUVAInfo fYUVAInfo;
-    std::array<GrBackendTexture, SkYUVAInfo::kMaxPlanes> fTextures;
-    GrSurfaceOrigin fTextureOrigin = kTopLeft_GrSurfaceOrigin;
-};
-
-#endif
diff --git a/src/core/SkYUVAInfo.cpp b/src/core/SkYUVAInfo.cpp
index c504f69..07b7c82 100644
--- a/src/core/SkYUVAInfo.cpp
+++ b/src/core/SkYUVAInfo.cpp
@@ -11,7 +11,7 @@
 int SkYUVAInfo::PlaneDimensions(SkISize imageDimensions,
                                 PlanarConfig planarConfig,
                                 SkEncodedOrigin origin,
-                                SkISize planeDimensions[SkYUVAInfo::kMaxPlanes]) {
+                                SkISize* planeDimensions) {
     int w = imageDimensions.width();
     int h = imageDimensions.height();
     if (origin >= kLeftTop_SkEncodedOrigin) {
@@ -21,12 +21,6 @@
     auto down2 = [](int x) { return (x + 1)/2; };
     auto down4 = [](int x) { return (x + 3)/4; };
     switch (planarConfig) {
-        case PlanarConfig::kUnknown:
-            planeDimensions[0] =
-            planeDimensions[1] =
-            planeDimensions[2] =
-            planeDimensions[3] = {0, 0};
-            return 0;
         case PlanarConfig::kY_U_V_444:
             planeDimensions[0] = planeDimensions[1] = planeDimensions[2] = {w, h};
             planeDimensions[3] = {0, 0};
@@ -131,9 +125,6 @@
     struct Location {int plane, chanIdx;};
     const Location* locations = nullptr;
     switch (config) {
-        case PlanarConfig::kUnknown:
-            return false;
-
         case PlanarConfig::kY_U_V_444:
         case PlanarConfig::kY_U_V_422:
         case PlanarConfig::kY_U_V_420:
@@ -219,8 +210,6 @@
 
 bool SkYUVAInfo::HasAlpha(PlanarConfig planarConfig) {
     switch (planarConfig) {
-        case PlanarConfig::kUnknown:      return false;
-
         case PlanarConfig::kY_U_V_444:    return false;
         case PlanarConfig::kY_U_V_422:    return false;
         case PlanarConfig::kY_U_V_420:    return false;
@@ -258,20 +247,11 @@
     , fYUVColorSpace(yuvColorSpace)
     , fOrigin(origin)
     , fSitingX(sitingX)
-    , fSitingY(sitingY) {
-    if (fDimensions.width() <= 0 ||
-        fDimensions.height() <= 0 ||
-        planarConfig == PlanarConfig::kUnknown) {
-        *this = {};
-        SkASSERT(!this->isValid());
-        return;
-    }
-    SkASSERT(this->isValid());
-}
+    , fSitingY(sitingY) {}
 
 size_t SkYUVAInfo::computeTotalBytes(const size_t rowBytes[kMaxPlanes],
                                      size_t planeSizes[kMaxPlanes]) const {
-    if (!this->isValid()) {
+    if (fDimensions.isEmpty()) {
         return 0;
     }
     SkSafeMath safe;
diff --git a/src/core/SkYUVAPixmaps.cpp b/src/core/SkYUVAPixmaps.cpp
index 2ce4ba5..e840fc5 100644
--- a/src/core/SkYUVAPixmaps.cpp
+++ b/src/core/SkYUVAPixmaps.cpp
@@ -80,7 +80,7 @@
                                    const SkColorType colorTypes[kMaxPlanes],
                                    const size_t rowBytes[kMaxPlanes])
         : fYUVAInfo(yuvaInfo) {
-    if (!yuvaInfo.isValid()) {
+    if (yuvaInfo.dimensions().isEmpty()) {
         *this = {};
         SkASSERT(!this->isValid());
         return;
diff --git a/src/gpu/GrYUVABackendTextures.cpp b/src/gpu/GrYUVABackendTextures.cpp
deleted file mode 100644
index d411a80..0000000
--- a/src/gpu/GrYUVABackendTextures.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "include/gpu/GrYUVABackendTextures.h"
-
-static int num_channels(const GrBackendFormat& format) {
-    switch (format.channelMask()) {
-        case kRed_SkColorChannelFlag  : return 1;
-        case kAlpha_SkColorChannelFlag: return 1;
-        case kGray_SkColorChannelFlag : return 1;
-        case kRG_SkColorChannelFlags  : return 2;
-        case kRGB_SkColorChannelFlags : return 3;
-        case kRGBA_SkColorChannelFlags: return 4;
-        default                       : return 0;
-    }
-}
-
-GrYUVABackendTextures::GrYUVABackendTextures(
-        const SkYUVAInfo& yuvaInfo,
-        const GrBackendTexture textures[SkYUVAInfo::kMaxPlanes],
-        GrSurfaceOrigin textureOrigin)
-        : fYUVAInfo(yuvaInfo), fTextureOrigin(textureOrigin) {
-    if (!fYUVAInfo.isValid()) {
-        return;
-    }
-    SkISize planeDimensions[SkYUVAInfo::kMaxPlanes];
-    int numPlanes = yuvaInfo.planeDimensions(planeDimensions);
-    for (int i = 0; i < numPlanes; ++i) {
-        if (textures[i].dimensions() != planeDimensions[i]) {
-            *this = {};
-            return;
-        }
-        int numRequiredChannels = fYUVAInfo.numChannelsInPlane(i);
-        if (!textures[i].isValid() || textures[i].backend() != textures[0].backend() ||
-            num_channels(textures[i].getBackendFormat()) < numRequiredChannels) {
-            *this = {};
-            return;
-        }
-        fTextures[i] = textures[i];
-    }
-}
-
-bool GrYUVABackendTextures::toYUVAIndices(SkYUVAIndex indices[SkYUVAIndex::kIndexCount]) const {
-    SkASSERT(indices);
-    uint32_t channelFlags[] = {fTextures[0].getBackendFormat().channelMask(),
-                               fTextures[1].getBackendFormat().channelMask(),
-                               fTextures[2].getBackendFormat().channelMask(),
-                               fTextures[3].getBackendFormat().channelMask()};
-    return fYUVAInfo.toYUVAIndices(channelFlags, indices);
-}
diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp
index 7c04f1a..0c38e98 100644
--- a/src/image/SkImage_GpuYUVA.cpp
+++ b/src/image/SkImage_GpuYUVA.cpp
@@ -13,7 +13,6 @@
 #include "include/core/SkYUVASizeInfo.h"
 #include "include/gpu/GrDirectContext.h"
 #include "include/gpu/GrRecordingContext.h"
-#include "include/gpu/GrYUVABackendTextures.h"
 #include "src/core/SkAutoPixmapStorage.h"
 #include "src/core/SkMipmap.h"
 #include "src/core/SkScopeExit.h"
@@ -235,45 +234,6 @@
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
 
-sk_sp<SkImage> SkImage::MakeFromYUVATextures(GrRecordingContext* context,
-                                             const GrYUVABackendTextures& yuvaTextures,
-                                             sk_sp<SkColorSpace> imageColorSpace,
-                                             TextureReleaseProc textureReleaseProc,
-                                             ReleaseContext releaseContext) {
-    sk_sp<GrRefCntedCallback> releaseHelper;
-    if (textureReleaseProc) {
-        releaseHelper.reset(new GrRefCntedCallback(textureReleaseProc, releaseContext));
-    }
-
-    SkYUVAIndex yuvaIndices[4];
-    yuvaTextures.toYUVAIndices(yuvaIndices);
-    int numTextures;
-    if (!SkYUVAIndex::AreValidIndices(yuvaIndices, &numTextures)) {
-        return nullptr;
-    }
-    SkASSERT(numTextures == yuvaTextures.numPlanes());
-
-    GrSurfaceProxyView tempViews[4];
-    if (!SkImage_GpuBase::MakeTempTextureProxies(context,
-                                                 yuvaTextures.textures().data(),
-                                                 numTextures,
-                                                 yuvaIndices,
-                                                 yuvaTextures.textureOrigin(),
-                                                 tempViews,
-                                                 std::move(releaseHelper))) {
-        return nullptr;
-    }
-
-    return sk_make_sp<SkImage_GpuYUVA>(sk_ref_sp(context),
-                                       yuvaTextures.yuvaInfo().dimensions(),
-                                       kNeedNewImageUniqueID,
-                                       yuvaTextures.yuvaInfo().yuvColorSpace(),
-                                       tempViews,
-                                       numTextures,
-                                       yuvaIndices,
-                                       imageColorSpace);
-}
-
 sk_sp<SkImage> SkImage::MakeFromYUVATextures(GrContext* ctx,
                                              SkYUVColorSpace colorSpace,
                                              const GrBackendTexture yuvaTextures[],
diff --git a/tools/gpu/YUVUtils.cpp b/tools/gpu/YUVUtils.cpp
index f72ae5d..d5f7ac3 100644
--- a/tools/gpu/YUVUtils.cpp
+++ b/tools/gpu/YUVUtils.cpp
@@ -10,7 +10,6 @@
 #include "include/core/SkColorPriv.h"
 #include "include/core/SkData.h"
 #include "include/gpu/GrRecordingContext.h"
-#include "include/gpu/GrYUVABackendTextures.h"
 #include "src/codec/SkCodecImageGenerator.h"
 #include "src/core/SkYUVMath.h"
 #include "src/gpu/GrDirectContextPriv.h"
@@ -227,23 +226,30 @@
             if (auto direct = rContext->asDirectContext()) {
                 sk_sp<sk_gpu_test::ManagedBackendTexture> mbets[SkYUVAInfo::kMaxPlanes];
                 GrBackendTexture textures[SkYUVAInfo::kMaxPlanes];
+                uint32_t componentFlags[SkYUVAInfo::kMaxPlanes] = {};
                 for (int i = 0; i < fPixmaps.numPlanes(); ++i) {
                     mbets[i] = sk_gpu_test::ManagedBackendTexture::MakeWithData(
                             direct, fPixmaps.plane(i), GrRenderable::kNo, GrProtected::kNo);
                     if (mbets[i]) {
                         textures[i] = mbets[i]->texture();
+                        componentFlags[i] = textures[i].getBackendFormat().channelMask();
                     } else {
                         return false;
                     }
                 }
-                GrYUVABackendTextures yuvaTextures(fPixmaps.yuvaInfo(),
-                                                   textures,
-                                                   kTopLeft_GrSurfaceOrigin);
+                SkYUVAIndex indices[SkYUVAIndex::kIndexCount];
+                if (!fPixmaps.yuvaInfo().toYUVAIndices(componentFlags, indices)) {
+                    return false;
+                }
                 void* relContext =
                         sk_gpu_test::ManagedBackendTexture::MakeYUVAReleaseContext(mbets);
                 fYUVImage[idx] = SkImage::MakeFromYUVATextures(
                         direct,
-                        yuvaTextures,
+                        fPixmaps.yuvaInfo().yuvColorSpace(),
+                        textures,
+                        indices,
+                        fPixmaps.yuvaInfo().dimensions(),
+                        kTopLeft_GrSurfaceOrigin,
                         fColorSpace,
                         sk_gpu_test::ManagedBackendTexture::ReleaseProc,
                         relContext);