| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * Return the rowbytes expressed as a number of pixels (like width and heig
ht). | 75 * Return the rowbytes expressed as a number of pixels (like width and heig
ht). |
| 76 */ | 76 */ |
| 77 int rowBytesAsPixels() const { return int(fRowBytes >> this->shiftPerPixel()
); } | 77 int rowBytesAsPixels() const { return int(fRowBytes >> this->shiftPerPixel()
); } |
| 78 | 78 |
| 79 /** | 79 /** |
| 80 * Return the shift amount per pixel (i.e. 0 for 1-byte per pixel, 1 for 2-
bytes per pixel | 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. | 81 * colortypes, 2 for 4-bytes per pixel colortypes). Return 0 for kUnknown_S
kColorType. |
| 82 */ | 82 */ |
| 83 int shiftPerPixel() const { return fInfo.bytesPerPixel() >> 1; } | 83 int shiftPerPixel() const { return fInfo.shiftPerPixel(); } |
| 84 | 84 |
| 85 uint64_t getSize64() const { return sk_64_mul(fInfo.height(), fRowBytes); } | 85 uint64_t getSize64() const { return sk_64_mul(fInfo.height(), fRowBytes); } |
| 86 uint64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); } | 86 uint64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); } |
| 87 size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); } | 87 size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); } |
| 88 | 88 |
| 89 const void* addr(int x, int y) const { | 89 const void* addr(int x, int y) const { |
| 90 return (const char*)fPixels + fInfo.computeOffset(x, y, fRowBytes); | 90 return (const char*)fPixels + fInfo.computeOffset(x, y, fRowBytes); |
| 91 } | 91 } |
| 92 const uint8_t* addr8() const { | 92 const uint8_t* addr8() const { |
| 93 SkASSERT(1 == SkColorTypeBytesPerPixel(fInfo.colorType())); | 93 SkASSERT(1 == SkColorTypeBytesPerPixel(fInfo.colorType())); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 return (const uint64_t*)((const char*)this->addr64() + y * fRowBytes + (
x << 3)); | 134 return (const uint64_t*)((const char*)this->addr64() + y * fRowBytes + (
x << 3)); |
| 135 } | 135 } |
| 136 const uint16_t* addrF16(int x, int y) const { | 136 const uint16_t* addrF16(int x, int y) const { |
| 137 SkASSERT(kRGBA_F16_SkColorType == fInfo.colorType()); | 137 SkASSERT(kRGBA_F16_SkColorType == fInfo.colorType()); |
| 138 return reinterpret_cast<const uint16_t*>(this->addr64(x, y)); | 138 return reinterpret_cast<const uint16_t*>(this->addr64(x, y)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 // Writable versions | 141 // Writable versions |
| 142 | 142 |
| 143 void* writable_addr() const { return const_cast<void*>(fPixels); } | 143 void* writable_addr() const { return const_cast<void*>(fPixels); } |
| 144 void* writable_addr(int x, int y) const { |
| 145 return const_cast<void*>(this->addr(x, y)); |
| 146 } |
| 144 uint8_t* writable_addr8(int x, int y) const { | 147 uint8_t* writable_addr8(int x, int y) const { |
| 145 return const_cast<uint8_t*>(this->addr8(x, y)); | 148 return const_cast<uint8_t*>(this->addr8(x, y)); |
| 146 } | 149 } |
| 147 uint16_t* writable_addr16(int x, int y) const { | 150 uint16_t* writable_addr16(int x, int y) const { |
| 148 return const_cast<uint16_t*>(this->addr16(x, y)); | 151 return const_cast<uint16_t*>(this->addr16(x, y)); |
| 149 } | 152 } |
| 150 uint32_t* writable_addr32(int x, int y) const { | 153 uint32_t* writable_addr32(int x, int y) const { |
| 151 return const_cast<uint32_t*>(this->addr32(x, y)); | 154 return const_cast<uint32_t*>(this->addr32(x, y)); |
| 152 } | 155 } |
| 153 uint64_t* writable_addr64(int x, int y) const { | 156 uint64_t* writable_addr64(int x, int y) const { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 private: | 243 private: |
| 241 void (*fUnlockProc)(void*); | 244 void (*fUnlockProc)(void*); |
| 242 void* fUnlockContext; | 245 void* fUnlockContext; |
| 243 SkPixmap fPixmap; | 246 SkPixmap fPixmap; |
| 244 bool fIsLocked; | 247 bool fIsLocked; |
| 245 | 248 |
| 246 friend class SkBitmap; | 249 friend class SkBitmap; |
| 247 }; | 250 }; |
| 248 | 251 |
| 249 #endif | 252 #endif |
| OLD | NEW |