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

Unified Diff: src/core/SkBitmap.cpp

Issue 1703013002: misc fixes to make float buffers work a little better (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « no previous file | src/core/SkBlitter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmap.cpp
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index bdf1daafccc25434f6286df55223c5475f665ddd..fdb66b378bea45fadbea5114524ed549a77a7f90 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -563,6 +563,8 @@ void* SkBitmap::getAddr(int x, int y) const {
return base;
}
+#include "SkHalf.h"
+
SkColor SkBitmap::getColor(int x, int y) const {
SkASSERT((unsigned)x < (unsigned)this->width());
SkASSERT((unsigned)y < (unsigned)this->height());
@@ -599,6 +601,18 @@ SkColor SkBitmap::getColor(int x, int y) const {
SkPMColor c = SkSwizzle_RGBA_to_PMColor(addr[0]);
return SkUnPreMultiply::PMColorToColor(c);
}
+ case kRGBA_F16_SkColorType: {
+ const uint64_t* addr = (const uint64_t*)fPixels + y * (fRowBytes >> 3) + x;
+ Sk4f p4 = SkHalfToFloat_01(addr[0]);
+ if (p4[3]) {
+ float inva = 1 / p4[3];
+ p4 = p4 * Sk4f(inva, inva, inva, 1);
+ }
+ SkColor c;
+ SkNx_cast<uint8_t>(p4 * Sk4f(255) + Sk4f(0.5f)).store(&c);
+ // p4 is RGBA, but we want BGRA, so we need to swap next
+ return SkSwizzle_RB(c);
+ }
default:
SkASSERT(false);
return 0;
« no previous file with comments | « no previous file | src/core/SkBlitter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698