| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkMask_DEFINED | 10 #ifndef SkMask_DEFINED |
| 11 #define SkMask_DEFINED | 11 #define SkMask_DEFINED |
| 12 | 12 |
| 13 #include "SkBitmap.h" |
| 13 #include "SkRect.h" | 14 #include "SkRect.h" |
| 14 | 15 |
| 15 /** \class SkMask | 16 /** \class SkMask |
| 16 SkMask is used to describe alpha bitmaps, either 1bit, 8bit, or | 17 SkMask is used to describe alpha bitmaps, either 1bit, 8bit, or |
| 17 the 3-channel 3D format. These are passed to SkMaskFilter objects. | 18 the 3-channel 3D format. These are passed to SkMaskFilter objects. |
| 18 */ | 19 */ |
| 19 struct SkMask { | 20 struct SkMask { |
| 20 enum Format { | 21 enum Format { |
| 21 kBW_Format, //!< 1bit per pixel mask (e.g. monochrome) | 22 kBW_Format, //!< 1bit per pixel mask (e.g. monochrome) |
| 22 kA8_Format, //!< 8bits per pixel mask (e.g. antialiasing) | 23 kA8_Format, //!< 8bits per pixel mask (e.g. antialiasing) |
| 23 k3D_Format, //!< 3 8bit per pixl planes: alpha, mul, add | 24 k3D_Format, //!< 3 8bit per pixl planes: alpha, mul, add |
| 24 kARGB32_Format, //!< SkPMColor | 25 kARGB32_Format, //!< SkPMColor |
| 25 kLCD16_Format, //!< 565 alpha for r/g/b | 26 kLCD16_Format, //!< 565 alpha for r/g/b |
| 26 kLCD32_Format //!< 888 alpha for r/g/b | 27 kLCD32_Format //!< 888 alpha for r/g/b |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 enum { | 30 enum { |
| 30 kCountMaskFormats = kLCD32_Format + 1 | 31 kCountMaskFormats = kLCD32_Format + 1 |
| 31 }; | 32 }; |
| 32 | 33 |
| 33 uint8_t* fImage; | 34 uint8_t* fImage; |
| 34 SkIRect fBounds; | 35 SkIRect fBounds; |
| 35 uint32_t fRowBytes; | 36 uint32_t fRowBytes; |
| 36 Format fFormat; | 37 Format fFormat; |
| 38 SkBitmap fBitmap; |
| 37 | 39 |
| 38 /** Returns true if the mask is empty: i.e. it has an empty bounds. | 40 /** Returns true if the mask is empty: i.e. it has an empty bounds. |
| 39 */ | 41 */ |
| 40 bool isEmpty() const { return fBounds.isEmpty(); } | 42 bool isEmpty() const { return fBounds.isEmpty(); } |
| 41 | 43 |
| 42 /** Return the byte size of the mask, assuming only 1 plane. | 44 /** Return the byte size of the mask, assuming only 1 plane. |
| 43 Does not account for k3D_Format. For that, use computeTotalImageSize(). | 45 Does not account for k3D_Format. For that, use computeTotalImageSize(). |
| 44 If there is an overflow of 32bits, then returns 0. | 46 If there is an overflow of 32bits, then returns 0. |
| 45 */ | 47 */ |
| 46 size_t computeImageSize() const; | 48 size_t computeImageSize() const; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 ~SkAutoMaskFreeImage() { | 155 ~SkAutoMaskFreeImage() { |
| 154 SkMask::FreeImage(fImage); | 156 SkMask::FreeImage(fImage); |
| 155 } | 157 } |
| 156 | 158 |
| 157 private: | 159 private: |
| 158 uint8_t* fImage; | 160 uint8_t* fImage; |
| 159 }; | 161 }; |
| 160 #define SkAutoMaskFreeImage(...) SK_REQUIRE_LOCAL_VAR(SkAutoMaskFreeImage) | 162 #define SkAutoMaskFreeImage(...) SK_REQUIRE_LOCAL_VAR(SkAutoMaskFreeImage) |
| 161 | 163 |
| 162 #endif | 164 #endif |
| OLD | NEW |