SF Generalization of Refresh Rates: Adding layer priority hint
Test: Device boots. Observe logs for errors.
Test: Open Swappy and Chrome in split screen, tap between apps,
SF prints the correct priority.
Test: Open Chrome, play video. SF prints correct priority.
Test: SF prints the correct priority received.
Bug: 142507166
Change-Id: I5fa8a857c950db01f42a380a72d098039badc289
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index a7c4f46..8b448ff 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -110,6 +110,9 @@
}
}
output.writeFloat(shadowRadius);
+
+ output.writeInt32(frameRateSelectionPriority);
+
return NO_ERROR;
}
@@ -188,6 +191,9 @@
listeners.emplace_back(listener, callbackIds);
}
shadowRadius = input.readFloat();
+
+ frameRateSelectionPriority = input.readInt32();
+
return NO_ERROR;
}
@@ -406,12 +412,14 @@
what |= eMetadataChanged;
metadata.merge(other.metadata);
}
-
if (other.what & eShadowRadiusChanged) {
what |= eShadowRadiusChanged;
shadowRadius = other.shadowRadius;
}
-
+ if (other.what & eFrameRateSelectionPriority) {
+ what |= eFrameRateSelectionPriority;
+ frameRateSelectionPriority = other.frameRateSelectionPriority;
+ }
if ((other.what & what) != other.what) {
ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
"other.what=0x%" PRIu64 " what=0x%" PRIu64,
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 5e259e2..2ef33cf 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1192,6 +1192,22 @@
}
SurfaceComposerClient::Transaction&
+SurfaceComposerClient::Transaction::setFrameRateSelectionPriority(const sp<SurfaceControl>& sc,
+ int32_t priority) {
+ layer_state_t* s = getLayerState(sc);
+ if (!s) {
+ mStatus = BAD_INDEX;
+ return *this;
+ }
+
+ s->what |= layer_state_t::eFrameRateSelectionPriority;
+ s->frameRateSelectionPriority = priority;
+
+ registerSurfaceControlForCallback(sc);
+ return *this;
+}
+
+SurfaceComposerClient::Transaction&
SurfaceComposerClient::Transaction::addTransactionCompletedCallback(
TransactionCompletedCallbackTakesContext callback, void* callbackContext) {
auto listener = TransactionCompletedListener::getInstance();
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index fb18639..03e91c4 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -99,6 +99,7 @@
eBackgroundColorChanged = 0x4'00000000,
eMetadataChanged = 0x8'00000000,
eColorSpaceAgnosticChanged = 0x10'00000000,
+ eFrameRateSelectionPriority = 0x20'00000000,
};
layer_state_t()
@@ -128,7 +129,8 @@
bgColorAlpha(0),
bgColorDataspace(ui::Dataspace::UNKNOWN),
colorSpaceAgnostic(false),
- shadowRadius(0.0f) {
+ shadowRadius(0.0f),
+ frameRateSelectionPriority(-1) {
matrix.dsdx = matrix.dtdy = 1.0f;
matrix.dsdy = matrix.dtdx = 0.0f;
hdrMetadata.validTypes = 0;
@@ -209,6 +211,9 @@
// Draws a shadow around the surface.
float shadowRadius;
+
+ // Priority of the layer assigned by Window Manager.
+ int32_t frameRateSelectionPriority;
};
struct ComposerState {
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 44f29ea..6a3f452 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -483,6 +483,9 @@
Transaction& setDesiredPresentTime(nsecs_t desiredPresentTime);
Transaction& setColorSpaceAgnostic(const sp<SurfaceControl>& sc, const bool agnostic);
+ // Sets information about the priority of the frame.
+ Transaction& setFrameRateSelectionPriority(const sp<SurfaceControl>& sc, int32_t priority);
+
Transaction& addTransactionCompletedCallback(
TransactionCompletedCallbackTakesContext callback, void* callbackContext);