diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-11-01 13:46:54 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-11-01 13:46:54 +0000 |
commit | 2bd8b8100529c96c81c30f749f672f4caf775b04 (patch) | |
tree | 5a7468a4570ecf07a7089afbfbfeebb5c773555c /include | |
parent | 05d56ebbf385c8723c9bed3409739055afa3b073 (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')
-rw-r--r-- | include/core/SkImage.h | 55 | ||||
-rw-r--r-- | include/core/SkImageDecoder.h | 4 | ||||
-rw-r--r-- | include/core/SkSurface.h | 14 | ||||
-rw-r--r-- | include/lazy/SkBitmapFactory.h | 8 |
4 files changed, 48 insertions, 33 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 diff --git a/include/lazy/SkBitmapFactory.h b/include/lazy/SkBitmapFactory.h index e967a915b2..8a39a48a28 100644 --- a/include/lazy/SkBitmapFactory.h +++ b/include/lazy/SkBitmapFactory.h @@ -39,7 +39,7 @@ public: /** * Signature for a function to decode an image from encoded data. */ - typedef bool (*DecodeProc)(const void* data, size_t length, SkImage::Info*, const Target*); + typedef bool (*DecodeProc)(const void* data, size_t length, SkImageInfo*, const Target*); /** * Create a bitmap factory which uses DecodeProc for decoding. @@ -67,18 +67,18 @@ public: bool installPixelRef(SkData*, SkBitmap*); /** - * An object for selecting an SkImageCache to use based on an SkImage::Info. + * An object for selecting an SkImageCache to use based on an SkImageInfo. */ class CacheSelector : public SkRefCnt { public: SK_DECLARE_INST_COUNT(CacheSelector) /** - * Return an SkImageCache to use based on the provided SkImage::Info. If the caller decides + * Return an SkImageCache to use based on the provided SkImageInfo. If the caller decides * to hang on to the result, it will call ref, so the implementation should not add a ref * as a result of this call. */ - virtual SkImageCache* selectCache(const SkImage::Info&) = 0; + virtual SkImageCache* selectCache(const SkImageInfo&) = 0; private: typedef SkRefCnt INHERITED; |