Add smooth switch bool for setFrameRateCategory
This allows the platform to have a different behavior depending on
whether a device is MRR or dVRR. When the bool is `true`, MRR devices
(those with DisplayModes that do not have vrr config) will not change
frame rates if it would cause jank. The expected usage is to mark the
bool true when an animation is running.
Bug: 300491171
Test: atest libsurfaceflinger_unittest
Change-Id: I5e87d276c11ecc806ede3e943f0a6498a7b910c4
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 613721e..fd8fc8d 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -85,6 +85,7 @@
changeFrameRateStrategy(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS),
defaultFrameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
frameRateCategory(ANATIVEWINDOW_FRAME_RATE_CATEGORY_DEFAULT),
+ frameRateCategorySmoothSwitchOnly(false),
frameRateSelectionStrategy(ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_SELF),
fixedTransformHint(ui::Transform::ROT_INVALID),
autoRefresh(false),
@@ -162,6 +163,7 @@
SAFE_PARCEL(output.writeByte, changeFrameRateStrategy);
SAFE_PARCEL(output.writeByte, defaultFrameRateCompatibility);
SAFE_PARCEL(output.writeByte, frameRateCategory);
+ SAFE_PARCEL(output.writeBool, frameRateCategorySmoothSwitchOnly);
SAFE_PARCEL(output.writeByte, frameRateSelectionStrategy);
SAFE_PARCEL(output.writeUint32, fixedTransformHint);
SAFE_PARCEL(output.writeBool, autoRefresh);
@@ -296,6 +298,7 @@
SAFE_PARCEL(input.readByte, &changeFrameRateStrategy);
SAFE_PARCEL(input.readByte, &defaultFrameRateCompatibility);
SAFE_PARCEL(input.readByte, &frameRateCategory);
+ SAFE_PARCEL(input.readBool, &frameRateCategorySmoothSwitchOnly);
SAFE_PARCEL(input.readByte, &frameRateSelectionStrategy);
SAFE_PARCEL(input.readUint32, &tmpUint32);
fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32);
@@ -669,6 +672,7 @@
if (other.what & eFrameRateCategoryChanged) {
what |= eFrameRateCategoryChanged;
frameRateCategory = other.frameRateCategory;
+ frameRateCategorySmoothSwitchOnly = other.frameRateCategorySmoothSwitchOnly;
}
if (other.what & eFrameRateSelectionStrategyChanged) {
what |= eFrameRateSelectionStrategyChanged;
@@ -784,7 +788,8 @@
CHECK_DIFF(diff, eFrameRateSelectionPriority, other, frameRateSelectionPriority);
CHECK_DIFF3(diff, eFrameRateChanged, other, frameRate, frameRateCompatibility,
changeFrameRateStrategy);
- CHECK_DIFF(diff, eFrameRateCategoryChanged, other, frameRateCategory);
+ CHECK_DIFF2(diff, eFrameRateCategoryChanged, other, frameRateCategory,
+ frameRateCategorySmoothSwitchOnly);
CHECK_DIFF(diff, eFrameRateSelectionStrategyChanged, other, frameRateSelectionStrategy);
CHECK_DIFF(diff, eFixedTransformHintChanged, other, fixedTransformHint);
CHECK_DIFF(diff, eAutoRefreshChanged, other, autoRefresh);
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 8a57f92..d9d99a4 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -2098,7 +2098,7 @@
}
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrameRateCategory(
- const sp<SurfaceControl>& sc, int8_t category) {
+ const sp<SurfaceControl>& sc, int8_t category, bool smoothSwitchOnly) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
@@ -2106,6 +2106,7 @@
}
s->what |= layer_state_t::eFrameRateCategoryChanged;
s->frameRateCategory = category;
+ s->frameRateCategorySmoothSwitchOnly = smoothSwitchOnly;
return *this;
}
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index 4371007..d3cde74 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -361,6 +361,7 @@
// Frame rate category to suggest what frame rate range a surface should run.
int8_t frameRateCategory;
+ bool frameRateCategorySmoothSwitchOnly;
// Strategy of the layer for frame rate selection.
int8_t frameRateSelectionStrategy;
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 26b1fbd..bc63c41 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -686,7 +686,8 @@
Transaction& setDefaultFrameRateCompatibility(const sp<SurfaceControl>& sc,
int8_t compatibility);
- Transaction& setFrameRateCategory(const sp<SurfaceControl>& sc, int8_t category);
+ Transaction& setFrameRateCategory(const sp<SurfaceControl>& sc, int8_t category,
+ bool smoothSwitchOnly);
Transaction& setFrameRateSelectionStrategy(const sp<SurfaceControl>& sc, int8_t strategy);