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


+13 −0
Original line number Original line Diff line number Diff line
@@ -226,6 +226,17 @@ void Display::chooseCompositionStrategy() {
    // Get any composition changes requested by the HWC device, and apply them.
    // Get any composition changes requested by the HWC device, and apply them.
    std::optional<android::HWComposer::DeviceRequestedChanges> changes;
    std::optional<android::HWComposer::DeviceRequestedChanges> changes;
    auto& hwc = getCompositionEngine().getHwComposer();
    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 =
    if (status_t result =
                hwc.getDeviceCompositionChanges(*halDisplayId, anyLayersRequireClientComposition(),
                hwc.getDeviceCompositionChanges(*halDisplayId, anyLayersRequireClientComposition(),
                                                getState().earliestPresentTime,
                                                getState().earliestPresentTime,
@@ -248,6 +259,8 @@ void Display::chooseCompositionStrategy() {
    auto& state = editState();
    auto& state = editState();
    state.usesClientComposition = anyLayersRequireClientComposition();
    state.usesClientComposition = anyLayersRequireClientComposition();
    state.usesDeviceComposition = !allLayersRequireClientComposition();
    state.usesDeviceComposition = !allLayersRequireClientComposition();
    // Clear out the display brightness now that it's been communicated to composer.
    state.displayBrightness.reset();
}
}


bool Display::getSkipColorTransform() const {
bool Display::getSkipColorTransform() const {
Loading