summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
author Rachel Lee <rnlee@google.com> 2023-06-27 11:22:54 -0700
committer Rachel Lee <rnlee@google.com> 2023-08-22 13:52:42 -0700
commitce6e0044cfea1e0ee38a48714364940a9de3e49a (patch)
treec956c0f654058748d68a5396a443108950407222 /libs
parent652493db2c61804e81342bfd77f4b5e14dc02e1f (diff)
Add setFrameRateCategory surface API
Bug: 284911776 Test: atest CtsSurfaceControlTestsStaging Test: atest libsurfaceflinger_unittest Change-Id: Ia804a63198ff096d1e5ffedf6046a0350963b8ed
Diffstat (limited to 'libs')
-rw-r--r--libs/gui/LayerState.cpp8
-rw-r--r--libs/gui/SurfaceComposerClient.cpp12
-rw-r--r--libs/gui/include/gui/LayerState.h6
-rw-r--r--libs/gui/include/gui/SurfaceComposerClient.h2
-rw-r--r--libs/nativewindow/include/system/window.h36
5 files changed, 62 insertions, 2 deletions
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 2322b70d1c..e1afb524e7 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -83,6 +83,7 @@ layer_state_t::layer_state_t()
frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
changeFrameRateStrategy(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS),
defaultFrameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
+ frameRateCategory(ANATIVEWINDOW_FRAME_RATE_CATEGORY_DEFAULT),
fixedTransformHint(ui::Transform::ROT_INVALID),
autoRefresh(false),
isTrustedOverlay(false),
@@ -158,6 +159,7 @@ status_t layer_state_t::write(Parcel& output) const
SAFE_PARCEL(output.writeByte, frameRateCompatibility);
SAFE_PARCEL(output.writeByte, changeFrameRateStrategy);
SAFE_PARCEL(output.writeByte, defaultFrameRateCompatibility);
+ SAFE_PARCEL(output.writeByte, frameRateCategory);
SAFE_PARCEL(output.writeUint32, fixedTransformHint);
SAFE_PARCEL(output.writeBool, autoRefresh);
SAFE_PARCEL(output.writeBool, dimmingEnabled);
@@ -290,6 +292,7 @@ status_t layer_state_t::read(const Parcel& input)
SAFE_PARCEL(input.readByte, &frameRateCompatibility);
SAFE_PARCEL(input.readByte, &changeFrameRateStrategy);
SAFE_PARCEL(input.readByte, &defaultFrameRateCompatibility);
+ SAFE_PARCEL(input.readByte, &frameRateCategory);
SAFE_PARCEL(input.readUint32, &tmpUint32);
fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32);
SAFE_PARCEL(input.readBool, &autoRefresh);
@@ -659,6 +662,10 @@ void layer_state_t::merge(const layer_state_t& other) {
frameRateCompatibility = other.frameRateCompatibility;
changeFrameRateStrategy = other.changeFrameRateStrategy;
}
+ if (other.what & eFrameRateCategoryChanged) {
+ what |= eFrameRateCategoryChanged;
+ frameRateCategory = other.frameRateCategory;
+ }
if (other.what & eFixedTransformHintChanged) {
what |= eFixedTransformHintChanged;
fixedTransformHint = other.fixedTransformHint;
@@ -769,6 +776,7 @@ uint64_t layer_state_t::diff(const layer_state_t& other) const {
CHECK_DIFF(diff, eFrameRateSelectionPriority, other, frameRateSelectionPriority);
CHECK_DIFF3(diff, eFrameRateChanged, other, frameRate, frameRateCompatibility,
changeFrameRateStrategy);
+ CHECK_DIFF(diff, eFrameRateCategoryChanged, other, frameRateCategory);
CHECK_DIFF(diff, eFixedTransformHintChanged, other, fixedTransformHint);
CHECK_DIFF(diff, eAutoRefreshChanged, other, autoRefresh);
CHECK_DIFF(diff, eTrustedOverlayChanged, other, isTrustedOverlay);
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 78401205ff..dc35c1c60e 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -2092,6 +2092,18 @@ SurfaceComposerClient::Transaction::setDefaultFrameRateCompatibility(const sp<Su
return *this;
}
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrameRateCategory(
+ const sp<SurfaceControl>& sc, int8_t category) {
+ layer_state_t* s = getLayerState(sc);
+ if (!s) {
+ mStatus = BAD_INDEX;
+ return *this;
+ }
+ s->what |= layer_state_t::eFrameRateCategoryChanged;
+ s->frameRateCategory = category;
+ return *this;
+}
+
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFixedTransformHint(
const sp<SurfaceControl>& sc, int32_t fixedTransformHint) {
layer_state_t* s = getLayerState(sc);
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index 7aa7068538..03d52d27b5 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -181,7 +181,7 @@ struct layer_state_t {
eRelativeLayerChanged = 0x00004000,
eReparent = 0x00008000,
eColorChanged = 0x00010000,
- /* unused = 0x00020000, */
+ eFrameRateCategoryChanged = 0x00020000,
eBufferTransformChanged = 0x00040000,
eTransformToDisplayInverseChanged = 0x00080000,
eCropChanged = 0x00100000,
@@ -213,7 +213,6 @@ struct layer_state_t {
eTrustedOverlayChanged = 0x4000'00000000,
eDropInputModeChanged = 0x8000'00000000,
eExtendedRangeBrightnessChanged = 0x10000'00000000,
-
};
layer_state_t();
@@ -358,6 +357,9 @@ struct layer_state_t {
// Default frame rate compatibility used to set the layer refresh rate votetype.
int8_t defaultFrameRateCompatibility;
+ // Frame rate category to suggest what frame rate range a surface should run.
+ int8_t frameRateCategory;
+
// Set by window manager indicating the layer and all its children are
// in a different orientation than the display. The hint suggests that
// the graphic producers should receive a transform hint as if the
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index dbcbd3bd62..fd9f186663 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -675,6 +675,8 @@ public:
Transaction& setDefaultFrameRateCompatibility(const sp<SurfaceControl>& sc,
int8_t compatibility);
+ Transaction& setFrameRateCategory(const sp<SurfaceControl>& sc, int8_t category);
+
// Set by window manager indicating the layer and all its children are
// in a different orientation than the display. The hint suggests that
// the graphic producers should receive a transform hint as if the
diff --git a/libs/nativewindow/include/system/window.h b/libs/nativewindow/include/system/window.h
index edaa422e55..e158f01e8c 100644
--- a/libs/nativewindow/include/system/window.h
+++ b/libs/nativewindow/include/system/window.h
@@ -1060,6 +1060,42 @@ enum {
ANATIVEWINDOW_FRAME_RATE_MIN
};
+/*
+ * Frame rate category values that can be used in Transaction::setFrameRateCategory.
+ */
+enum {
+ /**
+ * Default value. This value can also be set to return to default behavior, such as layers
+ * without animations.
+ */
+ ANATIVEWINDOW_FRAME_RATE_CATEGORY_DEFAULT = 0,
+
+ /**
+ * The layer will explicitly not influence the frame rate.
+ * This may indicate a frame rate suitable for no animation updates (such as a cursor blinking
+ * or a sporadic update).
+ */
+ ANATIVEWINDOW_FRAME_RATE_CATEGORY_NO_PREFERENCE = 1,
+
+ /**
+ * Indicates a frame rate suitable for animations that looks fine even if played at a low frame
+ * rate.
+ */
+ ANATIVEWINDOW_FRAME_RATE_CATEGORY_LOW = 2,
+
+ /**
+ * Indicates a middle frame rate suitable for animations that do not require higher frame
+ * rates, or do not benefit from high smoothness. This is normally 60 Hz or close to it.
+ */
+ ANATIVEWINDOW_FRAME_RATE_CATEGORY_NORMAL = 3,
+
+ /**
+ * Indicates a frame rate suitable for animations that require a high frame rate, which may
+ * increase smoothness but may also increase power usage.
+ */
+ ANATIVEWINDOW_FRAME_RATE_CATEGORY_HIGH = 4
+};
+
static inline int native_window_set_frame_rate(struct ANativeWindow* window, float frameRate,
int8_t compatibility, int8_t changeFrameRateStrategy) {
return window->perform(window, NATIVE_WINDOW_SET_FRAME_RATE, (double)frameRate,