diff options
author | 2014-06-28 14:26:35 -0700 | |
---|---|---|
committer | 2014-06-28 14:26:36 -0700 | |
commit | bae704b050491a8a98c67cb23eaccb10852d2bd5 (patch) | |
tree | 3e03bc38469a37dc6e7a7941aa1e1dd1d4ae69a4 /include/core/SkBitmap.h | |
parent | ce41ad1b3384473bec4e4fd32aac70d0ab15d0e1 (diff) |
add rowbytes option to allocPixels
TBR=
Author: reed@google.com
Review URL: https://codereview.chromium.org/345263005
Diffstat (limited to 'include/core/SkBitmap.h')
-rw-r--r-- | include/core/SkBitmap.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index d3a20c05eb..6728308b54 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -290,7 +290,7 @@ public: #endif /** - * Allocate a pixelref to match the specified image info. If the Factory + * Allocate the bitmap's pixels to match the requested image info. If the Factory * is non-null, call it to allcoate the pixelref. If the ImageInfo requires * a colortable, then ColorTable must be non-null, and will be ref'd. * On failure, the bitmap will be set to empty and return false. @@ -298,13 +298,23 @@ public: bool allocPixels(const SkImageInfo&, SkPixelRefFactory*, SkColorTable*); /** + * Allocate the bitmap's pixels to match the requested image info and + * rowBytes. If the request cannot be met (e.g. the info is invalid or + * the requested rowBytes are not compatible with the info + * (e.g. rowBytes < info.minRowBytes() or rowBytes is not aligned with + * the pixel size specified by info.colorType()) then false is returned + * and the bitmap is set to empty. + */ + bool allocPixels(const SkImageInfo& info, size_t rowBytes); + + /** * Allocate a pixelref to match the specified image info, using the default * allocator. * On success, the bitmap's pixels will be "locked", and return true. * On failure, the bitmap will be set to empty and return false. */ bool allocPixels(const SkImageInfo& info) { - return this->allocPixels(info, NULL, NULL); + return this->allocPixels(info, info.minRowBytes()); } bool allocN32Pixels(int width, int height, bool isOpaque = false) { |