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

Unified Diff: dm/DM.cpp

Issue 1890923003: Several fixes for fp 16 rendering: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Nicer looking clamp Created 4 years, 8 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 | samplecode/SampleApp.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DM.cpp
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 388546d66fcf23c309634bc0f43d5fbb5d7db101..7a0e8479296fcd44afba82138e676575d94ef1e6 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -959,7 +959,12 @@ static bool dump_png(SkBitmap bitmap, const char* path, const char* md5) {
return false;
}
for (int i = 0; i < w*h; i++) {
- Sk4f fs = SkHalfToFloat_01(px[i]); // Convert up to linear floats.
+ // Convert up to linear floats.
+ Sk4f fs(SkHalfToFloat(static_cast<SkHalf>(px[i] >> (0 * 16))),
+ SkHalfToFloat(static_cast<SkHalf>(px[i] >> (1 * 16))),
+ SkHalfToFloat(static_cast<SkHalf>(px[i] >> (2 * 16))),
+ SkHalfToFloat(static_cast<SkHalf>(px[i] >> (3 * 16))));
+ fs = Sk4f::Max(0.0f, Sk4f::Min(fs, 1.0f)); // Clamp
float invA = 1.0f / fs[3];
fs = fs * Sk4f(invA, invA, invA, 1); // Unpremultiply.
rgba[i] = Sk4f_toS32(fs); // Pack down to sRGB bytes.
« no previous file with comments | « no previous file | samplecode/SampleApp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698