Add alphaType() to SkImage

Keep isOpaque as a convenience method -- many places really only need to
know that for optimization purposes (SrcOver -> Src, etc...).

In all the places where we pull data back out or convert to another
object and need to supply an SkImageInfo, we can avoid losing information
about premulness.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2250663002

Review-Url: https://codereview.chromium.org/2250663002
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index ca4788c..fa22641 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -43,8 +43,7 @@
     // see https://bug.skia.org/3965
     //REPORTER_ASSERT(reporter, a->isOpaque() == b->isOpaque());
 
-    SkImageInfo info = SkImageInfo::MakeN32(widthA, heightA,
-                                        a->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
+    SkImageInfo info = SkImageInfo::MakeN32(widthA, heightA, a->alphaType());
     SkAutoPixmapStorage pmapA, pmapB;
     pmapA.alloc(info);
     pmapB.alloc(info);
@@ -505,8 +504,8 @@
         if (image->width() != texImage->width() || image->height() != texImage->height()) {
             ERRORF(reporter, "newTextureImage changed the image size.");
         }
-        if (image->isOpaque() != texImage->isOpaque()) {
-            ERRORF(reporter, "newTextureImage changed image opaqueness.");
+        if (image->alphaType() != texImage->alphaType()) {
+            ERRORF(reporter, "newTextureImage changed image alpha type.");
         }
     }
 }
@@ -669,7 +668,7 @@
                                 const SkBitmap& bitmap, SkImage::LegacyBitmapMode mode) {
     REPORTER_ASSERT(reporter, image->width() == bitmap.width());
     REPORTER_ASSERT(reporter, image->height() == bitmap.height());
-    REPORTER_ASSERT(reporter, image->isOpaque() == bitmap.isOpaque());
+    REPORTER_ASSERT(reporter, image->alphaType() == bitmap.alphaType());
 
     if (SkImage::kRO_LegacyBitmapMode == mode) {
         REPORTER_ASSERT(reporter, bitmap.isImmutable());
@@ -812,8 +811,8 @@
         ERRORF(reporter, "Images must have the same size");
         return;
     }
-    if (a->isOpaque() != b->isOpaque()) {
-        ERRORF(reporter, "Images must have the same opaquness");
+    if (a->alphaType() != b->alphaType()) {
+        ERRORF(reporter, "Images must have the same alpha type");
         return;
     }
 
@@ -948,9 +947,9 @@
                     if (newImage) {
                         // Scale the image in software for comparison.
                         SkImageInfo scaled_info = SkImageInfo::MakeN32(
-                                image->width() / testCase.fExpectedScaleFactor,
-                                image->height() / testCase.fExpectedScaleFactor,
-                                image->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
+                                                    image->width() / testCase.fExpectedScaleFactor,
+                                                    image->height() / testCase.fExpectedScaleFactor,
+                                                    image->alphaType());
                         SkAutoPixmapStorage scaled;
                         scaled.alloc(scaled_info);
                         image->scalePixels(scaled, testCase.fExpectedQuality);