OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
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 SkPixmap_DEFINED | 8 #ifndef SkPixmap_DEFINED |
9 #define SkPixmap_DEFINED | 9 #define SkPixmap_DEFINED |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 SkColorTable* ctable() const { return fCTable; } | 64 SkColorTable* ctable() const { return fCTable; } |
65 | 65 |
66 int width() const { return fInfo.width(); } | 66 int width() const { return fInfo.width(); } |
67 int height() const { return fInfo.height(); } | 67 int height() const { return fInfo.height(); } |
68 SkColorType colorType() const { return fInfo.colorType(); } | 68 SkColorType colorType() const { return fInfo.colorType(); } |
69 SkAlphaType alphaType() const { return fInfo.alphaType(); } | 69 SkAlphaType alphaType() const { return fInfo.alphaType(); } |
70 bool isOpaque() const { return fInfo.isOpaque(); } | 70 bool isOpaque() const { return fInfo.isOpaque(); } |
71 | 71 |
72 SkIRect bounds() const { return SkIRect::MakeWH(this->width(), this->height(
)); } | 72 SkIRect bounds() const { return SkIRect::MakeWH(this->width(), this->height(
)); } |
73 | 73 |
| 74 /** |
| 75 * Return the rowbytes expressed as a number of pixels (like width and heig
ht). |
| 76 */ |
| 77 int rowBytesAsPixels() const { return int(fRowBytes >> this->shiftPerPixel()
); } |
| 78 |
| 79 /** |
| 80 * Return the shift amount per pixel (i.e. 0 for 1-byte per pixel, 1 for 2-
bytes per pixel |
| 81 * colortypes, 2 for 4-bytes per pixel colortypes). Return 0 for kUnknown_S
kColorType. |
| 82 */ |
| 83 int shiftPerPixel() const { return fInfo.bytesPerPixel() >> 1; } |
| 84 |
74 uint64_t getSize64() const { return sk_64_mul(fInfo.height(), fRowBytes); } | 85 uint64_t getSize64() const { return sk_64_mul(fInfo.height(), fRowBytes); } |
75 uint64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); } | 86 uint64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); } |
76 size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); } | 87 size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); } |
77 | 88 |
78 const void* addr(int x, int y) const { | 89 const void* addr(int x, int y) const { |
79 return (const char*)fPixels + fInfo.computeOffset(x, y, fRowBytes); | 90 return (const char*)fPixels + fInfo.computeOffset(x, y, fRowBytes); |
80 } | 91 } |
81 const uint8_t* addr8() const { | 92 const uint8_t* addr8() const { |
82 SkASSERT(1 == SkColorTypeBytesPerPixel(fInfo.colorType())); | 93 SkASSERT(1 == SkColorTypeBytesPerPixel(fInfo.colorType())); |
83 return reinterpret_cast<const uint8_t*>(fPixels); | 94 return reinterpret_cast<const uint8_t*>(fPixels); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 private: | 240 private: |
230 void (*fUnlockProc)(void*); | 241 void (*fUnlockProc)(void*); |
231 void* fUnlockContext; | 242 void* fUnlockContext; |
232 SkPixmap fPixmap; | 243 SkPixmap fPixmap; |
233 bool fIsLocked; | 244 bool fIsLocked; |
234 | 245 |
235 friend class SkBitmap; | 246 friend class SkBitmap; |
236 }; | 247 }; |
237 | 248 |
238 #endif | 249 #endif |
OLD | NEW |