Revert "Widen internal API to support more complex YUV formats"

This reverts commit 0c583af06d50cf3a11a39f5804eccdeefd74fc02.

Reason for revert: DDL is failing

Original change's description:
> Widen internal API to support more complex YUV formats
> 
> Bug: skia:7901
> Change-Id: I46fec08711b8b483cf58ccae733e4dc2a9689231
> Reviewed-on: https://skia-review.googlesource.com/c/162280
> Commit-Queue: Jim Van Verth <jvanverth@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

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

Change-Id: Ibe3dd7abbce4a3b6afe74c565198dadc61a9f439
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:7901
Reviewed-on: https://skia-review.googlesource.com/c/163257
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index f5c23a2..257b764 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -831,18 +831,11 @@
     }
 
     jpeg_component_info * comp_info = dinfo->comp_info;
-    for (auto i : { SkYUVAIndex::kY_Index, SkYUVAIndex::kU_Index, SkYUVAIndex::kV_Index }) {
-        sizeInfo->fColorTypes[i] = kAlpha_8_SkColorType;
+    for (auto i : { SkYUVSizeInfo::kY, SkYUVSizeInfo::kU, SkYUVSizeInfo::kV }) {
         sizeInfo->fSizes[i].set(comp_info[i].downsampled_width, comp_info[i].downsampled_height);
         sizeInfo->fWidthBytes[i] = comp_info[i].width_in_blocks * DCTSIZE;
     }
 
-    // JPEG never has an alpha channel
-    sizeInfo->fColorTypes[SkYUVAIndex::kA_Index] = kUnknown_SkColorType;
-    sizeInfo->fSizes[SkYUVAIndex::kA_Index].fHeight =
-        sizeInfo->fSizes[SkYUVAIndex::kA_Index].fWidth =
-        sizeInfo->fWidthBytes[SkYUVAIndex::kA_Index] = 0;
-
     if (colorSpace) {
         *colorSpace = kJPEG_SkYUVColorSpace;
     }
@@ -850,22 +843,18 @@
     return true;
 }
 
-SkCodec::Result SkJpegCodec::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo,
-                                             void* planes[SkYUVSizeInfo::kMaxCount]) {
+SkCodec::Result SkJpegCodec::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[3]) {
     SkYUVSizeInfo defaultInfo;
 
     // This will check is_yuv_supported(), so we don't need to here.
     bool supportsYUV = this->onQueryYUV8(&defaultInfo, nullptr);
     if (!supportsYUV ||
-            kAlpha_8_SkColorType != sizeInfo.fColorTypes[0] ||
-            kAlpha_8_SkColorType != sizeInfo.fColorTypes[1] ||
-            kAlpha_8_SkColorType != sizeInfo.fColorTypes[2] ||
-            sizeInfo.fSizes[0] != defaultInfo.fSizes[0] ||
-            sizeInfo.fSizes[1] != defaultInfo.fSizes[1] ||
-            sizeInfo.fSizes[2] != defaultInfo.fSizes[2] ||
-            sizeInfo.fWidthBytes[0] < defaultInfo.fWidthBytes[0] ||
-            sizeInfo.fWidthBytes[1] < defaultInfo.fWidthBytes[1] ||
-            sizeInfo.fWidthBytes[2] < defaultInfo.fWidthBytes[2]) {
+            sizeInfo.fSizes[SkYUVSizeInfo::kY] != defaultInfo.fSizes[SkYUVSizeInfo::kY] ||
+            sizeInfo.fSizes[SkYUVSizeInfo::kU] != defaultInfo.fSizes[SkYUVSizeInfo::kU] ||
+            sizeInfo.fSizes[SkYUVSizeInfo::kV] != defaultInfo.fSizes[SkYUVSizeInfo::kV] ||
+            sizeInfo.fWidthBytes[SkYUVSizeInfo::kY] < defaultInfo.fWidthBytes[SkYUVSizeInfo::kY] ||
+            sizeInfo.fWidthBytes[SkYUVSizeInfo::kU] < defaultInfo.fWidthBytes[SkYUVSizeInfo::kU] ||
+            sizeInfo.fWidthBytes[SkYUVSizeInfo::kV] < defaultInfo.fWidthBytes[SkYUVSizeInfo::kV]) {
         return fDecoderMgr->returnFailure("onGetYUV8Planes", kInvalidInput);
     }
 
@@ -890,9 +879,9 @@
 
     // Currently, we require that the Y plane dimensions match the image dimensions
     // and that the U and V planes are the same dimensions.
-    SkASSERT(sizeInfo.fSizes[1] == sizeInfo.fSizes[2]);
-    SkASSERT((uint32_t) sizeInfo.fSizes[0].width() == dinfo->output_width &&
-             (uint32_t) sizeInfo.fSizes[0].height() == dinfo->output_height);
+    SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kU] == sizeInfo.fSizes[SkYUVSizeInfo::kV]);
+    SkASSERT((uint32_t) sizeInfo.fSizes[SkYUVSizeInfo::kY].width() == dinfo->output_width &&
+            (uint32_t) sizeInfo.fSizes[SkYUVSizeInfo::kY].height() == dinfo->output_height);
 
     // Build a JSAMPIMAGE to handle output from libjpeg-turbo.  A JSAMPIMAGE has
     // a 2-D array of pixels for each of the components (Y, U, V) in the image.
