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 26 matching lines...) Expand all Loading... |
37 size_t rowBytes() const { return fRowBytes; } | 37 size_t rowBytes() const { return fRowBytes; } |
38 const void* addr() const { return fPixels; } | 38 const void* addr() const { return fPixels; } |
39 SkColorTable* ctable() const { return fCTable; } | 39 SkColorTable* ctable() const { return fCTable; } |
40 | 40 |
41 int width() const { return fInfo.width(); } | 41 int width() const { return fInfo.width(); } |
42 int height() const { return fInfo.height(); } | 42 int height() const { return fInfo.height(); } |
43 SkColorType colorType() const { return fInfo.colorType(); } | 43 SkColorType colorType() const { return fInfo.colorType(); } |
44 SkAlphaType alphaType() const { return fInfo.alphaType(); } | 44 SkAlphaType alphaType() const { return fInfo.alphaType(); } |
45 bool isOpaque() const { return fInfo.isOpaque(); } | 45 bool isOpaque() const { return fInfo.isOpaque(); } |
46 | 46 |
47 int64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); } | 47 uint64_t getSize64() const { return sk_64_mul(fInfo.height(), fRowBytes); } |
| 48 uint64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); } |
48 size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); } | 49 size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); } |
49 | 50 |
50 const uint32_t* addr32() const { | 51 const uint32_t* addr32() const { |
51 SkASSERT(4 == SkColorTypeBytesPerPixel(fInfo.colorType())); | 52 SkASSERT(4 == SkColorTypeBytesPerPixel(fInfo.colorType())); |
52 return reinterpret_cast<const uint32_t*>(fPixels); | 53 return reinterpret_cast<const uint32_t*>(fPixels); |
53 } | 54 } |
54 | 55 |
55 const uint16_t* addr16() const { | 56 const uint16_t* addr16() const { |
56 SkASSERT(2 == SkColorTypeBytesPerPixel(fInfo.colorType())); | 57 SkASSERT(2 == SkColorTypeBytesPerPixel(fInfo.colorType())); |
57 return reinterpret_cast<const uint16_t*>(fPixels); | 58 return reinterpret_cast<const uint16_t*>(fPixels); |
(...skipping 29 matching lines...) Expand all Loading... |
87 uint32_t* writable_addr32(int x, int y) const { | 88 uint32_t* writable_addr32(int x, int y) const { |
88 return const_cast<uint32_t*>(this->addr32(x, y)); | 89 return const_cast<uint32_t*>(this->addr32(x, y)); |
89 } | 90 } |
90 uint16_t* writable_addr16(int x, int y) const { | 91 uint16_t* writable_addr16(int x, int y) const { |
91 return const_cast<uint16_t*>(this->addr16(x, y)); | 92 return const_cast<uint16_t*>(this->addr16(x, y)); |
92 } | 93 } |
93 uint8_t* writable_addr8(int x, int y) const { | 94 uint8_t* writable_addr8(int x, int y) const { |
94 return const_cast<uint8_t*>(this->addr8(x, y)); | 95 return const_cast<uint8_t*>(this->addr8(x, y)); |
95 } | 96 } |
96 | 97 |
| 98 // copy methods |
| 99 |
| 100 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy
tes, |
| 101 int srcX, int srcY) const; |
| 102 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy
tes) const { |
| 103 return this->readPixels(dstInfo, dstPixels, dstRowBytes, 0, 0); |
| 104 } |
| 105 bool readPixels(const SkPixmap& dst, int srcX, int srcY) const { |
| 106 return this->readPixels(dst.info(), dst.writable_addr(), dst.rowBytes(),
srcX, srcY); |
| 107 } |
| 108 bool readPixels(const SkPixmap& dst) const { |
| 109 return this->readPixels(dst.info(), dst.writable_addr(), dst.rowBytes(),
0, 0); |
| 110 } |
| 111 |
97 private: | 112 private: |
98 const void* fPixels; | 113 const void* fPixels; |
99 SkColorTable* fCTable; | 114 SkColorTable* fCTable; |
100 size_t fRowBytes; | 115 size_t fRowBytes; |
101 SkImageInfo fInfo; | 116 SkImageInfo fInfo; |
102 }; | 117 }; |
103 | 118 |
104 ////////////////////////////////////////////////////////////////////////////////
///////////// | 119 ////////////////////////////////////////////////////////////////////////////////
///////////// |
105 | 120 |
106 class SkAutoPixmapUnlock : ::SkNoncopyable { | 121 class SkAutoPixmapUnlock : ::SkNoncopyable { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 private: | 158 private: |
144 void (*fUnlockProc)(void*); | 159 void (*fUnlockProc)(void*); |
145 void* fUnlockContext; | 160 void* fUnlockContext; |
146 SkPixmap fPixmap; | 161 SkPixmap fPixmap; |
147 bool fIsLocked; | 162 bool fIsLocked; |
148 | 163 |
149 friend class SkBitmap; | 164 friend class SkBitmap; |
150 }; | 165 }; |
151 | 166 |
152 #endif | 167 #endif |
OLD | NEW |