Index: include/core/SkBitmap.h |
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h |
index 35f0151430bdc87d8be334c0c97b6d69b80fe43c..6de95be24e459c2106a0452834aaa816e9859b91 100644 |
--- a/include/core/SkBitmap.h |
+++ b/include/core/SkBitmap.h |
@@ -27,7 +27,7 @@ class GrTexture; |
/** \class SkBitmap |
The SkBitmap class specifies a raster bitmap. A bitmap has an integer width |
- and height, and a format (config), and a pointer to the actual pixels. |
+ and height, and a format (colortype), and a pointer to the actual pixels. |
Bitmaps can be drawn into a SkCanvas, but they are also used to specify the |
target of a SkCanvas' drawing operations. |
A const SkBitmap exposes getAddr(), which lets a caller write its pixels; |
@@ -53,9 +53,15 @@ public: |
kConfigCount = kARGB_8888_Config + 1 |
}; |
+ /** Return the config for the bitmap. */ |
+ Config config() const; |
scroggo
2014/06/05 16:59:34
Should we deprecate this one too?
|
+ |
+ SK_ATTR_DEPRECATED("use config()") |
+ Config getConfig() const { return this->config(); } |
scroggo
2014/06/05 16:59:34
Does Chrome still use this version? I removed Andr
|
+ |
/** |
* Default construct creates a bitmap with zero width and height, and no pixels. |
- * Its config is set to kNo_Config. |
+ * Its colortype is set to kUnknown_SkColorType. |
*/ |
SkBitmap(); |
@@ -101,24 +107,23 @@ public: |
} |
#endif |
- /** Return the number of bytes per pixel based on the config. If the config |
- does not have at least 1 byte per (e.g. kA1_Config) then 0 is returned. |
+ /** |
+ * Return the number of bytes per pixel based on the colortype. If the colortype is |
+ * kUnknown_SkColorType, then 0 is returned. |
*/ |
int bytesPerPixel() const { return fInfo.bytesPerPixel(); } |
- /** Return the rowbytes expressed as a number of pixels (like width and |
- height). Note, for 1-byte per pixel configs like kA8_Config, this will |
- return the same as rowBytes(). Is undefined for configs that are less |
- than 1-byte per pixel (e.g. kA1_Config) |
+ /** |
+ * Return the rowbytes expressed as a number of pixels (like width and height). |
+ * If the colortype is kUnknown_SkColorType, then 0 is returned. |
*/ |
int rowBytesAsPixels() const { |
return fRowBytes >> this->shiftPerPixel(); |
} |
- /** Return the shift amount per pixel (i.e. 0 for 1-byte per pixel, 1 for |
- 2-bytes per pixel configs, 2 for 4-bytes per pixel configs). Return 0 |
- for configs that are not at least 1-byte per pixel (e.g. kA1_Config |
- or kNo_Config) |
+ /** |
+ * Return the shift amount per pixel (i.e. 0 for 1-byte per pixel, 1 for 2-bytes per pixel |
+ * colortypes, 2 for 4-bytes per pixel colortypes). Return 0 for kUnknown_SkColorType. |
*/ |
int shiftPerPixel() const { return this->bytesPerPixel() >> 1; } |
@@ -139,19 +144,13 @@ public: |
*/ |
bool drawsNothing() const { return this->empty() || this->isNull(); } |
- /** Return the config for the bitmap. */ |
- Config config() const; |
- |
- SK_ATTR_DEPRECATED("use config()") |
- Config getConfig() const { return this->config(); } |
- |
/** Return the number of bytes between subsequent rows of the bitmap. */ |
size_t rowBytes() const { return fRowBytes; } |
/** |
* Set the bitmap's alphaType, returning true on success. If false is |
* returned, then the specified new alphaType is incompatible with the |
- * Config, and the current alphaType is unchanged. |
+ * colortype, and the current alphaType is unchanged. |
* |
* Note: this changes the alphatype for the underlying pixels, which means |
* that all bitmaps that might be sharing (subsets of) the pixels will |
@@ -228,6 +227,7 @@ public: |
*/ |
void reset(); |
+#ifdef SK_SUPPORT_LEGACY_COMPUTE_CONFIG_SIZE |
scroggo
2014/06/05 16:59:34
This needs to be defined in skia_for_android_frame
|
/** Given a config and a width, this computes the optimal rowBytes value. This is called automatically |
if you pass 0 for rowBytes to setConfig(). |
*/ |
@@ -247,6 +247,7 @@ public: |
static int64_t ComputeSize64(Config, int width, int height); |
static size_t ComputeSize(Config, int width, int height); |
+#endif |
/** |
* This will brute-force return true if all of the pixels in the bitmap |
@@ -302,12 +303,6 @@ public: |
return this->allocPixels(info, NULL, NULL); |
} |
- /** |
- * Legacy helper function, which creates an SkImageInfo from the specified |
- * config and then calls allocPixels(info). |
- */ |
- bool allocConfigPixels(Config, int width, int height, bool isOpaque = false); |
- |
bool allocN32Pixels(int width, int height, bool isOpaque = false) { |
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
if (isOpaque) { |
@@ -384,7 +379,7 @@ public: |
bool preserveDstPad = false) const; |
/** Use the standard HeapAllocator to create the pixelref that manages the |
- pixel memory. It will be sized based on the current width/height/config. |
+ pixel memory. It will be sized based on the current ImageInfo. |
If this is called multiple times, a new pixelref object will be created |
each time. |
@@ -392,7 +387,7 @@ public: |
not null) it will take care of incrementing the reference count. |
@param ctable ColorTable (or null) to use with the pixels that will |
- be allocated. Only used if config == Index8_Config |
+ be allocated. Only used if colortype == kIndex_8_SkColorType |
@return true if the allocation succeeds. If not the pixelref field of |
the bitmap will be unchanged. |
*/ |
@@ -401,7 +396,7 @@ public: |
} |
/** Use the specified Allocator to create the pixelref that manages the |
- pixel memory. It will be sized based on the current width/height/config. |
+ pixel memory. It will be sized based on the current ImageInfo. |
If this is called multiple times, a new pixelref object will be created |
each time. |
@@ -409,12 +404,11 @@ public: |
not null) it will take care of incrementing the reference count. |
@param allocator The Allocator to use to create a pixelref that can |
- manage the pixel memory for the current |
- width/height/config. If allocator is NULL, the standard |
- HeapAllocator will be used. |
+ manage the pixel memory for the current ImageInfo. |
+ If allocator is NULL, the standard HeapAllocator will be used. |
@param ctable ColorTable (or null) to use with the pixels that will |
- be allocated. Only used if config == Index8_Config. |
- If it is non-null and the config is not Index8, it will |
+ be allocated. Only used if colortype == kIndex_8_SkColorType. |
+ If it is non-null and the colortype is not indexed, it will |
be ignored. |
@return true if the allocation succeeds. If not the pixelref field of |
the bitmap will be unchanged. |
@@ -478,7 +472,7 @@ public: |
bool lockPixelsAreWritable() const; |
/** Call this to be sure that the bitmap is valid enough to be drawn (i.e. |
- it has non-null pixels, and if required by its config, it has a |
+ it has non-null pixels, and if required by its colortype, it has a |
non-null colortable. Returns true if all of the above are met. |
*/ |
bool readyToDraw() const { |
@@ -512,8 +506,8 @@ public: |
/** |
* Fill the entire bitmap with the specified color. |
- * If the bitmap's config does not support alpha (e.g. 565) then the alpha |
- * of the color is ignored (treated as opaque). If the config only supports |
+ * If the bitmap's colortype does not support alpha (e.g. 565) then the alpha |
+ * of the color is ignored (treated as opaque). If the colortype only supports |
* alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. |
*/ |
void eraseColor(SkColor c) const { |
@@ -523,8 +517,8 @@ public: |
/** |
* Fill the entire bitmap with the specified color. |
- * If the bitmap's config does not support alpha (e.g. 565) then the alpha |
- * of the color is ignored (treated as opaque). If the config only supports |
+ * If the bitmap's colortype does not support alpha (e.g. 565) then the alpha |
+ * of the color is ignored (treated as opaque). If the colortype only supports |
* alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. |
*/ |
void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const; |
@@ -536,8 +530,8 @@ public: |
/** |
* Fill the specified area of this bitmap with the specified color. |
- * If the bitmap's config does not support alpha (e.g. 565) then the alpha |
- * of the color is ignored (treated as opaque). If the config only supports |
+ * If the bitmap's colortype does not support alpha (e.g. 565) then the alpha |
+ * of the color is ignored (treated as opaque). If the colortype only supports |
* alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. |
*/ |
void eraseArea(const SkIRect& area, SkColor c) const; |
@@ -556,9 +550,8 @@ public: |
was scrolled away. E.g. if dx = dy = 0, then inval would |
be set to empty. If dx >= width or dy >= height, then |
inval would be set to the entire bounds of the bitmap. |
- @return true if the scroll was doable. Will return false if the bitmap |
- uses an unsupported config for scrolling (only kA8, |
- kIndex8, kRGB_565, kARGB_4444, kARGB_8888 are supported). |
+ @return true if the scroll was doable. Will return false if the colortype is kUnkown or |
+ if the bitmap is immutable. |
If no pixels are present (i.e. getPixels() returns false) |
inval will still be updated, and true will be returned. |
*/ |
@@ -567,9 +560,9 @@ public: |
/** |
* Return the SkColor of the specified pixel. In most cases this will |
- * require un-premultiplying the color. Alpha only configs (A1 and A8) |
+ * require un-premultiplying the color. Alpha only colortypes (e.g. kAlpha_8_SkColorType) |
* return black with the appropriate alpha set. The value is undefined |
- * for kNone_Config or if x or y are out of bounds, or if the bitmap |
+ * for kUnknown_SkColorType or if x or y are out of bounds, or if the bitmap |
* does not have any pixels (or has not be locked with lockPixels()). |
*/ |
SkColor getColor(int x, int y) const; |
@@ -587,21 +580,21 @@ public: |
/** Returns the address of the pixel specified by x,y for 32bit pixels. |
* In debug build, this asserts that the pixels are allocated and locked, |
- * and that the config is 32-bit, however none of these checks are performed |
+ * and that the colortype is 32-bit, however none of these checks are performed |
* in the release build. |
*/ |
inline uint32_t* getAddr32(int x, int y) const; |
/** Returns the address of the pixel specified by x,y for 16bit pixels. |
* In debug build, this asserts that the pixels are allocated and locked, |
- * and that the config is 16-bit, however none of these checks are performed |
+ * and that the colortype is 16-bit, however none of these checks are performed |
* in the release build. |
*/ |
inline uint16_t* getAddr16(int x, int y) const; |
/** Returns the address of the pixel specified by x,y for 8bit pixels. |
* In debug build, this asserts that the pixels are allocated and locked, |
- * and that the config is 8-bit, however none of these checks are performed |
+ * and that the colortype is 8-bit, however none of these checks are performed |
* in the release build. |
*/ |
inline uint8_t* getAddr8(int x, int y) const; |
@@ -609,16 +602,16 @@ public: |
/** Returns the color corresponding to the pixel specified by x,y for |
* colortable based bitmaps. |
* In debug build, this asserts that the pixels are allocated and locked, |
- * that the config is kIndex8, and that the colortable is allocated, |
+ * that the colortype is indexed, and that the colortable is allocated, |
* however none of these checks are performed in the release build. |
*/ |
inline SkPMColor getIndex8Color(int x, int y) const; |
/** Set dst to be a setset of this bitmap. If possible, it will share the |
- pixel memory, and just point into a subset of it. However, if the config |
+ pixel memory, and just point into a subset of it. However, if the colortype |
does not support this, a local copy will be made and associated with |
the dst bitmap. If the subset rectangle, intersected with the bitmap's |
- dimensions is empty, or if there is an unsupported config, false will be |
+ dimensions is empty, or if there is an unsupported colortype, false will be |
returned and dst will be untouched. |
@param dst The bitmap that will be set to a subset of this bitmap |
@param subset The rectangle of pixels in this bitmap that dst will |
@@ -631,7 +624,7 @@ public: |
* and allocating the dst pixels on the cpu. |
* Returns false if either there is an error (i.e. the src does not have |
* pixels) or the request cannot be satisfied (e.g. the src has per-pixel |
- * alpha, and the requested config does not support alpha). |
+ * alpha, and the requested colortype does not support alpha). |
* @param dst The bitmap to be sized and allocated |
* @param ct The desired colorType for dst |
* @param allocator Allocator used to allocate the pixelref for the dst |
@@ -705,9 +698,9 @@ public: |
SK_DECLARE_INST_COUNT(Allocator) |
/** Allocate the pixel memory for the bitmap, given its dimensions and |
- config. Return true on success, where success means either setPixels |
+ colortype. Return true on success, where success means either setPixels |
or setPixelRef was called. The pixels need not be locked when this |
- returns. If the config requires a colortable, it also must be |
+ returns. If the colortype requires a colortable, it also must be |
installed via setColorTable. If false is returned, the bitmap and |
colortable should be left unchanged. |
*/ |
@@ -778,17 +771,6 @@ private: |
void internalErase(const SkIRect&, U8CPU a, U8CPU r, U8CPU g, U8CPU b)const; |
- /* Internal computations for safe size. |
- */ |
- static int64_t ComputeSafeSize64(Config config, |
- uint32_t width, |
- uint32_t height, |
- size_t rowBytes); |
- static size_t ComputeSafeSize(Config config, |
- uint32_t width, |
- uint32_t height, |
- size_t rowBytes); |
- |
/* Unreference any pixelrefs or colortables |
*/ |
void freePixels(); |