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

Commit 33f4e0e6 authored by Ying Wei's avatar Ying Wei Committed by Android (Google) Code Review
Browse files

Merge "[SF] Use Render rate for Refresh rate" into main

parents 54a5cc8d c6e522e2
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -474,7 +474,6 @@ void DisplayDevice::enableRefreshRateOverlay(bool enable, bool setByHwc, bool sh
        features |= RefreshRateOverlay::Features::SetByHwc;
    }

    // TODO(b/296636258) Update to use the render rate range in VRR mode.
    const auto fpsRange = mRefreshRateSelector->getSupportedRefreshRateRange();
    mRefreshRateOverlay = RefreshRateOverlay::create(fpsRange, features);
    if (mRefreshRateOverlay) {
@@ -489,6 +488,9 @@ void DisplayDevice::updateRefreshRateOverlayRate(Fps refreshRate, Fps renderFps,
    ATRACE_CALL();
    if (mRefreshRateOverlay) {
        if (!mRefreshRateOverlay->isSetByHwc() || setByHwc) {
            if (mRefreshRateSelector->isVrrDevice() && !mRefreshRateOverlay->isSetByHwc()) {
                refreshRate = renderFps;
            }
            mRefreshRateOverlay->changeRefreshRate(refreshRate, renderFps);
        } else {
            mRefreshRateOverlay->changeRenderRate(renderFps);
+6 −12
Original line number Diff line number Diff line
@@ -200,19 +200,13 @@ auto RefreshRateOverlay::getOrCreateBuffers(Fps refreshRate, Fps renderFps) -> c
    BufferCache::const_iterator it =
            mBufferCache.find({refreshRate.getIntValue(), renderFps.getIntValue(), transformHint});
    if (it == mBufferCache.end()) {
        // HWC minFps is not known by the framework in order
        // to consider lower rates we set minFps to 0.
        const int minFps = isSetByHwc() ? 0 : mFpsRange.min.getIntValue();
        const int maxFps = mFpsRange.max.getIntValue();

        // Clamp to the range. The current refreshRate may be outside of this range if the display
        // has changed its set of supported refresh rates.
        const int displayIntFps = std::clamp(refreshRate.getIntValue(), minFps, maxFps);
        // Clamp to supported refresh rate range: the current refresh rate may be outside of this
        // range if the display has changed its set of supported refresh rates.
        const int refreshIntFps = std::clamp(refreshRate.getIntValue(), 0, maxFps);
        const int renderIntFps = renderFps.getIntValue();

        // Ensure non-zero range to avoid division by zero.
        const float fpsScale =
                static_cast<float>(displayIntFps - minFps) / std::max(1, maxFps - minFps);
        const float fpsScale = static_cast<float>(refreshIntFps) / maxFps;

        constexpr SkColor kMinFpsColor = SK_ColorRED;
        constexpr SkColor kMaxFpsColor = SK_ColorGREEN;
@@ -228,9 +222,9 @@ auto RefreshRateOverlay::getOrCreateBuffers(Fps refreshRate, Fps renderFps) -> c

        const SkColor color = colorBase.toSkColor();

        auto buffers = draw(displayIntFps, renderIntFps, color, transformHint, mFeatures);
        auto buffers = draw(refreshIntFps, renderIntFps, color, transformHint, mFeatures);
        it = mBufferCache
                     .try_emplace({displayIntFps, renderIntFps, transformHint}, std::move(buffers))
                     .try_emplace({refreshIntFps, renderIntFps, transformHint}, std::move(buffers))
                     .first;
    }

+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ private:

    using Buffers = std::vector<sp<GraphicBuffer>>;

    static Buffers draw(int vsyncRate, int renderFps, SkColor, ui::Transform::RotationFlags,
    static Buffers draw(int refreshRate, int renderFps, SkColor, ui::Transform::RotationFlags,
                        ftl::Flags<Features>);
    static void drawNumber(int number, int left, SkColor, SkCanvas&);