Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b02fc47 authored by John Reck's avatar John Reck
Browse files

Adjust screenshot behavior of HDR content

Cap the max amount of HDR headroom beyond which the
layer is clipped. This avoids over-dimming the SDR content
range in the resulting SDR screenshot

Test: screenshot of silkfx
Bug: 286942637
Change-Id: I67df32d9c192da18df516972ed92e9bd64063186
parent 094946bd
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ namespace {
// Debugging settings
static const bool kPrintLayerSettings = false;
static const bool kFlushAfterEveryLayer = kPrintLayerSettings;
static constexpr bool kEnableLayerBrightening = true;

} // namespace

@@ -699,7 +700,8 @@ void SkiaRenderEngine::drawLayersInternal(

    // ...and compute the dimming ratio if dimming is requested
    const float displayDimmingRatio = display.targetLuminanceNits > 0.f &&
                    maxLayerWhitePoint > 0.f && display.targetLuminanceNits > maxLayerWhitePoint
                    maxLayerWhitePoint > 0.f &&
                    (kEnableLayerBrightening || display.targetLuminanceNits > maxLayerWhitePoint)
            ? maxLayerWhitePoint / display.targetLuminanceNits
            : 1.f;

+7 −0
Original line number Diff line number Diff line
@@ -7419,6 +7419,13 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl(
                                      renderArea->getHintForSeamlessTransition());
            sdrWhitePointNits = state.sdrWhitePointNits;
            displayBrightnessNits = state.displayBrightnessNits;
            if (sdrWhitePointNits > 1.0f) {
                // Restrict the amount of HDR "headroom" in the screenshot to avoid over-dimming
                // the SDR portion. 2.0 chosen by experimentation
                constexpr float kMaxScreenshotHeadroom = 2.0f;
                displayBrightnessNits =
                        std::min(sdrWhitePointNits * kMaxScreenshotHeadroom, displayBrightnessNits);
            }

            if (requestedDataspace == ui::Dataspace::UNKNOWN) {
                renderIntent = state.renderIntent;