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

Commit 635a67ff authored by Alec Mouri's avatar Alec Mouri Committed by Android (Google) Code Review
Browse files

Merge "Synchronize brightness change with frame update for hdr layers."

parents 4a3ce08f cdf1679c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -173,6 +173,8 @@ public:
    // Sets the projection state to use
    virtual void setProjection(ui::Rotation orientation, const Rect& layerStackSpaceRect,
                               const Rect& orientedDisplaySpaceRect) = 0;
    // Sets the brightness that will take effect next frame.
    virtual void setNextBrightness(float brightness) = 0;
    // Sets the bounds to use
    virtual void setDisplaySize(const ui::Size&) = 0;
    // Gets the transform hint used in layers that belong to this output. Used to guide
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ public:
    void setLayerCachingTexturePoolEnabled(bool) override;
    void setProjection(ui::Rotation orientation, const Rect& layerStackSpaceRect,
                       const Rect& orientedDisplaySpaceRect) override;
    void setNextBrightness(float brightness) override;
    void setDisplaySize(const ui::Size&) override;
    void setLayerFilter(ui::LayerFilter) override;
    ui::Transform::RotationFlags getTransformHint() const override;
+4 −0
Original line number Diff line number Diff line
@@ -133,6 +133,10 @@ struct OutputCompositionState {
    // White point of the client target
    float clientTargetWhitePointNits{-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.
    std::optional<float> displayBrightness = std::nullopt;

    // Debugging
    void dump(std::string& result) const;
};
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ public:
    MOCK_METHOD1(setLayerCachingEnabled, void(bool));
    MOCK_METHOD1(setLayerCachingTexturePoolEnabled, void(bool));
    MOCK_METHOD3(setProjection, void(ui::Rotation, const Rect&, const Rect&));
    MOCK_METHOD1(setNextBrightness, void(float));
    MOCK_METHOD1(setDisplaySize, void(const ui::Size&));
    MOCK_CONST_METHOD0(getTransformHint, ui::Transform::RotationFlags());

+13 −0
Original line number Diff line number Diff line
@@ -226,6 +226,17 @@ void Display::chooseCompositionStrategy() {
    // Get any composition changes requested by the HWC device, and apply them.
    std::optional<android::HWComposer::DeviceRequestedChanges> changes;
    auto& hwc = getCompositionEngine().getHwComposer();
    if (const auto physicalDisplayId = PhysicalDisplayId::tryCast(*halDisplayId);
        physicalDisplayId && getState().displayBrightness) {
        const status_t result =
                hwc.setDisplayBrightness(*physicalDisplayId, *getState().displayBrightness,
                                         Hwc2::Composer::DisplayBrightnessOptions{
                                                 .applyImmediately = false})
                        .get();
        ALOGE_IF(result != NO_ERROR, "setDisplayBrightness failed for %s: %d, (%s)",
                 getName().c_str(), result, strerror(-result));
    }

    if (status_t result =
                hwc.getDeviceCompositionChanges(*halDisplayId, anyLayersRequireClientComposition(),
                                                getState().earliestPresentTime,
@@ -248,6 +259,8 @@ void Display::chooseCompositionStrategy() {
    auto& state = editState();
    state.usesClientComposition = anyLayersRequireClientComposition();
    state.usesDeviceComposition = !allLayersRequireClientComposition();
    // Clear out the display brightness now that it's been communicated to composer.
    state.displayBrightness.reset();
}

bool Display::getSkipColorTransform() const {
Loading