| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 /////////////////////////////////////////////////////////////////////////// | 82 /////////////////////////////////////////////////////////////////////////// |
| 83 | 83 |
| 84 const SkImageInfo& info() const { return fInfo; } | 84 const SkImageInfo& info() const { return fInfo; } |
| 85 | 85 |
| 86 int width() const { return fInfo.fWidth; } | 86 int width() const { return fInfo.fWidth; } |
| 87 int height() const { return fInfo.fHeight; } | 87 int height() const { return fInfo.fHeight; } |
| 88 SkColorType colorType() const { return fInfo.fColorType; } | 88 SkColorType colorType() const { return fInfo.fColorType; } |
| 89 SkAlphaType alphaType() const { return fInfo.fAlphaType; } | 89 SkAlphaType alphaType() const { return fInfo.fAlphaType; } |
| 90 | 90 |
| 91 #ifdef SK_SUPPORT_LEGACY_ASIMAGEINFO |
| 92 bool asImageInfo(SkImageInfo* info) const { |
| 93 // compatibility: return false for kUnknown |
| 94 if (kUnknown_SkColorType == this->colorType()) { |
| 95 return false; |
| 96 } |
| 97 if (info) { |
| 98 *info = this->info(); |
| 99 } |
| 100 return true; |
| 101 } |
| 102 #endif |
| 103 |
| 91 /** Return the number of bytes per pixel based on the config. If the config | 104 /** Return the number of bytes per pixel based on the config. If the config |
| 92 does not have at least 1 byte per (e.g. kA1_Config) then 0 is returned. | 105 does not have at least 1 byte per (e.g. kA1_Config) then 0 is returned. |
| 93 */ | 106 */ |
| 94 int bytesPerPixel() const { return fInfo.bytesPerPixel(); } | 107 int bytesPerPixel() const { return fInfo.bytesPerPixel(); } |
| 95 | 108 |
| 96 /** Return the rowbytes expressed as a number of pixels (like width and | 109 /** Return the rowbytes expressed as a number of pixels (like width and |
| 97 height). Note, for 1-byte per pixel configs like kA8_Config, this will | 110 height). Note, for 1-byte per pixel configs like kA8_Config, this will |
| 98 return the same as rowBytes(). Is undefined for configs that are less | 111 return the same as rowBytes(). Is undefined for configs that are less |
| 99 than 1-byte per pixel (e.g. kA1_Config) | 112 than 1-byte per pixel (e.g. kA1_Config) |
| 100 */ | 113 */ |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 return this->installPixels(info, pixels, rowBytes, NULL, NULL); | 330 return this->installPixels(info, pixels, rowBytes, NULL, NULL); |
| 318 } | 331 } |
| 319 | 332 |
| 320 /** | 333 /** |
| 321 * Calls installPixels() with the value in the SkMask. The caller must | 334 * Calls installPixels() with the value in the SkMask. The caller must |
| 322 * ensure that the specified mask pixels are valid for the lifetime | 335 * ensure that the specified mask pixels are valid for the lifetime |
| 323 * of the created bitmap (and its pixelRef). | 336 * of the created bitmap (and its pixelRef). |
| 324 */ | 337 */ |
| 325 bool installMaskPixels(const SkMask&); | 338 bool installMaskPixels(const SkMask&); |
| 326 | 339 |
| 327 /** | |
| 328 * DEPRECATED: call info(). | |
| 329 */ | |
| 330 bool asImageInfo(SkImageInfo* info) const { | |
| 331 // compatibility: return false for kUnknown | |
| 332 if (kUnknown_SkColorType == this->colorType()) { | |
| 333 return false; | |
| 334 } | |
| 335 if (info) { | |
| 336 *info = this->info(); | |
| 337 } | |
| 338 return true; | |
| 339 } | |
| 340 | |
| 341 /** Use this to assign a new pixel address for an existing bitmap. This | 340 /** Use this to assign a new pixel address for an existing bitmap. This |
| 342 will automatically release any pixelref previously installed. Only call | 341 will automatically release any pixelref previously installed. Only call |
| 343 this if you are handling ownership/lifetime of the pixel memory. | 342 this if you are handling ownership/lifetime of the pixel memory. |
| 344 | 343 |
| 345 If the bitmap retains a reference to the colortable (assuming it is | 344 If the bitmap retains a reference to the colortable (assuming it is |
| 346 not null) it will take care of incrementing the reference count. | 345 not null) it will take care of incrementing the reference count. |
| 347 | 346 |
| 348 @param pixels Address for the pixels, managed by the caller. | 347 @param pixels Address for the pixels, managed by the caller. |
| 349 @param ctable ColorTable (or null) that matches the specified pixels | 348 @param ctable ColorTable (or null) that matches the specified pixels |
| 350 */ | 349 */ |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 } | 899 } |
| 901 | 900 |
| 902 /////////////////////////////////////////////////////////////////////////////// | 901 /////////////////////////////////////////////////////////////////////////////// |
| 903 // | 902 // |
| 904 // Helpers until we can fully deprecate SkBitmap::Config | 903 // Helpers until we can fully deprecate SkBitmap::Config |
| 905 // | 904 // |
| 906 extern SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType); | 905 extern SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType); |
| 907 extern SkColorType SkBitmapConfigToColorType(SkBitmap::Config); | 906 extern SkColorType SkBitmapConfigToColorType(SkBitmap::Config); |
| 908 | 907 |
| 909 #endif | 908 #endif |
| OLD | NEW |