mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 18:10:37 +02:00
cleanup, fixes, update QML
This commit is contained in:
parent
a6646d8dff
commit
750c5f20f6
3 changed files with 191 additions and 140 deletions
|
@ -366,15 +366,7 @@ Flickable {
|
||||||
currentIndex: -1
|
currentIndex: -1
|
||||||
|
|
||||||
function refreshRefreshRateDropdownDisplay() {
|
function refreshRefreshRateDropdownDisplay() {
|
||||||
if (Performance.getRefreshRateProfile() === 0) {
|
refreshRateDropdown.currentIndex = Performance.getRefreshRateProfile();
|
||||||
refreshRateDropdown.currentIndex = 0;
|
|
||||||
} else if (Performance.getRefreshRateProfile() === 1) {
|
|
||||||
refreshRateDropdown.currentIndex = 1;
|
|
||||||
} else if (Performance.getRefreshRateProfile() === 2) {
|
|
||||||
refreshRateDropdown.currentIndex = 2;
|
|
||||||
} else {
|
|
||||||
refreshRateDropdown.currentIndex = 3;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
@ -386,130 +378,178 @@ Flickable {
|
||||||
refreshRateDropdown.displayText = model.get(currentIndex).text;
|
refreshRateDropdown.displayText = model.get(currentIndex).text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HifiControlsUit.SpinBox {
|
ColumnLayout {
|
||||||
id: refreshRateCustomFocusActive
|
width: parent.width
|
||||||
decimals: 0
|
Layout.topMargin: 32
|
||||||
width: 160
|
visible: refreshRateDropdown.currentIndex == 3
|
||||||
height: parent.height
|
|
||||||
suffix: " FPS"
|
|
||||||
label: "Focus Active"
|
|
||||||
minimumValue: 1.0
|
|
||||||
realStepSize: 1.0
|
|
||||||
realValue: 60.0
|
|
||||||
colorScheme: hifi.colorSchemes.dark
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
RowLayout {
|
||||||
realValue = Performance.getCustomRefreshRate(0)
|
Layout.margins: 8
|
||||||
|
|
||||||
|
HifiControlsUit.SpinBox {
|
||||||
|
id: refreshRateCustomFocusActive
|
||||||
|
decimals: 0
|
||||||
|
width: 160
|
||||||
|
height: 32
|
||||||
|
suffix: " FPS"
|
||||||
|
label: "Focus Active"
|
||||||
|
realFrom: 1
|
||||||
|
realTo: 1000
|
||||||
|
realStepSize: 15
|
||||||
|
realValue: 60
|
||||||
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
property var loaded: false
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
realValue = Performance.getCustomRefreshRate(0)
|
||||||
|
loaded = true
|
||||||
|
}
|
||||||
|
|
||||||
|
onRealValueChanged: {
|
||||||
|
if (loaded) {
|
||||||
|
Performance.setCustomRefreshRate(0, realValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onRealValueChanged: {
|
HifiControlsUit.SpinBox {
|
||||||
Performance.setCustomRefreshRate(0, realValue);
|
id: refreshRateCustomFocusInactive
|
||||||
|
decimals: 0
|
||||||
|
width: 160
|
||||||
|
height: 32
|
||||||
|
suffix: " FPS"
|
||||||
|
label: "Focus Inactive"
|
||||||
|
realFrom: 1
|
||||||
|
realTo: 1000
|
||||||
|
realStepSize: 15
|
||||||
|
realValue: 60
|
||||||
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
property var loaded: false
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
realValue = Performance.getCustomRefreshRate(1)
|
||||||
|
loaded = true
|
||||||
|
}
|
||||||
|
|
||||||
|
onRealValueChanged: {
|
||||||
|
if (loaded) {
|
||||||
|
Performance.setCustomRefreshRate(1, realValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControlsUit.SpinBox {
|
RowLayout {
|
||||||
id: refreshRateCustomFocusInactive
|
Layout.margins: 8
|
||||||
decimals: 0
|
|
||||||
width: 160
|
|
||||||
height: parent.height
|
|
||||||
suffix: " FPS"
|
|
||||||
label: "Focus Inactive"
|
|
||||||
minimumValue: 1.0
|
|
||||||
realStepSize: 1.0
|
|
||||||
realValue: 60.0
|
|
||||||
colorScheme: hifi.colorSchemes.dark
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
HifiControlsUit.SpinBox {
|
||||||
realValue = Performance.getCustomRefreshRate(1)
|
id: refreshRateCustomUnfocus
|
||||||
|
decimals: 0
|
||||||
|
width: 160
|
||||||
|
height: 32
|
||||||
|
suffix: " FPS"
|
||||||
|
label: "Unfocus"
|
||||||
|
realFrom: 1
|
||||||
|
realTo: 1000
|
||||||
|
realStepSize: 15
|
||||||
|
realValue: 60
|
||||||
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
property var loaded: false
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
realValue = Performance.getCustomRefreshRate(2)
|
||||||
|
loaded = true
|
||||||
|
}
|
||||||
|
|
||||||
|
onRealValueChanged: {
|
||||||
|
if (loaded) {
|
||||||
|
Performance.setCustomRefreshRate(2, realValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onRealValueChanged: {
|
HifiControlsUit.SpinBox {
|
||||||
Performance.setCustomRefreshRate(1, realValue);
|
id: refreshRateCustomMinimized
|
||||||
|
decimals: 0
|
||||||
|
width: 160
|
||||||
|
height: 32
|
||||||
|
suffix: " FPS"
|
||||||
|
label: "Minimized"
|
||||||
|
realFrom: 1
|
||||||
|
realTo: 1000
|
||||||
|
realStepSize: 1
|
||||||
|
realValue: 60
|
||||||
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
property var loaded: false
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
realValue = Performance.getCustomRefreshRate(3)
|
||||||
|
loaded = true
|
||||||
|
}
|
||||||
|
|
||||||
|
onRealValueChanged: {
|
||||||
|
if (loaded) {
|
||||||
|
Performance.setCustomRefreshRate(3, realValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControlsUit.SpinBox {
|
RowLayout {
|
||||||
id: refreshRateCustomUnfocus
|
Layout.margins: 8
|
||||||
decimals: 0
|
|
||||||
width: 160
|
|
||||||
height: parent.height
|
|
||||||
suffix: " FPS"
|
|
||||||
label: "Unfocus"
|
|
||||||
minimumValue: 1.0
|
|
||||||
realStepSize: 1.0
|
|
||||||
realValue: 60.0
|
|
||||||
colorScheme: hifi.colorSchemes.dark
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
HifiControlsUit.SpinBox {
|
||||||
realValue = Performance.getCustomRefreshRate(2)
|
id: refreshRateCustomStartup
|
||||||
|
decimals: 0
|
||||||
|
width: 160
|
||||||
|
height: 32
|
||||||
|
suffix: " FPS"
|
||||||
|
label: "Startup"
|
||||||
|
realFrom: 1
|
||||||
|
realTo: 1000
|
||||||
|
realStepSize: 15
|
||||||
|
realValue: 60
|
||||||
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
property var loaded: false
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
realValue = Performance.getCustomRefreshRate(4)
|
||||||
|
loaded = true
|
||||||
|
}
|
||||||
|
|
||||||
|
onRealValueChanged: {
|
||||||
|
if (loaded) {
|
||||||
|
Performance.setCustomRefreshRate(4, realValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onRealValueChanged: {
|
HifiControlsUit.SpinBox {
|
||||||
Performance.setCustomRefreshRate(2, realValue);
|
id: refreshRateCustomShutdown
|
||||||
}
|
decimals: 0
|
||||||
}
|
width: 160
|
||||||
|
height: 32
|
||||||
|
suffix: " FPS"
|
||||||
|
label: "Shutdown"
|
||||||
|
realFrom: 1
|
||||||
|
realTo: 1000
|
||||||
|
realStepSize: 15
|
||||||
|
realValue: 60
|
||||||
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
property var loaded: false
|
||||||
|
|
||||||
HifiControlsUit.SpinBox {
|
Component.onCompleted: {
|
||||||
id: refreshRateCustomMinimized
|
realValue = Performance.getCustomRefreshRate(5)
|
||||||
decimals: 0
|
loaded = true
|
||||||
width: 160
|
}
|
||||||
height: parent.height
|
|
||||||
suffix: " FPS"
|
|
||||||
label: "Minimized"
|
|
||||||
minimumValue: 1.0
|
|
||||||
realStepSize: 1.0
|
|
||||||
realValue: 60.0
|
|
||||||
colorScheme: hifi.colorSchemes.dark
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
onRealValueChanged: {
|
||||||
realValue = Performance.getCustomRefreshRate(3)
|
if (loaded) {
|
||||||
}
|
Performance.setCustomRefreshRate(5, realValue)
|
||||||
|
}
|
||||||
onRealValueChanged: {
|
}
|
||||||
Performance.setCustomRefreshRate(3, realValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HifiControlsUit.SpinBox {
|
|
||||||
id: refreshRateCustomStartup
|
|
||||||
decimals: 0
|
|
||||||
width: 160
|
|
||||||
height: parent.height
|
|
||||||
suffix: " FPS"
|
|
||||||
label: "Startup"
|
|
||||||
minimumValue: 1.0
|
|
||||||
realStepSize: 1.0
|
|
||||||
realValue: 60.0
|
|
||||||
colorScheme: hifi.colorSchemes.dark
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
realValue = Performance.getCustomRefreshRate(4)
|
|
||||||
}
|
|
||||||
|
|
||||||
onRealValueChanged: {
|
|
||||||
Performance.setCustomRefreshRate(4, realValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HifiControlsUit.SpinBox {
|
|
||||||
id: refreshRateCustomShutdown
|
|
||||||
decimals: 0
|
|
||||||
width: 160
|
|
||||||
height: parent.height
|
|
||||||
suffix: " FPS"
|
|
||||||
label: "Shutdown"
|
|
||||||
minimumValue: 1.0
|
|
||||||
realStepSize: 1.0
|
|
||||||
realValue: 60.0
|
|
||||||
colorScheme: hifi.colorSchemes.dark
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
realValue = Performance.getCustomRefreshRate(5)
|
|
||||||
}
|
|
||||||
|
|
||||||
onRealValueChanged: {
|
|
||||||
Performance.setCustomRefreshRate(5, realValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,12 +48,13 @@ static const int VR_TARGET_RATE = 90;
|
||||||
* <tr><td><code>"Interactive"</code></td><td>Medium refresh rate, which is reduced when Interface doesn't have focus or is
|
* <tr><td><code>"Interactive"</code></td><td>Medium refresh rate, which is reduced when Interface doesn't have focus or is
|
||||||
* minimized.</td></tr>
|
* minimized.</td></tr>
|
||||||
* <tr><td><code>"Realtime"</code></td><td>High refresh rate, even when Interface doesn't have focus or is minimized.
|
* <tr><td><code>"Realtime"</code></td><td>High refresh rate, even when Interface doesn't have focus or is minimized.
|
||||||
|
* <tr><td><code>"Custom"</code></td><td>Custom refresh rate for full control over the refresh rate in all states.
|
||||||
* </tbody>
|
* </tbody>
|
||||||
* </table>
|
* </table>
|
||||||
* @typedef {string} RefreshRateProfileName
|
* @typedef {string} RefreshRateProfileName
|
||||||
*/
|
*/
|
||||||
static const std::array<std::string, RefreshRateManager::RefreshRateProfile::PROFILE_NUM> REFRESH_RATE_PROFILE_TO_STRING =
|
static const std::array<std::string, RefreshRateManager::RefreshRateProfile::PROFILE_NUM> REFRESH_RATE_PROFILE_TO_STRING =
|
||||||
{ { "Eco", "Interactive", "Realtime" } };
|
{ { "Eco", "Interactive", "Realtime", "Custom" } };
|
||||||
|
|
||||||
/*@jsdoc
|
/*@jsdoc
|
||||||
* <p>Interface states that affect the refresh rate.</p>
|
* <p>Interface states that affect the refresh rate.</p>
|
||||||
|
@ -108,10 +109,12 @@ static const std::array<int, RefreshRateManager::RefreshRateRegime::REGIME_NUM>
|
||||||
{ { 30, 20, 10, 2, 30, 30 } };
|
{ { 30, 20, 10, 2, 30, 30 } };
|
||||||
|
|
||||||
static const std::array<int, RefreshRateManager::RefreshRateRegime::REGIME_NUM> REALTIME_PROFILE =
|
static const std::array<int, RefreshRateManager::RefreshRateRegime::REGIME_NUM> REALTIME_PROFILE =
|
||||||
{ { 60, 60, 60, 2, 30, 30} };
|
{ { 60, 60, 60, 2, 30, 30 } };
|
||||||
|
|
||||||
static const std::array<std::array<int, RefreshRateManager::RefreshRateRegime::REGIME_NUM>, RefreshRateManager::RefreshRateProfile::PROFILE_NUM> REFRESH_RATE_PROFILES =
|
static const std::array<int, RefreshRateManager::RefreshRateRegime::REGIME_NUM> CUSTOM_PROFILE = REALTIME_PROFILE; // derived from settings and modified by scripts below
|
||||||
{ { ECO_PROFILE, INTERACTIVE_PROFILE, REALTIME_PROFILE } };
|
|
||||||
|
static std::array<std::array<int, RefreshRateManager::RefreshRateRegime::REGIME_NUM>, RefreshRateManager::RefreshRateProfile::PROFILE_NUM> REFRESH_RATE_PROFILES =
|
||||||
|
{ { ECO_PROFILE, INTERACTIVE_PROFILE, REALTIME_PROFILE, CUSTOM_PROFILE } };
|
||||||
|
|
||||||
|
|
||||||
static const int INACTIVE_TIMER_LIMIT = 3000;
|
static const int INACTIVE_TIMER_LIMIT = 3000;
|
||||||
|
@ -135,6 +138,10 @@ std::string RefreshRateManager::uxModeToString(RefreshRateManager::RefreshRateMa
|
||||||
|
|
||||||
RefreshRateManager::RefreshRateManager() {
|
RefreshRateManager::RefreshRateManager() {
|
||||||
_refreshRateProfile = (RefreshRateManager::RefreshRateProfile) _refreshRateProfileSetting.get();
|
_refreshRateProfile = (RefreshRateManager::RefreshRateProfile) _refreshRateProfileSetting.get();
|
||||||
|
for (size_t i = 0; i < _customRefreshRateSettings.size(); i++) {
|
||||||
|
REFRESH_RATE_PROFILES[CUSTOM][i] = _customRefreshRateSettings[i].get();
|
||||||
|
}
|
||||||
|
|
||||||
_inactiveTimer->setInterval(INACTIVE_TIMER_LIMIT);
|
_inactiveTimer->setInterval(INACTIVE_TIMER_LIMIT);
|
||||||
_inactiveTimer->setSingleShot(true);
|
_inactiveTimer->setSingleShot(true);
|
||||||
QObject::connect(_inactiveTimer.get(), &QTimer::timeout, [&] {
|
QObject::connect(_inactiveTimer.get(), &QTimer::timeout, [&] {
|
||||||
|
@ -169,23 +176,23 @@ void RefreshRateManager::setRefreshRateProfile(RefreshRateManager::RefreshRatePr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int RefreshRateManager::getCustomRefreshRate(RefreshRateRegime regime)
|
int RefreshRateManager::getCustomRefreshRate(RefreshRateRegime regime) {
|
||||||
{
|
if (isValidRefreshRateRegime(regime)) {
|
||||||
Q_ASSERT(regime >= 0 && regime < RefreshRateRegime::REGIME_NUM);
|
return REFRESH_RATE_PROFILES[RefreshRateProfile::CUSTOM][regime];
|
||||||
if (regime < 0 && regime >= RefreshRateRegime::REGIME_NUM)
|
}
|
||||||
return -1;
|
|
||||||
|
|
||||||
return _customProfile[regime];
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RefreshRateManager::setCustomRefreshRate(RefreshRateRegime regime, int value)
|
void RefreshRateManager::setCustomRefreshRate(RefreshRateRegime regime, int value) {
|
||||||
{
|
value = std::max(value, 1);
|
||||||
Q_ASSERT(regime >= 0 && regime < RefreshRateRegime::REGIME_NUM);
|
if (isValidRefreshRateRegime(regime)) {
|
||||||
if (regime < 0 && regime >= RefreshRateRegime::REGIME_NUM)
|
_refreshRateProfileSettingLock.withWriteLock([&] {
|
||||||
return -1;
|
REFRESH_RATE_PROFILES[RefreshRateProfile::CUSTOM][regime] = value;
|
||||||
|
_customRefreshRateSettings[regime].set(value);
|
||||||
_customProfile[regime] = value;
|
});
|
||||||
return 0;
|
updateRefreshRateController();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshRateManager::RefreshRateProfile RefreshRateManager::getRefreshRateProfile() const {
|
RefreshRateManager::RefreshRateProfile RefreshRateManager::getRefreshRateProfile() const {
|
||||||
|
@ -211,7 +218,6 @@ void RefreshRateManager::setRefreshRateRegime(RefreshRateManager::RefreshRateReg
|
||||||
_refreshRateRegime = refreshRateRegime;
|
_refreshRateRegime = refreshRateRegime;
|
||||||
updateRefreshRateController();
|
updateRefreshRateController();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshRateManager::setUXMode(RefreshRateManager::UXMode uxMode) {
|
void RefreshRateManager::setUXMode(RefreshRateManager::UXMode uxMode) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
PROFILE_NUM
|
PROFILE_NUM
|
||||||
};
|
};
|
||||||
Q_ENUM(RefreshRateProfile)
|
Q_ENUM(RefreshRateProfile)
|
||||||
static bool isValidRefreshRateProfile(RefreshRateProfile value) { return (value >= RefreshRateProfile::ECO && value <= RefreshRateProfile::REALTIME); }
|
static bool isValidRefreshRateProfile(RefreshRateProfile value) { return (value >= 0 && value < RefreshRateProfile::PROFILE_NUM); }
|
||||||
|
|
||||||
/*@jsdoc
|
/*@jsdoc
|
||||||
* <p>Interface states that affect the refresh rate.</p>
|
* <p>Interface states that affect the refresh rate.</p>
|
||||||
|
@ -108,7 +108,7 @@ public:
|
||||||
int queryRefreshRateTarget(RefreshRateProfile profile, RefreshRateRegime regime, UXMode uxMode) const;
|
int queryRefreshRateTarget(RefreshRateProfile profile, RefreshRateRegime regime, UXMode uxMode) const;
|
||||||
|
|
||||||
int getCustomRefreshRate(RefreshRateRegime regime);
|
int getCustomRefreshRate(RefreshRateRegime regime);
|
||||||
int setCustomRefreshRate(RefreshRateRegime regime, int value);
|
void setCustomRefreshRate(RefreshRateRegime regime, int value);
|
||||||
|
|
||||||
void resetInactiveTimer();
|
void resetInactiveTimer();
|
||||||
void toggleInactive();
|
void toggleInactive();
|
||||||
|
@ -119,16 +119,21 @@ public:
|
||||||
static std::string refreshRateRegimeToString(RefreshRateRegime refreshRateRegime);
|
static std::string refreshRateRegimeToString(RefreshRateRegime refreshRateRegime);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<int, RefreshRateRegime::REGIME_NUM> _customProfile =
|
|
||||||
{ { 0, 0, 0, 0, 0, 0 } };
|
|
||||||
|
|
||||||
mutable int _activeRefreshRate { 20 };
|
mutable int _activeRefreshRate { 20 };
|
||||||
RefreshRateProfile _refreshRateProfile { RefreshRateProfile::INTERACTIVE};
|
RefreshRateProfile _refreshRateProfile { RefreshRateProfile::INTERACTIVE};
|
||||||
RefreshRateRegime _refreshRateRegime { RefreshRateRegime::STARTUP };
|
RefreshRateRegime _refreshRateRegime { RefreshRateRegime::STARTUP };
|
||||||
UXMode _uxMode { UXMode::DESKTOP };
|
UXMode _uxMode { UXMode::DESKTOP };
|
||||||
|
|
||||||
mutable ReadWriteLockable _refreshRateProfileSettingLock;
|
mutable ReadWriteLockable _refreshRateProfileSettingLock;
|
||||||
Setting::Handle<int> _refreshRateProfileSetting { "refreshRateProfile", RefreshRateProfile::INTERACTIVE };
|
Setting::Handle<int> _refreshRateProfileSetting{ "refreshRateProfile", RefreshRateProfile::INTERACTIVE };
|
||||||
|
std::array<Setting::Handle<int>, REGIME_NUM> _customRefreshRateSettings { {
|
||||||
|
{ "customRefreshRateFocusActive", 60 },
|
||||||
|
{ "customRefreshRateFocusInactive", 60 },
|
||||||
|
{ "customRefreshRateUnfocus", 60 },
|
||||||
|
{ "customRefreshRateMinimized", 2 },
|
||||||
|
{ "customRefreshRateStartup", 30 },
|
||||||
|
{ "customRefreshRateShutdown", 30 }
|
||||||
|
} };
|
||||||
|
|
||||||
std::function<void(int)> _refreshRateOperator { nullptr };
|
std::function<void(int)> _refreshRateOperator { nullptr };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue