OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkBitmap_DEFINED | 8 #ifndef SkBitmap_DEFINED |
9 #define SkBitmap_DEFINED | 9 #define SkBitmap_DEFINED |
10 | 10 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 283 |
284 bool setInfo(const SkImageInfo&, size_t rowBytes = 0); | 284 bool setInfo(const SkImageInfo&, size_t rowBytes = 0); |
285 | 285 |
286 #ifdef SK_SUPPORT_LEGACY_SETCONFIG_INFO | 286 #ifdef SK_SUPPORT_LEGACY_SETCONFIG_INFO |
287 bool setConfig(const SkImageInfo& info, size_t rowBytes = 0) { | 287 bool setConfig(const SkImageInfo& info, size_t rowBytes = 0) { |
288 return this->setInfo(info, rowBytes); | 288 return this->setInfo(info, rowBytes); |
289 } | 289 } |
290 #endif | 290 #endif |
291 | 291 |
292 /** | 292 /** |
293 * Allocate a pixelref to match the specified image info. If the Factory | 293 * Allocate the bitmap's pixels to match the requested image info. If the F
actory |
294 * is non-null, call it to allcoate the pixelref. If the ImageInfo requires | 294 * is non-null, call it to allcoate the pixelref. If the ImageInfo requires |
295 * a colortable, then ColorTable must be non-null, and will be ref'd. | 295 * a colortable, then ColorTable must be non-null, and will be ref'd. |
296 * On failure, the bitmap will be set to empty and return false. | 296 * On failure, the bitmap will be set to empty and return false. |
297 */ | 297 */ |
298 bool allocPixels(const SkImageInfo&, SkPixelRefFactory*, SkColorTable*); | 298 bool allocPixels(const SkImageInfo&, SkPixelRefFactory*, SkColorTable*); |
299 | 299 |
300 /** | 300 /** |
| 301 * Allocate the bitmap's pixels to match the requested image info and |
| 302 * rowBytes. If the request cannot be met (e.g. the info is invalid or |
| 303 * the requested rowBytes are not compatible with the info |
| 304 * (e.g. rowBytes < info.minRowBytes() or rowBytes is not aligned with |
| 305 * the pixel size specified by info.colorType()) then false is returned |
| 306 * and the bitmap is set to empty. |
| 307 */ |
| 308 bool allocPixels(const SkImageInfo& info, size_t rowBytes); |
| 309 |
| 310 /** |
301 * Allocate a pixelref to match the specified image info, using the default | 311 * Allocate a pixelref to match the specified image info, using the default |
302 * allocator. | 312 * allocator. |
303 * On success, the bitmap's pixels will be "locked", and return true. | 313 * On success, the bitmap's pixels will be "locked", and return true. |
304 * On failure, the bitmap will be set to empty and return false. | 314 * On failure, the bitmap will be set to empty and return false. |
305 */ | 315 */ |
306 bool allocPixels(const SkImageInfo& info) { | 316 bool allocPixels(const SkImageInfo& info) { |
307 return this->allocPixels(info, NULL, NULL); | 317 return this->allocPixels(info, info.minRowBytes()); |
308 } | 318 } |
309 | 319 |
310 bool allocN32Pixels(int width, int height, bool isOpaque = false) { | 320 bool allocN32Pixels(int width, int height, bool isOpaque = false) { |
311 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); | 321 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
312 if (isOpaque) { | 322 if (isOpaque) { |
313 info.fAlphaType = kOpaque_SkAlphaType; | 323 info.fAlphaType = kOpaque_SkAlphaType; |
314 } | 324 } |
315 return this->allocPixels(info); | 325 return this->allocPixels(info); |
316 } | 326 } |
317 | 327 |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 #ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG | 910 #ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG |
901 /////////////////////////////////////////////////////////////////////////////// | 911 /////////////////////////////////////////////////////////////////////////////// |
902 // | 912 // |
903 // Helpers until we can fully deprecate SkBitmap::Config | 913 // Helpers until we can fully deprecate SkBitmap::Config |
904 // | 914 // |
905 extern SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType); | 915 extern SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType); |
906 extern SkColorType SkBitmapConfigToColorType(SkBitmap::Config); | 916 extern SkColorType SkBitmapConfigToColorType(SkBitmap::Config); |
907 #endif | 917 #endif |
908 | 918 |
909 #endif | 919 #endif |
OLD | NEW |