@@ -909,19 +898,20 @@
     // Initialize rowptrs.
     int numYRowsPerBlock = DCTSIZE * dinfo->comp_info[0].v_samp_factor;
     for (int i = 0; i < numYRowsPerBlock; i++) {
-        rowptrs[i] = SkTAddOffset<JSAMPLE>(planes[0], i * sizeInfo.fWidthBytes[0]);
+        rowptrs[i] = SkTAddOffset<JSAMPLE>(planes[SkYUVSizeInfo::kY],
+                i * sizeInfo.fWidthBytes[SkYUVSizeInfo::kY]);
     }
     for (int i = 0; i < DCTSIZE; i++) {
-        rowptrs[i + 2 * DCTSIZE] =
-            SkTAddOffset<JSAMPLE>(planes[1], i * sizeInfo.fWidthBytes[1]);
-        rowptrs[i + 3 * DCTSIZE] =
-            SkTAddOffset<JSAMPLE>(planes[2], i * sizeInfo.fWidthBytes[2]);
+        rowptrs[i + 2 * DCTSIZE] = SkTAddOffset<JSAMPLE>(planes[SkYUVSizeInfo::kU],
+                i * sizeInfo.fWidthBytes[SkYUVSizeInfo::kU]);
+        rowptrs[i + 3 * DCTSIZE] = SkTAddOffset<JSAMPLE>(planes[SkYUVSizeInfo::kV],
+                i * sizeInfo.fWidthBytes[SkYUVSizeInfo::kV]);
     }
 
     // After each loop iteration, we will increment pointers to Y, U, and V.
-    size_t blockIncrementY = numYRowsPerBlock * sizeInfo.fWidthBytes[0];
-    size_t blockIncrementU = DCTSIZE * sizeInfo.fWidthBytes[1];
-    size_t blockIncrementV = DCTSIZE * sizeInfo.fWidthBytes[2];
+    size_t blockIncrementY = numYRowsPerBlock * sizeInfo.fWidthBytes[SkYUVSizeInfo::kY];
+    size_t blockIncrementU = DCTSIZE * sizeInfo.fWidthBytes[SkYUVSizeInfo::kU];
+    size_t blockIncrementV = DCTSIZE * sizeInfo.fWidthBytes[SkYUVSizeInfo::kV];
 
     uint32_t numRowsPerBlock = numYRowsPerBlock;
 
@@ -954,7 +944,7 @@
         // this requirement using a dummy row buffer.
         // FIXME: Should SkCodec have an extra memory buffer that can be shared among
         //        all of the implementations that use temporary/garbage memory?
-        SkAutoTMalloc<JSAMPLE> dummyRow(sizeInfo.fWidthBytes[SkYUVAIndex::kY_Index]);
+        SkAutoTMalloc<JSAMPLE> dummyRow(sizeInfo.fWidthBytes[SkYUVSizeInfo::kY]);
         for (int i = remainingRows; i < numYRowsPerBlock; i++) {
             rowptrs[i] = dummyRow.get();
         }