Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: include/core/SkPixmap.h

Issue 1666343002: add kRGBA_F16_SkColorType (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add unittest Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkImageInfo.h ('k') | src/core/SkColor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 uint64_t getSize64() const { return sk_64_mul(fInfo.height(), fRowBytes); } 74 uint64_t getSize64() const { return sk_64_mul(fInfo.height(), fRowBytes); }
75 uint64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); } 75 uint64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); }
76 size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); } 76 size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); }
77 77
78 const void* addr(int x, int y) const {
79 return (const char*)fPixels + fInfo.computeOffset(x, y, fRowBytes);
80 }
81 const uint8_t* addr8() const {
82 SkASSERT(1 == SkColorTypeBytesPerPixel(fInfo.colorType()));
83 return reinterpret_cast<const uint8_t*>(fPixels);
84 }
85 const uint16_t* addr16() const {
86 SkASSERT(2 == SkColorTypeBytesPerPixel(fInfo.colorType()));
87 return reinterpret_cast<const uint16_t*>(fPixels);
88 }
78 const uint32_t* addr32() const { 89 const uint32_t* addr32() const {
79 SkASSERT(4 == SkColorTypeBytesPerPixel(fInfo.colorType())); 90 SkASSERT(4 == SkColorTypeBytesPerPixel(fInfo.colorType()));
80 return reinterpret_cast<const uint32_t*>(fPixels); 91 return reinterpret_cast<const uint32_t*>(fPixels);
81 } 92 }
82 93 const uint64_t* addr64() const {
83 const uint16_t* addr16() const { 94 SkASSERT(8 == SkColorTypeBytesPerPixel(fInfo.colorType()));
84 SkASSERT(2 == SkColorTypeBytesPerPixel(fInfo.colorType())); 95 return reinterpret_cast<const uint64_t*>(fPixels);
96 }
97 const uint16_t* addrF16() const {
98 SkASSERT(8 == SkColorTypeBytesPerPixel(fInfo.colorType()));
99 SkASSERT(kRGBA_F16_SkColorType == fInfo.colorType());
85 return reinterpret_cast<const uint16_t*>(fPixels); 100 return reinterpret_cast<const uint16_t*>(fPixels);
86 } 101 }
87 102
88 const uint8_t* addr8() const { 103 // Offset by the specified x,y coordinates
89 SkASSERT(1 == SkColorTypeBytesPerPixel(fInfo.colorType()));
90 return reinterpret_cast<const uint8_t*>(fPixels);
91 }
92 104
93 const uint32_t* addr32(int x, int y) const { 105 const uint8_t* addr8(int x, int y) const {
94 SkASSERT((unsigned)x < (unsigned)fInfo.width()); 106 SkASSERT((unsigned)x < (unsigned)fInfo.width());
95 SkASSERT((unsigned)y < (unsigned)fInfo.height()); 107 SkASSERT((unsigned)y < (unsigned)fInfo.height());
96 return (const uint32_t*)((const char*)this->addr32() + y * fRowBytes + ( x << 2)); 108 return (const uint8_t*)((const char*)this->addr8() + y * fRowBytes + (x << 0));
97 } 109 }
98 const uint16_t* addr16(int x, int y) const { 110 const uint16_t* addr16(int x, int y) const {
99 SkASSERT((unsigned)x < (unsigned)fInfo.width()); 111 SkASSERT((unsigned)x < (unsigned)fInfo.width());
100 SkASSERT((unsigned)y < (unsigned)fInfo.height()); 112 SkASSERT((unsigned)y < (unsigned)fInfo.height());
101 return (const uint16_t*)((const char*)this->addr16() + y * fRowBytes + ( x << 1)); 113 return (const uint16_t*)((const char*)this->addr16() + y * fRowBytes + ( x << 1));
102 } 114 }
103 const uint8_t* addr8(int x, int y) const { 115 const uint32_t* addr32(int x, int y) const {
104 SkASSERT((unsigned)x < (unsigned)fInfo.width()); 116 SkASSERT((unsigned)x < (unsigned)fInfo.width());
105 SkASSERT((unsigned)y < (unsigned)fInfo.height()); 117 SkASSERT((unsigned)y < (unsigned)fInfo.height());
106 return (const uint8_t*)((const char*)this->addr8() + y * fRowBytes + (x << 0)); 118 return (const uint32_t*)((const char*)this->addr32() + y * fRowBytes + ( x << 2));
107 } 119 }
108 const void* addr(int x, int y) const { 120 const uint64_t* addr64(int x, int y) const {
109 return (const char*)fPixels + fInfo.computeOffset(x, y, fRowBytes); 121 SkASSERT((unsigned)x < (unsigned)fInfo.width());
122 SkASSERT((unsigned)y < (unsigned)fInfo.height());
123 return (const uint64_t*)((const char*)this->addr64() + y * fRowBytes + ( x << 3));
124 }
125 const uint16_t* addrF16(int x, int y) const {
126 SkASSERT(kRGBA_F16_SkColorType == fInfo.colorType());
127 return reinterpret_cast<const uint16_t*>(this->addr64(x, y));
110 } 128 }
111 129
112 // Writable versions 130 // Writable versions
113 131
114 void* writable_addr() const { return const_cast<void*>(fPixels); } 132 void* writable_addr() const { return const_cast<void*>(fPixels); }
115 uint32_t* writable_addr32(int x, int y) const { 133 uint8_t* writable_addr8(int x, int y) const {
116 return const_cast<uint32_t*>(this->addr32(x, y)); 134 return const_cast<uint8_t*>(this->addr8(x, y));
117 } 135 }
118 uint16_t* writable_addr16(int x, int y) const { 136 uint16_t* writable_addr16(int x, int y) const {
119 return const_cast<uint16_t*>(this->addr16(x, y)); 137 return const_cast<uint16_t*>(this->addr16(x, y));
120 } 138 }
121 uint8_t* writable_addr8(int x, int y) const { 139 uint32_t* writable_addr32(int x, int y) const {
122 return const_cast<uint8_t*>(this->addr8(x, y)); 140 return const_cast<uint32_t*>(this->addr32(x, y));
141 }
142 uint64_t* writable_addr64(int x, int y) const {
143 return const_cast<uint64_t*>(this->addr64(x, y));
144 }
145 uint16_t* writable_addrF16(int x, int y) const {
146 return reinterpret_cast<uint16_t*>(writable_addr64(x, y));
123 } 147 }
124 148
125 // copy methods 149 // copy methods
126 150
127 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy tes, 151 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy tes,
128 int srcX, int srcY) const; 152 int srcX, int srcY) const;
129 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy tes) const { 153 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy tes) const {
130 return this->readPixels(dstInfo, dstPixels, dstRowBytes, 0, 0); 154 return this->readPixels(dstInfo, dstPixels, dstRowBytes, 0, 0);
131 } 155 }
132 bool readPixels(const SkPixmap& dst, int srcX, int srcY) const { 156 bool readPixels(const SkPixmap& dst, int srcX, int srcY) const {
(...skipping 12 matching lines...) Expand all
145 */ 169 */
146 bool scalePixels(const SkPixmap& dst, SkFilterQuality) const; 170 bool scalePixels(const SkPixmap& dst, SkFilterQuality) const;
147 171
148 /** 172 /**
149 * Returns true if pixels were written to (e.g. if colorType is kUnknown_Sk ColorType, this 173 * Returns true if pixels were written to (e.g. if colorType is kUnknown_Sk ColorType, this
150 * will return false). If subset does not intersect the bounds of this pixm ap, returns false. 174 * will return false). If subset does not intersect the bounds of this pixm ap, returns false.
151 */ 175 */
152 bool erase(SkColor, const SkIRect& subset) const; 176 bool erase(SkColor, const SkIRect& subset) const;
153 177
154 bool erase(SkColor color) const { return this->erase(color, this->bounds()); } 178 bool erase(SkColor color) const { return this->erase(color, this->bounds()); }
179 bool erase(const SkColor4f&, const SkIRect* subset = nullptr) const;
155 180
156 private: 181 private:
157 const void* fPixels; 182 const void* fPixels;
158 SkColorTable* fCTable; 183 SkColorTable* fCTable;
159 size_t fRowBytes; 184 size_t fRowBytes;
160 SkImageInfo fInfo; 185 SkImageInfo fInfo;
161 }; 186 };
162 187
163 //////////////////////////////////////////////////////////////////////////////// ///////////// 188 //////////////////////////////////////////////////////////////////////////////// /////////////
164 189
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 private: 288 private:
264 void (*fUnlockProc)(void*); 289 void (*fUnlockProc)(void*);
265 void* fUnlockContext; 290 void* fUnlockContext;
266 SkPixmap fPixmap; 291 SkPixmap fPixmap;
267 bool fIsLocked; 292 bool fIsLocked;
268 293
269 friend class SkBitmap; 294 friend class SkBitmap;
270 }; 295 };
271 296
272 #endif 297 #endif
OLDNEW
« no previous file with comments | « include/core/SkImageInfo.h ('k') | src/core/SkColor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698