Skip to content

Commit 114851e

Browse files
Ram IndaniAndroid (Google) Code Review
authored andcommitted
Merge changes from topic "getsuggestedframerate" into main
* changes: SF: Adds support for getSuggestedFrameRate api Adds support for getSuggestedFrameRate api
2 parents cd19b68 + d2a0e72 commit 114851e

8 files changed

Lines changed: 88 additions & 2 deletions

File tree

libs/gui/SurfaceComposerClient.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include <ui/DisplayMode.h>
5858
#include <ui/DisplayState.h>
5959
#include <ui/DynamicDisplayInfo.h>
60+
#include <ui/FrameRateCategoryRate.h>
6061

6162
#include <android-base/thread_annotations.h>
6263
#include <gui/LayerStatePermissions.h>
@@ -2814,6 +2815,8 @@ void SurfaceComposerClient::getDynamicDisplayInfoInternal(gui::DynamicDisplayInf
28142815
outInfo->gameContentTypeSupported = ginfo.gameContentTypeSupported;
28152816
outInfo->preferredBootDisplayMode = ginfo.preferredBootDisplayMode;
28162817
outInfo->hasArrSupport = ginfo.hasArrSupport;
2818+
outInfo->frameRateCategoryRate = ui::FrameRateCategoryRate(ginfo.frameRateCategoryRate.normal,
2819+
ginfo.frameRateCategoryRate.high);
28172820
}
28182821

