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. |