Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / include / core / SkImageInfo.h
index 1c73d95..3d82dc8 100644 (file)
@@ -67,6 +67,10 @@ static inline bool SkAlphaTypeIsValid(unsigned value) {
 
 /**
  *  Describes how to interpret the components of a pixel.
+ *
+ *  kN32_SkColorType is an alias for whichever 32bit ARGB format is the "native"
+ *  form for skia's blitters. Use this if you don't have a swizzle preference
+ *  for 32bit pixels.
  */
 enum SkColorType {
     kUnknown_SkColorType,
@@ -80,12 +84,16 @@ enum SkColorType {
     kLastEnum_SkColorType = kIndex_8_SkColorType,
 
 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
-    kPMColor_SkColorType = kBGRA_8888_SkColorType
+    kN32_SkColorType = kBGRA_8888_SkColorType,
 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
-    kPMColor_SkColorType = kRGBA_8888_SkColorType
+    kN32_SkColorType = kRGBA_8888_SkColorType,
 #else
 #error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order"
 #endif
+
+#ifdef SK_SUPPORT_LEGACY_N32_NAME
+    kPMColor_SkColorType = kN32_SkColorType
+#endif
 };
 
 static int SkColorTypeBytesPerPixel(SkColorType ct) {
@@ -116,6 +124,15 @@ static inline bool SkColorTypeIsValid(unsigned value) {
 ///////////////////////////////////////////////////////////////////////////////
 
 /**
+ *  Return true if alphaType is supported by colorType. If there is a canonical
+ *  alphaType for this colorType, return it in canonical.
+ */
+bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType,
+                                  SkAlphaType* canonical = NULL);
+
+///////////////////////////////////////////////////////////////////////////////
+
+/**
  *  Describe an image's dimensions and pixel type.
  */
 struct SkImageInfo {
@@ -136,7 +153,7 @@ struct SkImageInfo {
      */
     static SkImageInfo MakeN32(int width, int height, SkAlphaType at) {
         SkImageInfo info = {
-            width, height, kPMColor_SkColorType, at
+            width, height, kN32_SkColorType, at
         };
         return info;
     }
@@ -146,7 +163,7 @@ struct SkImageInfo {
      */
     static SkImageInfo MakeN32Premul(int width, int height) {
         SkImageInfo info = {
-            width, height, kPMColor_SkColorType, kPremul_SkAlphaType
+            width, height, kN32_SkColorType, kPremul_SkAlphaType
         };
         return info;
     }
@@ -172,6 +189,13 @@ struct SkImageInfo {
         return info;
     }
 
+    static SkImageInfo MakeUnknown() {
+        SkImageInfo info = {
+            0, 0, kUnknown_SkColorType, kIgnore_SkAlphaType
+        };
+        return info;
+    }
+
     int width() const { return fWidth; }
     int height() const { return fHeight; }
     SkColorType colorType() const { return fColorType; }
@@ -185,6 +209,14 @@ struct SkImageInfo {
 
     SkISize dimensions() const { return SkISize::Make(fWidth, fHeight); }
 
+    /**
+     *  Return a new ImageInfo with the same colortype and alphatype as this info,
+     *  but with the specified width and height.
+     */
+    SkImageInfo makeWH(int newWidth, int newHeight) const {
+        return SkImageInfo::Make(newWidth, newHeight, fColorType, fAlphaType);
+    }
+
     int bytesPerPixel() const {
         return SkColorTypeBytesPerPixel(fColorType);
     }