Revert "Revert "New variant of SkImage::MakeFromYUVATextures.""

This reverts commit be8004d2fb6c8575d7da7c580811639654a9d255.

Bug: skia:10632
Change-Id: I52dd36ae167623563c7554c40092442a3822ee3c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/327760
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/tools/gpu/YUVUtils.cpp b/tools/gpu/YUVUtils.cpp
index d5f7ac3..5d42ef7 100644
--- a/tools/gpu/YUVUtils.cpp
+++ b/tools/gpu/YUVUtils.cpp
@@ -10,6 +10,7 @@
 #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"
@@ -226,30 +227,26 @@
             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;
                     }
                 }
-                SkYUVAIndex indices[SkYUVAIndex::kIndexCount];
-                if (!fPixmaps.yuvaInfo().toYUVAIndices(componentFlags, indices)) {
+                GrYUVABackendTextures yuvaTextures(fPixmaps.yuvaInfo(),
+                                                   textures,
+                                                   kTopLeft_GrSurfaceOrigin);
+                if (!yuvaTextures.isValid()) {
                     return false;
                 }
                 void* relContext =
                         sk_gpu_test::ManagedBackendTexture::MakeYUVAReleaseContext(mbets);
                 fYUVImage[idx] = SkImage::MakeFromYUVATextures(
                         direct,
-                        fPixmaps.yuvaInfo().yuvColorSpace(),
-                        textures,
-                        indices,
-                        fPixmaps.yuvaInfo().dimensions(),
-                        kTopLeft_GrSurfaceOrigin,
+                        yuvaTextures,
                         fColorSpace,
                         sk_gpu_test::ManagedBackendTexture::ReleaseProc,
                         relContext);