Revert of replace kIgnore_SkAlphaType with kUnknown_SkAlphaType (patchset #3 id:40001...
authorscroggo <scroggo@google.com>
Fri, 27 Feb 2015 14:21:58 +0000 (06:21 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 27 Feb 2015 14:21:58 +0000 (06:21 -0800)
Reason for revert:
This breaks Android framework build. See

https://android-build.storage.googleapis.com/builds/git_master-skia-linux-volantisg-userdebug/1759130/7f0fcdbf3c0d47530d770a15c912298dac20dd7d90a01de63ecb9ba16c96b25c/logs/build_error.log?Expires=1425047630&GoogleAccessId=701025073339-mqn0q2nvir9iurm6q5d00tdv7blbgvjr%40developer.gserviceaccount.com&Signature=BHPS1lffyH7WykwyEw5RXVVXWqQK5rab%2B6Pl1VaUrTlmWT%2FXb6fq%2FBe22AUDZYFPG24MBR%2F2IzIDzTqH3mihQS9wIkcKJ4kJpA2G%2BI3l8jCX20brZSr3bsDSx%2F4wsLwU1bBpIxI%2FbrauoPRqddbXP8sNI1l51u6ZCxpvRQms9Mc%3D

We need to stop them from using kIgnore before we can reland this.

Original issue's description:
> replace kIgnore_SkAlphaType with kUnknown_SkAlphaType
>
> BUG=skia:
> TBR=
>
> Committed: https://skia.googlesource.com/skia/+/1c8aeeaebce9675197be31bd769e8ffa2531bf86

TBR=reed@google.com,reed@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/966753002

include/core/SkCanvas.h
include/core/SkImageInfo.h
src/core/SkBitmap.cpp
src/core/SkBitmapDevice.cpp
src/core/SkConfig8888.cpp
src/core/SkImageInfo.cpp
src/utils/mac/SkCreateCGImageRef.cpp

index 74bf909..a57f4cd 100644 (file)
@@ -64,7 +64,7 @@ public:
      *  1. invalid ImageInfo (e.g. negative dimensions)
      *  2. unsupported ImageInfo for a canvas
      *      - kUnknown_SkColorType, kIndex_8_SkColorType
-     *      - kUnknown_SkAlphaType
+     *      - kIgnore_SkAlphaType
      *      - this list is not complete, so others may also be unsupported
      *
      *  Note: it is valid to request a supported ImageInfo, but with zero
index d915c09..f928416 100644 (file)
@@ -19,7 +19,12 @@ class SkWriteBuffer;
  *  Describes how to interpret the alpha compoent of a pixel.
  */
 enum SkAlphaType {
-    kUnknown_SkAlphaType,
+    /**
+     *  All pixels should be treated as opaque, regardless of the value stored
+     *  in their alpha field. Used for legacy images that wrote 0 or garbarge
+     *  in their alpha field, but intended the RGB to be treated as opaque.
+     */
+    kIgnore_SkAlphaType,
 
     /**
      *  All pixels are stored as opaque. This differs slightly from kIgnore in
@@ -48,7 +53,11 @@ enum SkAlphaType {
 };
 
 static inline bool SkAlphaTypeIsOpaque(SkAlphaType at) {
-    return kOpaque_SkAlphaType == at;
+    SK_COMPILE_ASSERT(kIgnore_SkAlphaType < kOpaque_SkAlphaType, bad_alphatype_order);
+    SK_COMPILE_ASSERT(kPremul_SkAlphaType > kOpaque_SkAlphaType, bad_alphatype_order);
+    SK_COMPILE_ASSERT(kUnpremul_SkAlphaType > kOpaque_SkAlphaType, bad_alphatype_order);
+
+    return (unsigned)at <= kOpaque_SkAlphaType;
 }
 
 static inline bool SkAlphaTypeIsValid(unsigned value) {
@@ -152,7 +161,7 @@ public:
         : fWidth(0)
         , fHeight(0)
         , fColorType(kUnknown_SkColorType)
-        , fAlphaType(kUnknown_SkAlphaType)
+        , fAlphaType(kIgnore_SkAlphaType)
         , fProfileType(kLinear_SkColorProfileType)
     {}
 
@@ -191,7 +200,7 @@ public:
     }
 
     static SkImageInfo MakeUnknown(int width, int height) {
-        return SkImageInfo(width, height, kUnknown_SkColorType, kUnknown_SkAlphaType,
+        return SkImageInfo(width, height, kUnknown_SkColorType, kIgnore_SkAlphaType,
                            kLinear_SkColorProfileType);
     }
 
index 0b586cb..e77bbbd 100644 (file)
@@ -182,8 +182,8 @@ SkPixelRef* SkBitmap::setPixelRef(SkPixelRef* pr, int dx, int dy) {
             SkASSERT(fInfo.height() <= prInfo.height());
             SkASSERT(fInfo.colorType() == prInfo.colorType());
             switch (prInfo.alphaType()) {
-                case kUnknown_SkAlphaType:
-                    SkASSERT(fInfo.alphaType() == kUnknown_SkAlphaType);
+                case kIgnore_SkAlphaType:
+                    SkASSERT(fInfo.alphaType() == kIgnore_SkAlphaType);
                     break;
                 case kOpaque_SkAlphaType:
                 case kPremul_SkAlphaType:
index 37cbff5..e545bae 100644 (file)
@@ -25,7 +25,7 @@ static bool valid_for_bitmap_device(const SkImageInfo& info,
     // TODO: can we stop supporting kUnknown in SkBitmkapDevice?
     if (kUnknown_SkColorType == info.colorType()) {
         if (newAlphaType) {
-            *newAlphaType = kUnknown_SkAlphaType;
+            *newAlphaType = kIgnore_SkAlphaType;
         }
         return true;
     }
index 85e208f..8b47a20 100644 (file)
@@ -54,8 +54,8 @@ static bool is_32bit_colortype(SkColorType ct) {
 }
 
 static AlphaVerb compute_AlphaVerb(SkAlphaType src, SkAlphaType dst) {
-    SkASSERT(kUnknown_SkAlphaType != src);
-    SkASSERT(kUnknown_SkAlphaType != dst);
+    SkASSERT(kIgnore_SkAlphaType != src);
+    SkASSERT(kIgnore_SkAlphaType != dst);
 
     if (kOpaque_SkAlphaType == src || kOpaque_SkAlphaType == dst || src == dst) {
         return kNothing_AlphaVerb;
index 0e8b0b1..146a3ae 100644 (file)
@@ -50,7 +50,7 @@ bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType,
                                   SkAlphaType* canonical) {
     switch (colorType) {
         case kUnknown_SkColorType:
-            alphaType = kUnknown_SkAlphaType;
+            alphaType = kIgnore_SkAlphaType;
             break;
         case kAlpha_8_SkColorType:
             if (kUnpremul_SkAlphaType == alphaType) {
@@ -61,7 +61,7 @@ bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType,
         case kARGB_4444_SkColorType:
         case kRGBA_8888_SkColorType:
         case kBGRA_8888_SkColorType:
-            if (kUnknown_SkAlphaType == alphaType) {
+            if (kIgnore_SkAlphaType == alphaType) {
                 return false;
             }
             break;
index 4675d71..51a5ed9 100644 (file)
@@ -12,9 +12,8 @@
 static CGBitmapInfo ComputeCGAlphaInfo_RGBA(SkAlphaType at) {
     CGBitmapInfo info = kCGBitmapByteOrder32Big;
     switch (at) {
-        case kUnknown_SkAlphaType:
-            break;
         case kOpaque_SkAlphaType:
+        case kIgnore_SkAlphaType:
             info |= kCGImageAlphaNoneSkipLast;
             break;
         case kPremul_SkAlphaType:
@@ -30,9 +29,8 @@ static CGBitmapInfo ComputeCGAlphaInfo_RGBA(SkAlphaType at) {
 static CGBitmapInfo ComputeCGAlphaInfo_BGRA(SkAlphaType at) {
     CGBitmapInfo info = kCGBitmapByteOrder32Little;
     switch (at) {
-        case kUnknown_SkAlphaType:
-            break;
         case kOpaque_SkAlphaType:
+        case kIgnore_SkAlphaType:
             info |= kCGImageAlphaNoneSkipFirst;
             break;
         case kPremul_SkAlphaType: