|
26 | 26 | #include <ui/FloatRect.h> |
27 | 27 | #include <ui/HdrRenderTypeUtils.h> |
28 | 28 | #include <cstdint> |
| 29 | +#include <limits> |
29 | 30 | #include "system/graphics-base-v1.0.h" |
30 | 31 |
|
31 | 32 | #include <com_android_graphics_libgui_flags.h> |
@@ -398,11 +399,22 @@ void OutputLayer::updateCompositionState( |
398 | 399 | // For hdr content, treat the white point as the display brightness - HDR content should not be |
399 | 400 | // boosted or dimmed. |
400 | 401 | // If the layer explicitly requests to disable dimming, then don't dim either. |
401 | | - if (hdrRenderType == HdrRenderType::GENERIC_HDR || |
402 | | - getOutput().getState().displayBrightnessNits == getOutput().getState().sdrWhitePointNits || |
403 | | - getOutput().getState().displayBrightnessNits == 0.f || !layerFEState->dimmingEnabled) { |
| 402 | + if (getOutput().getState().displayBrightnessNits == getOutput().getState().sdrWhitePointNits || |
| 403 | + getOutput().getState().displayBrightnessNits <= 0.f || !layerFEState->dimmingEnabled) { |
404 | 404 | state.dimmingRatio = 1.f; |
405 | 405 | state.whitePointNits = getOutput().getState().displayBrightnessNits; |
| 406 | + } else if (hdrRenderType == HdrRenderType::GENERIC_HDR) { |
| 407 | + float deviceHeadroom = getOutput().getState().displayBrightnessNits / |
| 408 | + getOutput().getState().sdrWhitePointNits; |
| 409 | + float idealizedMaxHeadroom = deviceHeadroom; |
| 410 | + |
| 411 | + if (FlagManager::getInstance().begone_bright_hlg()) { |
| 412 | + idealizedMaxHeadroom = |
| 413 | + std::min(idealizedMaxHeadroom, getIdealizedMaxHeadroom(state.dataspace)); |
| 414 | + } |
| 415 | + |
| 416 | + state.dimmingRatio = std::min(idealizedMaxHeadroom / deviceHeadroom, 1.0f); |
| 417 | + state.whitePointNits = getOutput().getState().displayBrightnessNits * state.dimmingRatio; |
406 | 418 | } else { |
407 | 419 | float layerBrightnessNits = getOutput().getState().sdrWhitePointNits; |
408 | 420 | // RANGE_EXTENDED can "self-promote" to HDR, but is still rendered for a particular |
|
0 commit comments