Reland "Hide SkEncodedInfo"

This partially reverts commit
1793e7bb46c1f9d430c1a699a1c3d3168159b659.

Hide SkEncodedInfo

Bug: skia:7353
Bug: skia:6839

This contains information that is not necessary for clients to know. The
Color enum tells the number of components in the input, but this is only
interesting internally (to the SkSwizzler).

Similarly, the Alpha enum differs from SkAlphaType in that it has
kBinary instead of kPremul. This is useful information only internally
for determining whether the SkColorSpaceXform needs to premultiply.

The bitsPerComponent is potentially useful for a client; Android (in
SkAndroidCodec) uses it to determine the SkColorType. Rather than
exposing bitsPerComponent, make SkAndroidCodec a friend so it can
access the SkEncodedInfo. A future change will change SkCodec to
recommend F16 for bitsPerComponent > 8, but that will be more involved;
it was the reason for the revert of this CL.

Switch conversionSupported to use an SkColorType, which is enough info.

Replace the SkEncodedInfo::Alpha field on SkCodec::FrameInfo with an
SkAlphaType.

SkCodec still needs an SkEncodedInfo, so move its header (which is
already not SK_API) to include/private.

TBR=mtklein@chromium.org,reed@google.com
Change-Id: I928b1f55317602cb37d29da63b53026c8d139cee
Reviewed-on: https://skia-review.googlesource.com/80860
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index a0f1fb2..7de083d 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -158,7 +158,7 @@
 
 SkCodec::~SkCodec() {}
 
-bool SkCodec::conversionSupported(const SkImageInfo& dst, SkEncodedInfo::Color srcColor,
+bool SkCodec::conversionSupported(const SkImageInfo& dst, SkColorType srcColor,
                                   bool srcIsOpaque, const SkColorSpace* srcCS) const {
     if (!valid_alpha(dst.alphaType(), srcIsOpaque)) {
         return false;
@@ -173,7 +173,7 @@
         case kRGB_565_SkColorType:
             return srcIsOpaque;
         case kGray_8_SkColorType:
-            return SkEncodedInfo::kGray_Color == srcColor && srcIsOpaque &&
+            return kGray_8_SkColorType == srcColor && srcIsOpaque &&
                    !needs_color_xform(dst, srcCS, false);
         case kAlpha_8_SkColorType:
             // conceptually we can convert anything into alpha_8, but we haven't actually coded
@@ -224,7 +224,7 @@
                                           const Options& options) {
     const int index = options.fFrameIndex;
     if (0 == index) {
-        if (!this->conversionSupported(info, fEncodedInfo.color(), fEncodedInfo.opaque(),
+        if (!this->conversionSupported(info, fSrcInfo.colorType(), fEncodedInfo.opaque(),
                                       fSrcInfo.colorSpace())
             || !this->initializeColorXform(info, fEncodedInfo.alpha(), options.fPremulBehavior))
         {
@@ -253,7 +253,7 @@
     const auto* frame = frameHolder->getFrame(index);
     SkASSERT(frame);
 
-    if (!this->conversionSupported(info, fEncodedInfo.color(), !frame->hasAlpha(),
+    if (!this->conversionSupported(info, fSrcInfo.colorType(), !frame->hasAlpha(),
                                    fSrcInfo.colorSpace())) {
         return kInvalidConversion;
     }
@@ -297,9 +297,7 @@
         }
     }
 
-    FrameInfo frameInfo;
-    SkAssertResult(this->getFrameInfo(index, &frameInfo));
-    return this->initializeColorXform(info, frameInfo.fAlpha, options.fPremulBehavior)
+    return this->initializeColorXform(info, frame->reportedAlpha(), options.fPremulBehavior)
         ? kSuccess : kInvalidConversion;
 }
 
@@ -630,6 +628,10 @@
     if (!this->usesColorXform()) {
         return true;
     }
+    // FIXME: In SkWebpCodec, if a frame is blending with a prior frame, we don't need
+    // a colorXform to do a color correct premul, since the blend step will handle
+    // premultiplication. But there is no way to know whether we need to blend from
+    // inside this call.
     bool needsColorCorrectPremul = needs_premul(dstInfo.alphaType(), encodedAlpha) &&
                                    SkTransferFunctionBehavior::kRespect == premulBehavior;
     if (needs_color_xform(dstInfo, fSrcInfo.colorSpace(), needsColorCorrectPremul)) {