promote SkImage::AlphaType to SkAlphaType

BUG=
R=bsalomon@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk/include@11421 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkAlpha.h b/core/SkAlpha.h
new file mode 100644
index 0000000..662b741
--- /dev/null
+++ b/core/SkAlpha.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkAlpha_DEFINED
+#define SkAlpha_DEFINED
+
+#include "SkTypes.h"
+
+/**
+ *  Describes how to interpret the alpha compoent of a pixel.
+ */
+enum 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
+     *  that kOpaque has correct "opaque" values stored in the pixels, while
+     *  kIgnore may not, but in both cases the caller should treat the pixels
+     *  as opaque.
+     */
+    kOpaque_SkAlphaType,
+
+    /**
+     *  All pixels have their alpha premultiplied in their color components.
+     *  This is the natural format for the rendering target pixels.
+     */
+    kPremul_SkAlphaType,
+
+    /**
+     *  All pixels have their color components stored without any regard to the
+     *  alpha. e.g. this is the default configuration for PNG images.
+     *
+     *  This alpha-type is ONLY supported for input images. Rendering cannot
+     *  generate this on output.
+     */
+    kUnpremul_SkAlphaType,
+    
+    kLastEnum_SkAlphaType = kUnpremul_SkAlphaType
+};
+
+#endif
diff --git a/core/SkImage.h b/core/SkImage.h
index 871d461..f6f6a41 100644
--- a/core/SkImage.h
+++ b/core/SkImage.h
@@ -8,6 +8,7 @@
 #ifndef SkImage_DEFINED
 #define SkImage_DEFINED
 
+#include "SkAlpha.h"
 #include "SkImageEncoder.h"
 #include "SkRefCnt.h"
 #include "SkScalar.h"
@@ -41,25 +42,32 @@
         kRGB_565_ColorType,
         kRGBA_8888_ColorType,
         kBGRA_8888_ColorType,
-        kPMColor_ColorType,
+    
+#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
+        kPMColor_ColorType = kBGRA_8888_ColorType,
+#elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
+        kPMColor_ColorType = kRGBA_8888_ColorType,
+#else
+        #error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order
+#endif
 
-        kLastEnum_ColorType = kPMColor_ColorType
+        kLastEnum_ColorType = kBGRA_8888_ColorType
     };
 
+#ifdef SK_ENABLE_LEGACY_API_ALIASING
     enum AlphaType {
-        kIgnore_AlphaType,
-        kOpaque_AlphaType,
-        kPremul_AlphaType,
-        kUnpremul_AlphaType,
-
-        kLastEnum_AlphaType = kUnpremul_AlphaType
+        kIgnore_AlphaType   = kIgnore_SkAlphaType,
+        kOpaque_AlphaType   = kOpaque_SkAlphaType,
+        kPremul_AlphaType   = kPremul_SkAlphaType,
+        kUnpremul_AlphaType = kUnpremul_SkAlphaType,
     };
+#endif
 
     struct Info {
         int         fWidth;
         int         fHeight;
         ColorType   fColorType;
-        AlphaType   fAlphaType;
+        SkAlphaType fAlphaType;
     };
 
     static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowBytes);
diff --git a/core/SkSurface.h b/core/SkSurface.h
index 663cea0..d197a57 100644
--- a/core/SkSurface.h
+++ b/core/SkSurface.h
@@ -53,7 +53,7 @@
      */
     static SkSurface* NewRasterPMColor(int width, int height) {
         SkImage::Info info = {
-            width, height, SkImage::kPMColor_ColorType, SkImage::kPremul_AlphaType
+            width, height, SkImage::kPMColor_ColorType, kPremul_SkAlphaType
         };
         return NewRaster(info);
     }