| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 260 |
| 261 /** | 261 /** |
| 262 * Allocate a pixelref to match the specified image info, using the default | 262 * Allocate a pixelref to match the specified image info, using the default |
| 263 * allocator. | 263 * allocator. |
| 264 * On success, the bitmap's pixels will be "locked", and return true. | 264 * On success, the bitmap's pixels will be "locked", and return true. |
| 265 * On failure, the bitmap will be set to empty and return false. | 265 * On failure, the bitmap will be set to empty and return false. |
| 266 */ | 266 */ |
| 267 bool allocPixels(const SkImageInfo& info) { | 267 bool allocPixels(const SkImageInfo& info) { |
| 268 return this->allocPixels(info, NULL, NULL); | 268 return this->allocPixels(info, NULL, NULL); |
| 269 } | 269 } |
| 270 | 270 |
| 271 /** |
| 272 * Legacy helper function, which creates an SkImageInfo from the specified |
| 273 * config and then calls allocPixels(info). |
| 274 */ |
| 275 bool allocConfigPixels(Config, int width, int height, bool isOpaque = false)
; |
| 276 |
| 277 bool allocN32Pixels(int width, int height, bool isOpaque = false) { |
| 278 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
| 279 if (isOpaque) { |
| 280 info.fAlphaType = kOpaque_SkAlphaType; |
| 281 } |
| 282 return this->allocPixels(info); |
| 283 } |
| 284 |
| 271 /** | 285 /** |
| 272 * Install a pixelref that wraps the specified pixels and rowBytes, and | 286 * Install a pixelref that wraps the specified pixels and rowBytes, and |
| 273 * optional ReleaseProc and context. When the pixels are no longer | 287 * optional ReleaseProc and context. When the pixels are no longer |
| 274 * referenced, if ReleaseProc is not null, it will be called with the | 288 * referenced, if ReleaseProc is not null, it will be called with the |
| 275 * pixels and context as parameters. | 289 * pixels and context as parameters. |
| 276 * On failure, the bitmap will be set to empty and return false. | 290 * On failure, the bitmap will be set to empty and return false. |
| 277 */ | 291 */ |
| 278 bool installPixels(const SkImageInfo&, void* pixels, size_t rowBytes, | 292 bool installPixels(const SkImageInfo&, void* pixels, size_t rowBytes, |
| 279 void (*ReleaseProc)(void* addr, void* context), | 293 void (*ReleaseProc)(void* addr, void* context), |
| 280 void* context); | 294 void* context); |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 | 871 |
| 858 inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const { | 872 inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const { |
| 859 SkASSERT(fPixels); | 873 SkASSERT(fPixels); |
| 860 SkASSERT(fConfig == kIndex8_Config); | 874 SkASSERT(fConfig == kIndex8_Config); |
| 861 SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight); | 875 SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight); |
| 862 SkASSERT(fColorTable); | 876 SkASSERT(fColorTable); |
| 863 return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)]; | 877 return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)]; |
| 864 } | 878 } |
| 865 | 879 |
| 866 #endif | 880 #endif |
| OLD | NEW |