28192822
status_t SurfaceComposerClient::getDynamicDisplayInfoFromId(int64_t displayId,

libs/gui/aidl/android/gui/DynamicDisplayInfo.aidl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package android.gui;
1818

1919
import android.gui.DisplayMode;
20+
import android.gui.FrameRateCategoryRate;
2021
import android.gui.HdrCapabilities;
2122

2223
// Information about a physical display which may change on hotplug reconnect.
@@ -46,4 +47,7 @@ parcelable DynamicDisplayInfo {
4647

4748
// Represents whether display supports ARR.
4849
boolean hasArrSupport;
50+
51+
// Represents frame rate for FrameRateCategory Normal and High.
52+
FrameRateCategoryRate frameRateCategoryRate;
4953
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2024 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.gui;
18+
19+
/** @hide */
20+
// Represents frame rate for FrameRateCategory Normal and High.
21+
parcelable FrameRateCategoryRate {
22+
float normal;
23+
float high;
24+
}

libs/ui/include/ui/DynamicDisplayInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <optional>
2323
#include <vector>
2424

25+
#include <ui/FrameRateCategoryRate.h>
2526
#include <ui/GraphicTypes.h>
2627
#include <ui/HdrCapabilities.h>
2728

@@ -55,6 +56,9 @@ struct DynamicDisplayInfo {
5556
std::optional<ui::DisplayMode> getActiveDisplayMode() const;
5657

5758
bool hasArrSupport;
59+
60+
// Represents frame rate for FrameRateCategory Normal and High.
61+
ui::FrameRateCategoryRate frameRateCategoryRate;
5862
};
5963

6064
} // namespace android::ui
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2024 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
namespace android::ui {
20+
21+
// Represents frame rate for FrameRateCategory Normal and High.
22+
class FrameRateCategoryRate {
23+
public:
24+
FrameRateCategoryRate(float normal = 0, float high = 0) : mNormal(normal), mHigh(high) {}
25+
26+
float getNormal() const { return mNormal; }
27+
28+
float getHigh() const { return mHigh; }
29+
30+
private:
31+
float mNormal;
32+
float mHigh;
33+
};
34+
35+
} // namespace android::ui

services/surfaceflinger/Scheduler/RefreshRateSelector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,9 +1652,9 @@ std::chrono::milliseconds RefreshRateSelector::getIdleTimerTimeout() {
16521652
FpsRange RefreshRateSelector::getFrameRateCategoryRange(FrameRateCategory category) {
16531653
switch (category) {
16541654
case FrameRateCategory::High:
1655-
return FpsRange{90_Hz, 120_Hz};
1655+
return FpsRange{kFrameRateCategoryRateHigh, 120_Hz};
16561656
case FrameRateCategory::Normal:
1657-
return FpsRange{60_Hz, 120_Hz};
1657+
return FpsRange{kFrameRateCategoryRateNormal, 120_Hz};
16581658
case FrameRateCategory::Low:
16591659
return FpsRange{48_Hz, 120_Hz};
16601660
case FrameRateCategory::HighHint:

services/surfaceflinger/Scheduler/RefreshRateSelector.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ class RefreshRateSelector {
5252
// The lowest Render Frame Rate that will ever be selected
5353
static constexpr Fps kMinSupportedFrameRate = 20_Hz;
5454

55+
// Start range for FrameRateCategory Normal and High.
56+
static constexpr Fps kFrameRateCategoryRateHigh = 90_Hz;
57+
static constexpr Fps kFrameRateCategoryRateNormal = 60_Hz;
58+
static constexpr std::pair<Fps, Fps> kFrameRateCategoryRates = {kFrameRateCategoryRateNormal,
59+
kFrameRateCategoryRateHigh};
60+
5561
class Policy {
5662
static constexpr int kAllowGroupSwitchingDefault = false;
5763

@@ -433,6 +439,8 @@ class RefreshRateSelector {
433439

434440
bool isVrrDevice() const;
435441

442+
std::pair<Fps, Fps> getFrameRateCategoryRates() const { return kFrameRateCategoryRates; }
443+
436444
private:
437445
friend struct TestableRefreshRateSelector;
438446

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
#include <ui/DisplayStatInfo.h>
9393
#include <ui/DisplayState.h>
9494
#include <ui/DynamicDisplayInfo.h>
95+
#include <ui/FrameRateCategoryRate.h>
9596
#include <ui/GraphicBufferAllocator.h>
9697
#include <ui/HdrRenderTypeUtils.h>
9798
#include <ui/LayerStack.h>
@@ -1217,6 +1218,10 @@ void SurfaceFlinger::getDynamicDisplayInfoInternal(ui::DynamicDisplayInfo*& info
12171218
info->activeDisplayModeId = ftl::to_underlying(mode.modePtr->getId());
12181219
info->renderFrameRate = mode.fps.getValue();
12191220
info->hasArrSupport = mode.modePtr->getVrrConfig() && FlagManager::getInstance().vrr_config();
1221+
1222+
const auto [normal, high] = display->refreshRateSelector().getFrameRateCategoryRates();
1223+
ui::FrameRateCategoryRate frameRateCategoryRate(normal.getValue(), high.getValue());
1224+
info->frameRateCategoryRate = frameRateCategoryRate;
12201225
info->activeColorMode = display->getCompositionDisplay()->getState().colorMode;
12211226
info->hdrCapabilities = filterOut4k30(display->getHdrCapabilities());
12221227

@@ -8496,6 +8501,9 @@ void SurfaceComposerAIDL::getDynamicDisplayInfoInternal(ui::DynamicDisplayInfo&
84968501
outInfo->activeDisplayModeId = info.activeDisplayModeId;
84978502
outInfo->renderFrameRate = info.renderFrameRate;
84988503
outInfo->hasArrSupport = info.hasArrSupport;
8504+
gui::FrameRateCategoryRate& frameRateCategoryRate = outInfo->frameRateCategoryRate;
8505+
frameRateCategoryRate.normal = info.frameRateCategoryRate.getNormal();
8506+
frameRateCategoryRate.high = info.frameRateCategoryRate.getHigh();
84998507

85008508
outInfo->supportedColorModes.clear();
85018509
outInfo->supportedColorModes.reserve(info.supportedColorModes.size());

0 commit comments

Comments
 (0)