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

Commit 8a82ba66 authored by Ady Abraham's avatar Ady Abraham
Browse files

SurfaceFlinger: enhance refresh rate selection

Enhance the refresh rate selection algorithm to allow having multiple
refresh rate. The new process attaches scores to each one of the available
refresh rate and chooses the refresh rate with the highest score.
This behavior is currently controlled by the sysprop flag
'debug.sf.use_content_detection_v2' and currently turned off.

This algorithm stills needs some tunings which will be done in
layer CLs.

Test: adb shell /data/nativetest64/SurfaceFlinger_test/SurfaceFlinger_test
Test: adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest
Test: go/90hzscenarios manual tests
Bug: 147516364
Fixes: 146068419
Change-Id: I06e07459e469482799ff80fa54fa8dd311325e0e
parent c34a8a2e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -165,7 +165,9 @@ filegroup {
        "Scheduler/EventThread.cpp",
        "Scheduler/OneShotTimer.cpp",
        "Scheduler/LayerHistory.cpp",
        "Scheduler/LayerHistoryV2.cpp",
        "Scheduler/LayerInfo.cpp",
        "Scheduler/LayerInfoV2.cpp",
        "Scheduler/MessageQueue.cpp",
        "Scheduler/PhaseOffsets.cpp",
        "Scheduler/RefreshRateConfigs.cpp",
+5 −2
Original line number Diff line number Diff line
@@ -129,8 +129,11 @@ bool BufferQueueLayer::setFrameRate(float frameRate) {
    return frameRateChanged;
}

float BufferQueueLayer::getFrameRate() const {
std::optional<float> BufferQueueLayer::getFrameRate() const {
    if (mLatchedFrameRate > 0.f || mLatchedFrameRate == FRAME_RATE_NO_VOTE)
        return mLatchedFrameRate;

    return {};
}

// -----------------------------------------------------------------------
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ public:
    bool shouldPresentNow(nsecs_t expectedPresentTime) const override;

    bool setFrameRate(float frameRate) override;
    float getFrameRate() const override;
    std::optional<float> getFrameRate() const override;

    // -----------------------------------------------------------------------

+2 −1
Original line number Diff line number Diff line
@@ -251,7 +251,8 @@ bool BufferStateLayer::setBuffer(const sp<GraphicBuffer>& buffer, nsecs_t postTi
                                           FrameTracer::FrameEvent::POST);
    mCurrentState.desiredPresentTime = desiredPresentTime;

    mFlinger->mScheduler->recordLayerHistory(this, desiredPresentTime);
    mFlinger->mScheduler->recordLayerHistory(this,
                                             desiredPresentTime <= 0 ? 0 : desiredPresentTime);

    return true;
}
+4 −2
Original line number Diff line number Diff line
@@ -227,8 +227,10 @@ class DisplayRenderArea : public RenderArea {
public:
    DisplayRenderArea(const sp<const DisplayDevice>& display,
                      RotationFlags rotation = ui::Transform::ROT_0)
          : DisplayRenderArea(display, display->getBounds(), display->getWidth(),
                              display->getHeight(), display->getCompositionDataSpace(), rotation) {}
          : DisplayRenderArea(display, display->getBounds(),
                              static_cast<uint32_t>(display->getWidth()),
                              static_cast<uint32_t>(display->getHeight()),
                              display->getCompositionDataSpace(), rotation) {}

    DisplayRenderArea(sp<const DisplayDevice> display, const Rect& sourceCrop, uint32_t reqWidth,
                      uint32_t reqHeight, ui::Dataspace reqDataSpace, RotationFlags rotation,
Loading