A new way to specify YUVA planar data from SkCodec to SkImage_Lazy

Tunnels through SkImageGenerator as well.

The new SkCodec interface doesn't assume three 8 bit planes.

New SkYUVASpec more clearly defines chroma subsampling and siting of
the planes.

The intent is to use this for other YUVA APIs as well, in particular
SkImage factories in the future.

In this change we convert to the SkYUVASpec to SkYUVASizeInfo
and SkYUVAIndex[4] representation. But the intent is to use
the SkYUVASpec representation throughout the pipeline once
legacy APIs are removed.

orientation GM is replicated to test a variety of chroma
subsampling configs.

Bug: skia:10632

Change-Id: I3fad35752b87cac16c51b24824331f2ae7d458d3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309658
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index 3d09810..b11c63c 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -167,6 +167,37 @@
 
 SkCodec::~SkCodec() {}
 
+bool SkCodec::queryYUVAInfo(SkYUVAInfo* yuvaInfo,
+                            SkColorType colorTypes[SkYUVAInfo::kMaxPlanes],
+                            size_t rowBytes[SkYUVAInfo::kMaxPlanes]) const {
+    if (!yuvaInfo || !colorTypes || !rowBytes) {
+        return false;
+    }
+    if (!this->onQueryYUVAInfo(yuvaInfo, colorTypes, rowBytes)) {
+        return false;
+    }
+    SkISize planeDimensions[SkYUVAInfo::kMaxPlanes];
+    int numPlanes = yuvaInfo->expectedPlaneDims(planeDimensions);
+    // Validate that the returned color types and row bytes are OK for the expected plane sizes.
+    for (int i = 0; i < numPlanes; ++i) {
+        SkImageInfo ii = SkImageInfo::Make(planeDimensions[i], colorTypes[i], kPremul_SkAlphaType);
+        if (!ii.validRowBytes(rowBytes[i])) {
+            return false;
+        }
+    }
+    return true;
+}
+
+SkCodec::Result SkCodec::getYUVAPlanes(const SkPixmap planes[SkYUVAInfo::kMaxPlanes]) {
+    if (!planes) {
+        return kInvalidInput;
+    }
+    if (!this->rewindIfNeeded()) {
+        return kCouldNotRewind;
+    }
+    return this->onGetYUVAPlanes(planes);
+}
+
 bool SkCodec::conversionSupported(const SkImageInfo& dst, bool srcIsOpaque, bool needsColorXform) {
     if (!valid_alpha(dst.alphaType(), srcIsOpaque)) {
         return false;