diff options
author | 2016-04-14 12:39:00 -0700 | |
---|---|---|
committer | 2016-04-14 12:39:00 -0700 | |
commit | 6b08652abff788a251db82ca2b5f6b359ffe2590 (patch) | |
tree | b8a879ed17887fc61be769611b30f42d46ea8979 /dm | |
parent | cbe3c1af987d622ea67ef560d855b41bb14a0ce9 (diff) |
Several fixes for fp 16 rendering:
With the GPU backend, allow F16 render targets to be created (along with
any other renderable format). We were previously just falling back to 8888.
In SampleApp, if the window configuration is F16, don't render directly
to the primary surface (which is actually sRGB 8888). Intead, make an
off-screen F16 surface, then blit it back to the framebuffer when we're done.
In DM, clamp values outside of [0,1]. These were wrapping, producing very
incorrect images. (Many filters can trigger out-of-range values due to
ringing).
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1890923003
Review URL: https://codereview.chromium.org/1890923003
Diffstat (limited to 'dm')
-rw-r--r-- | dm/DM.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -958,7 +958,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. |