aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-20 19:33:52 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-20 19:33:52 +0000
commitd28ba8010c6058bf073f7e815d5b2d7fdf698601 (patch)
tree25d4f972fc63d9f8a39544bec50d53ee1c29f2ac /include
parentd2cfa7422e2b0928970b3b0fa1abe1d73113fc1d (diff)
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@11421 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r--include/core/SkAlpha.h50
-rw-r--r--include/core/SkImage.h26
-rw-r--r--include/core/SkSurface.h2
3 files changed, 68 insertions, 10 deletions
diff --git a/include/core/SkAlpha.h b/include/core/SkAlpha.h
new file mode 100644
index 0000000000..662b741a95
--- /dev/null
+++ b/include/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/include/core/SkImage.h b/include/core/SkImage.h
index 871d4612c7..f6f6a41eaf 100644
--- a/include/core/SkImage.h
+++ b/include/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 @@ public:
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/include/core/SkSurface.h b/include/core/SkSurface.h
index 663cea0875..d197a57eaf 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -53,7 +53,7 @@ public:
*/
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);
}