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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkImageInfo.h ('k') | src/core/SkColor.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPixmap.h
diff --git a/include/core/SkPixmap.h b/include/core/SkPixmap.h
index 523c40f294db0b1e5c69b234748dcd4f3340bdab..894b238196da95ca80e80ce992a0c6bffb24bb5e 100644
--- a/include/core/SkPixmap.h
+++ b/include/core/SkPixmap.h
@@ -75,51 +75,75 @@ public:
uint64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); }
size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); }
+ const void* addr(int x, int y) const {
+ return (const char*)fPixels + fInfo.computeOffset(x, y, fRowBytes);
+ }
+ const uint8_t* addr8() const {
+ SkASSERT(1 == SkColorTypeBytesPerPixel(fInfo.colorType()));
+ return reinterpret_cast<const uint8_t*>(fPixels);
+ }
+ const uint16_t* addr16() const {
+ SkASSERT(2 == SkColorTypeBytesPerPixel(fInfo.colorType()));
+ return reinterpret_cast<const uint16_t*>(fPixels);
+ }
const uint32_t* addr32() const {
SkASSERT(4 == SkColorTypeBytesPerPixel(fInfo.colorType()));
return reinterpret_cast<const uint32_t*>(fPixels);
}
-
- const uint16_t* addr16() const {
- SkASSERT(2 == SkColorTypeBytesPerPixel(fInfo.colorType()));
+ const uint64_t* addr64() const {
+ SkASSERT(8 == SkColorTypeBytesPerPixel(fInfo.colorType()));
+ return reinterpret_cast<const uint64_t*>(fPixels);
+ }
+ const uint16_t* addrF16() const {
+ SkASSERT(8 == SkColorTypeBytesPerPixel(fInfo.colorType()));
+ SkASSERT(kRGBA_F16_SkColorType == fInfo.colorType());
return reinterpret_cast<const uint16_t*>(fPixels);
}
- const uint8_t* addr8() const {
- SkASSERT(1 == SkColorTypeBytesPerPixel(fInfo.colorType()));
- return reinterpret_cast<const uint8_t*>(fPixels);
- }
+ // Offset by the specified x,y coordinates
- const uint32_t* addr32(int x, int y) const {
+ const uint8_t* addr8(int x, int y) const {
SkASSERT((unsigned)x < (unsigned)fInfo.width());
SkASSERT((unsigned)y < (unsigned)fInfo.height());
- return (const uint32_t*)((const char*)this->addr32() + y * fRowBytes + (x << 2));
+ return (const uint8_t*)((const char*)this->addr8() + y * fRowBytes + (x << 0));
}
const uint16_t* addr16(int x, int y) const {
SkASSERT((unsigned)x < (unsigned)fInfo.width());
SkASSERT((unsigned)y < (unsigned)fInfo.height());
return (const uint16_t*)((const char*)this->addr16() + y * fRowBytes + (x << 1));
}
- const uint8_t* addr8(int x, int y) const {
+ const uint32_t* addr32(int x, int y) const {
SkASSERT((unsigned)x < (unsigned)fInfo.width());
SkASSERT((unsigned)y < (unsigned)fInfo.height());
- return (const uint8_t*)((const char*)this->addr8() + y * fRowBytes + (x << 0));
+ return (const uint32_t*)((const char*)this->addr32() + y * fRowBytes + (x << 2));
}
- const void* addr(int x, int y) const {
- return (const char*)fPixels + fInfo.computeOffset(x, y, fRowBytes);
+ const uint64_t* addr64(int x, int y) const {
+ SkASSERT((unsigned)x < (unsigned)fInfo.width());
+ SkASSERT((unsigned)y < (unsigned)fInfo.height());
+ return (const uint64_t*)((const char*)this->addr64() + y * fRowBytes + (x << 3));
+ }
+ const uint16_t* addrF16(int x, int y) const {
+ SkASSERT(kRGBA_F16_SkColorType == fInfo.colorType());
+ return reinterpret_cast<const uint16_t*>(this->addr64(x, y));
}
// Writable versions
void* writable_addr() const { return const_cast<void*>(fPixels); }
- uint32_t* writable_addr32(int x, int y) const {
- return const_cast<uint32_t*>(this->addr32(x, y));
+ uint8_t* writable_addr8(int x, int y) const {
+ return const_cast<uint8_t*>(this->addr8(x, y));
}
uint16_t* writable_addr16(int x, int y) const {
return const_cast<uint16_t*>(this->addr16(x, y));
}
- uint8_t* writable_addr8(int x, int y) const {
- return const_cast<uint8_t*>(this->addr8(x, y));
+ uint32_t* writable_addr32(int x, int y) const {
+ return const_cast<uint32_t*>(this->addr32(x, y));
+ }
+ uint64_t* writable_addr64(int x, int y) const {
+ return const_cast<uint64_t*>(this->addr64(x, y));
+ }
+ uint16_t* writable_addrF16(int x, int y) const {
+ return reinterpret_cast<uint16_t*>(writable_addr64(x, y));
}
// copy methods
@@ -152,6 +176,7 @@ public:
bool erase(SkColor, const SkIRect& subset) const;
bool erase(SkColor color) const { return this->erase(color, this->bounds()); }
+ bool erase(const SkColor4f&, const SkIRect* subset = nullptr) const;
private:
const void* fPixels;
« 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