aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-01 13:46:54 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-01 13:46:54 +0000
commit2bd8b8100529c96c81c30f749f672f4caf775b04 (patch)
tree5a7468a4570ecf07a7089afbfbfeebb5c773555c /include/core
parent05d56ebbf385c8723c9bed3409739055afa3b073 (diff)
move SkImage::ColorType into SkColorType
objective -- move clients over to SkImage tasks - use SkImageInfo instead of SkBitmap::Config - add support for colortables to SkImage - add drawImage to SkCanvas - return SkImage from readPixels This CL works towards the first task R=robertphillips@google.com Review URL: https://codereview.chromium.org/54363008 git-svn-id: http://skia.googlecode.com/svn/trunk@12077 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkImage.h55
-rw-r--r--include/core/SkImageDecoder.h4
-rw-r--r--include/core/SkSurface.h14
3 files changed, 44 insertions, 29 deletions
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index beede0338a..4142c63034 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -23,6 +23,30 @@ class GrTexture;
// need for TileMode
#include "SkShader.h"
+enum SkColorType {
+ kAlpha_8_SkColorType,
+ kRGB_565_SkColorType,
+ kRGBA_8888_SkColorType,
+ kBGRA_8888_SkColorType,
+
+#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
+ kPMColor_SkColorType = kBGRA_8888_SkColorType,
+#elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
+ kPMColor_SkColorType = kRGBA_8888_SkColorType,
+#else
+ #error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order"
+#endif
+
+ kLastEnum_SkColorType = kBGRA_8888_SkColorType
+};
+
+struct SkImageInfo {
+ int fWidth;
+ int fHeight;
+ SkColorType fColorType;
+ SkAlphaType fAlphaType;
+};
+
/**
* SkImage is an abstraction for drawing a rectagle of pixels, though the
* particular type of image could be actually storing its data on the GPU, or
@@ -37,36 +61,27 @@ class SK_API SkImage : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(SkImage)
- enum ColorType {
- kAlpha_8_ColorType,
- kRGB_565_ColorType,
- kRGBA_8888_ColorType,
- kBGRA_8888_ColorType,
+#ifdef SK_SUPPORT_LEGACY_COLORTYPE
+ typedef SkColorType 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"
+ static const SkColorType kAlpha_8_ColorType = kAlpha_8_SkColorType;
+ static const SkColorType kRGB_565_ColorType = kRGB_565_SkColorType;
+ static const SkColorType kRGBA_8888_ColorType = kRGBA_8888_SkColorType;
+ static const SkColorType kBGRA_8888_ColorType = kBGRA_8888_SkColorType;
+ static const SkColorType kPMColor_ColorType = kPMColor_SkColorType;
+ static const SkColorType kLastEnum_ColorType = kLastEnum_SkColorType;
#endif
- kLastEnum_ColorType = kBGRA_8888_ColorType
- };
-
+#ifdef SK_SUPPORT_LEGACY_ALPHATYPE
typedef SkAlphaType AlphaType;
static const SkAlphaType kIgnore_AlphaType = kIgnore_SkAlphaType;
static const SkAlphaType kOpaque_AlphaType = kOpaque_SkAlphaType;
static const SkAlphaType kPremul_AlphaType = kPremul_SkAlphaType;
static const SkAlphaType kUnpremul_AlphaType = kUnpremul_SkAlphaType;
+#endif
- struct Info {
- int fWidth;
- int fHeight;
- ColorType fColorType;
- SkAlphaType fAlphaType;
- };
+ typedef SkImageInfo Info;
static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowBytes);
static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes);
diff --git a/include/core/SkImageDecoder.h b/include/core/SkImageDecoder.h
index eac2157708..a7e3646553 100644
--- a/include/core/SkImageDecoder.h
+++ b/include/core/SkImageDecoder.h
@@ -377,7 +377,7 @@ public:
* Sample usage:
* <code>
* // Determine the image's info: width/height/config
- * SkImage::Info info;
+ * SkImageInfo info;
* bool success = DecodeMemoryToTarget(src, size, &info, NULL);
* if (!success) return;
* // Allocate space for the result:
@@ -389,7 +389,7 @@ public:
* success = DecodeMemoryToTarget(src, size, &info, &target);
* </code>
*/
- static bool DecodeMemoryToTarget(const void* buffer, size_t size, SkImage::Info* info,
+ static bool DecodeMemoryToTarget(const void* buffer, size_t size, SkImageInfo* info,
const SkBitmapFactory::Target* target);
/** Decode the image stored in the specified SkStreamRewindable, and store the result
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index d197a57eaf..3b7df4257f 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -35,7 +35,7 @@ public:
* If the requested surface cannot be created, or the request is not a
* supported configuration, NULL will be returned.
*/
- static SkSurface* NewRasterDirect(const SkImage::Info&, void* pixels, size_t rowBytes);
+ static SkSurface* NewRasterDirect(const SkImageInfo&, void* pixels, size_t rowBytes);
/**
* Return a new surface, with the memory for the pixels automatically
@@ -44,16 +44,16 @@ public:
* If the requested surface cannot be created, or the request is not a
* supported configuration, NULL will be returned.
*/
- static SkSurface* NewRaster(const SkImage::Info&);
+ static SkSurface* NewRaster(const SkImageInfo&);
/**
- * Helper version of NewRaster. It creates a SkImage::Info with the
+ * Helper version of NewRaster. It creates a SkImageInfo with the
* specified width and height, and populates the rest of info to match
* pixels in SkPMColor format.
*/
static SkSurface* NewRasterPMColor(int width, int height) {
- SkImage::Info info = {
- width, height, SkImage::kPMColor_ColorType, kPremul_SkAlphaType
+ SkImageInfo info = {
+ width, height, kPMColor_SkColorType, kPremul_SkAlphaType
};
return NewRaster(info);
}
@@ -74,7 +74,7 @@ public:
* Return a new surface whose contents will be drawn to an offscreen
* render target, allocated by the surface.
*/
- static SkSurface* NewRenderTarget(GrContext*, const SkImage::Info&, int sampleCount = 0);
+ static SkSurface* NewRenderTarget(GrContext*, const SkImageInfo&, int sampleCount = 0);
int width() const { return fWidth; }
int height() const { return fHeight; }
@@ -133,7 +133,7 @@ public:
* ... // draw using canvasB
* canvasA->drawSurface(surfaceB); // <--- this will always be optimal!
*/
- SkSurface* newSurface(const SkImage::Info&);
+ SkSurface* newSurface(const SkImageInfo&);
/**
* Returns an image of the current state of the surface pixels up to this