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

Commit f8d093dc authored by Alec Mouri's avatar Alec Mouri
Browse files

Accomodate brightness space change for client target

Previous the hal reported a white point in nits. Since nits are being
removed from the composer interface, SurfaceFlinger converts a dimming
ratio reported by composer into a white point instead.

Bug: 217961164
Test: builds, boots
Change-Id: I9ceec3af80f503df0debe434bb454ec42694811b
Merged-In: I9ceec3af80f503df0debe434bb454ec42694811b
parent fa8b56be
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ public:
    virtual void applyChangedTypesToLayers(const ChangedTypes&);
    virtual void applyDisplayRequests(const DisplayRequests&);
    virtual void applyLayerRequestsToLayers(const LayerRequests&);
    virtual void applyClientTargetRequests(const ClientTargetProperty&, float whitePointNits);
    virtual void applyClientTargetRequests(const ClientTargetProperty&, float brightness);

    // Internal
    virtual void setConfiguration(const compositionengine::DisplayCreationArgs&);
+2 −2
Original line number Diff line number Diff line
@@ -130,8 +130,8 @@ struct OutputCompositionState {
    // SDR white point
    float sdrWhitePointNits{-1.f};

    // White point of the client target
    float clientTargetWhitePointNits{-1.f};
    // Brightness of the client target, normalized to display brightness
    float clientTargetBrightness{1.f};

    // Display brightness that will take effect this frame.
    // This is slightly distinct from nits, in that nits cannot be passed to hw composer.
+3 −4
Original line number Diff line number Diff line
@@ -266,8 +266,7 @@ void Display::chooseCompositionStrategy() {
        applyChangedTypesToLayers(changes->changedTypes);
        applyDisplayRequests(changes->displayRequests);
        applyLayerRequestsToLayers(changes->layerRequests);
        applyClientTargetRequests(changes->clientTargetProperty,
                                  changes->clientTargetWhitePointNits);
        applyClientTargetRequests(changes->clientTargetProperty, changes->clientTargetBrightness);
    }

    // Determine what type of composition we are doing from the final state
@@ -343,13 +342,13 @@ void Display::applyLayerRequestsToLayers(const LayerRequests& layerRequests) {
}

void Display::applyClientTargetRequests(const ClientTargetProperty& clientTargetProperty,
                                        float whitePointNits) {
                                        float brightness) {
    if (clientTargetProperty.dataspace == ui::Dataspace::UNKNOWN) {
        return;
    }

    editState().dataspace = clientTargetProperty.dataspace;
    editState().clientTargetWhitePointNits = whitePointNits;
    editState().clientTargetBrightness = brightness;
    getRenderSurface()->setBufferDataspace(clientTargetProperty.dataspace);
    getRenderSurface()->setBufferPixelFormat(clientTargetProperty.pixelFormat);
}
+2 −1
Original line number Diff line number Diff line
@@ -1076,7 +1076,8 @@ std::optional<base::unique_fd> Output::composeSurfaces(
            : mDisplayColorProfile->getHdrCapabilities().getDesiredMaxLuminance();
    clientCompositionDisplay.maxLuminance =
            mDisplayColorProfile->getHdrCapabilities().getDesiredMaxLuminance();
    clientCompositionDisplay.targetLuminanceNits = outputState.clientTargetWhitePointNits;
    clientCompositionDisplay.targetLuminanceNits =
            outputState.clientTargetBrightness * outputState.displayBrightnessNits;

    // Compute the global color transform matrix.
    clientCompositionDisplay.colorTransform = outputState.colorTransformMatrix;
+1 −1
Original line number Diff line number Diff line
@@ -839,7 +839,7 @@ TEST_F(DisplayApplyLayerRequestsToLayersTest, applyClientTargetRequests) {

    auto& state = mDisplay->getState();
    EXPECT_EQ(clientTargetProperty.dataspace, state.dataspace);
    EXPECT_EQ(kWhitePointNits, state.clientTargetWhitePointNits);
    EXPECT_EQ(kWhitePointNits, state.clientTargetBrightness);
}

/*
Loading