| 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 20 matching lines...) Expand all Loading... |
| 31 Bitmaps can be drawn into a SkCanvas, but they are also used to specify the | 31 Bitmaps can be drawn into a SkCanvas, but they are also used to specify the |
| 32 target of a SkCanvas' drawing operations. | 32 target of a SkCanvas' drawing operations. |
| 33 A const SkBitmap exposes getAddr(), which lets a caller write its pixels; | 33 A const SkBitmap exposes getAddr(), which lets a caller write its pixels; |
| 34 the constness is considered to apply to the bitmap's configuration, not | 34 the constness is considered to apply to the bitmap's configuration, not |
| 35 its contents. | 35 its contents. |
| 36 */ | 36 */ |
| 37 class SK_API SkBitmap { | 37 class SK_API SkBitmap { |
| 38 public: | 38 public: |
| 39 class SK_API Allocator; | 39 class SK_API Allocator; |
| 40 | 40 |
| 41 #ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG | |
| 42 enum Config { | |
| 43 kNo_Config, //!< bitmap has not been configured | |
| 44 kA8_Config, //!< 8-bits per pixel, with only alpha specified (0
is transparent, 0xFF is opaque) | |
| 45 kIndex8_Config, //!< 8-bits per pixel, using SkColorTable to specify
the colors | |
| 46 kRGB_565_Config, //!< 16-bits per pixel, (see SkColorPriv.h for packi
ng) | |
| 47 kARGB_4444_Config, //!< 16-bits per pixel, (see SkColorPriv.h for packi
ng) | |
| 48 kARGB_8888_Config, //!< 32-bits per pixel, (see SkColorPriv.h for packi
ng) | |
| 49 }; | |
| 50 | |
| 51 // do not add this to the Config enum, otherwise the compiler will let us | |
| 52 // pass this as a valid parameter for Config. | |
| 53 enum { | |
| 54 kConfigCount = kARGB_8888_Config + 1 | |
| 55 }; | |
| 56 | |
| 57 /** Return the config for the bitmap. */ | |
| 58 Config config() const; | |
| 59 | |
| 60 SK_ATTR_DEPRECATED("use config()") | |
| 61 Config getConfig() const { return this->config(); } | |
| 62 #endif | |
| 63 | |
| 64 /** | 41 /** |
| 65 * Default construct creates a bitmap with zero width and height, and no pi
xels. | 42 * Default construct creates a bitmap with zero width and height, and no pi
xels. |
| 66 * Its colortype is set to kUnknown_SkColorType. | 43 * Its colortype is set to kUnknown_SkColorType. |
| 67 */ | 44 */ |
| 68 SkBitmap(); | 45 SkBitmap(); |
| 69 | 46 |
| 70 /** | 47 /** |
| 71 * Copy the settings from the src into this bitmap. If the src has pixels | 48 * Copy the settings from the src into this bitmap. If the src has pixels |
| 72 * allocated, they will be shared, not copied, so that the two bitmaps will | 49 * allocated, they will be shared, not copied, so that the two bitmaps will |
| 73 * reference the same memory for the pixels. If a deep copy is needed, | 50 * reference the same memory for the pixels. If a deep copy is needed, |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 } | 835 } |
| 859 | 836 |
| 860 inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const { | 837 inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const { |
| 861 SkASSERT(fPixels); | 838 SkASSERT(fPixels); |
| 862 SkASSERT(kIndex_8_SkColorType == this->colorType()); | 839 SkASSERT(kIndex_8_SkColorType == this->colorType()); |
| 863 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); | 840 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); |
| 864 SkASSERT(fColorTable); | 841 SkASSERT(fColorTable); |
| 865 return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)]; | 842 return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)]; |
| 866 } | 843 } |
| 867 | 844 |
| 868 #ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG | |
| 869 /////////////////////////////////////////////////////////////////////////////// | |
| 870 // | |
| 871 // Helpers until we can fully deprecate SkBitmap::Config | |
| 872 // | |
| 873 SK_API SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType); | |
| 874 SK_API SkColorType SkBitmapConfigToColorType(SkBitmap::Config); | |
| 875 #endif | 845 #endif |
| 876 | |
| 877 #endif | |
| OLD | NEW |