diff options
author | 2023-08-09 16:07:57 -0400 | |
---|---|---|
committer | 2023-08-09 16:09:01 -0400 | |
commit | 4ef70c212462383eb6c746acb40989b312e9eb5b (patch) | |
tree | 5ae5fc8e864631f5b614ee896192510ac666f446 | |
parent | 7f7a3e1da79b131c519c058c655484cf848c5cef (diff) |
Clarify cutoff priorities
Fixes: 279812401
Test: existing gainmap tests
Change-Id: Idabb13bb730ff69909cad7daf1028422142b727e
-rw-r--r-- | libs/hwui/effects/GainmapRenderer.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libs/hwui/effects/GainmapRenderer.cpp b/libs/hwui/effects/GainmapRenderer.cpp index 613f52b32bea..db58b2bfa273 100644 --- a/libs/hwui/effects/GainmapRenderer.cpp +++ b/libs/hwui/effects/GainmapRenderer.cpp @@ -245,11 +245,18 @@ private: // This can happen if a BitmapShader is used on multiple canvas', such as a // software + hardware canvas, which is otherwise valid as SkShader is "immutable" std::lock_guard _lock(mUniformGuard); - const float Wunclamped = (sk_float_log(targetHdrSdrRatio) - - sk_float_log(mGainmapInfo.fDisplayRatioSdr)) / - (sk_float_log(mGainmapInfo.fDisplayRatioHdr) - - sk_float_log(mGainmapInfo.fDisplayRatioSdr)); - const float W = std::max(std::min(Wunclamped, 1.f), 0.f); + // Compute the weight parameter that will be used to blend between the images. + float W = 0.f; + if (targetHdrSdrRatio > mGainmapInfo.fDisplayRatioSdr) { + if (targetHdrSdrRatio < mGainmapInfo.fDisplayRatioHdr) { + W = (sk_float_log(targetHdrSdrRatio) - + sk_float_log(mGainmapInfo.fDisplayRatioSdr)) / + (sk_float_log(mGainmapInfo.fDisplayRatioHdr) - + sk_float_log(mGainmapInfo.fDisplayRatioSdr)); + } else { + W = 1.f; + } + } mBuilder.uniform("W") = W; uniforms = mBuilder.uniforms(); } |