summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/gui/include/gui/LayerState.h2
-rw-r--r--services/surfaceflinger/CompositionEngine/src/Output.cpp2
-rw-r--r--services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp8
-rw-r--r--services/surfaceflinger/FrontEnd/LayerSnapshot.cpp2
-rw-r--r--services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp70
5 files changed, 54 insertions, 30 deletions
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index 1c31e46cb4..64f191b867 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -425,7 +425,7 @@ struct layer_state_t {
PictureProfileHandle pictureProfileHandle{PictureProfileHandle::NONE};
// A value indicating the significance of the layer's content to the app's desired user
- // experience. A lower priority will result in more likelihood of getting access to limited
+ // experience. A higher value will result in more likelihood of getting access to limited
// resources, such as picture processing hardware.
int32_t appContentPriority = 0;
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index 4c55615efc..734d76404e 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -810,7 +810,7 @@ void Output::commitPictureProfilesToCompositionState() {
}
auto compare = [](const ::android::compositionengine::OutputLayer* lhs,
const ::android::compositionengine::OutputLayer* rhs) {
- return lhs->getPictureProfilePriority() > rhs->getPictureProfilePriority();
+ return lhs->getPictureProfilePriority() < rhs->getPictureProfilePriority();
};
std::priority_queue<::android::compositionengine::OutputLayer*,
std::vector<::android::compositionengine::OutputLayer*>, decltype(compare)>
diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
index 109d3ed55e..09ad9fa497 100644
--- a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
@@ -5100,14 +5100,14 @@ TEST_F(OutputUpdateAndWriteCompositionStateTest, assignsDisplayProfileBasedOnLay
InjectedLayer layer1;
injectOutputLayer(layer1);
PictureProfileHandle profileForLayer1(1);
- EXPECT_CALL(*layer1.outputLayer, getPictureProfilePriority()).WillRepeatedly(Return(3));
+ EXPECT_CALL(*layer1.outputLayer, getPictureProfilePriority()).WillRepeatedly(Return(1));
EXPECT_CALL(*layer1.outputLayer, getPictureProfileHandle())
.WillRepeatedly(ReturnRef(profileForLayer1));
InjectedLayer layer2;
injectOutputLayer(layer2);
PictureProfileHandle profileForLayer2(2);
- EXPECT_CALL(*layer2.outputLayer, getPictureProfilePriority()).WillRepeatedly(Return(1));
+ EXPECT_CALL(*layer2.outputLayer, getPictureProfilePriority()).WillRepeatedly(Return(3));
EXPECT_CALL(*layer2.outputLayer, getPictureProfileHandle())
.WillRepeatedly(ReturnRef(profileForLayer2));
@@ -5163,14 +5163,14 @@ TEST_F(OutputUpdateAndWriteCompositionStateTest, assignsLayerProfileBasedOnLayer
InjectedLayer layer1;
injectOutputLayer(layer1);
PictureProfileHandle profileForLayer1(1);
- EXPECT_CALL(*layer1.outputLayer, getPictureProfilePriority()).WillRepeatedly(Return(3));
+ EXPECT_CALL(*layer1.outputLayer, getPictureProfilePriority()).WillRepeatedly(Return(1));
EXPECT_CALL(*layer1.outputLayer, getPictureProfileHandle())
.WillRepeatedly(ReturnRef(profileForLayer1));
InjectedLayer layer2;
injectOutputLayer(layer2);
PictureProfileHandle profileForLayer2(2);
- EXPECT_CALL(*layer2.outputLayer, getPictureProfilePriority()).WillRepeatedly(Return(1));
+ EXPECT_CALL(*layer2.outputLayer, getPictureProfilePriority()).WillRepeatedly(Return(3));
EXPECT_CALL(*layer2.outputLayer, getPictureProfileHandle())
.WillRepeatedly(ReturnRef(profileForLayer2));
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
index 58f6b96e57..367132c113 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
@@ -418,7 +418,7 @@ void LayerSnapshot::merge(const RequestedLayerState& requested, bool forceUpdate
}
if (forceUpdate || requested.what & layer_state_t::eAppContentPriorityChanged) {
// TODO(b/337330263): Also consider the system-determined priority of the app
- pictureProfilePriority = requested.appContentPriority;
+ pictureProfilePriority = int64_t(requested.appContentPriority) + INT_MAX;
}
if (forceUpdate || requested.what & layer_state_t::eDefaultFrameRateCompatibilityChanged) {
diff --git a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
index 8c53eef01a..4d322efe86 100644
--- a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
+++ b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
@@ -2021,16 +2021,13 @@ TEST_F(LayerSnapshotTest, contentDirtyWhenParentGeometryChanges) {
EXPECT_FALSE(getSnapshot(1)->contentDirty);
}
TEST_F(LayerSnapshotTest, shouldUpdatePictureProfileHandle) {
- if (!com_android_graphics_libgui_flags_apply_picture_profiles()) {
- GTEST_SKIP() << "Flag disabled, skipping test";
- }
std::vector<TransactionState> transactions;
transactions.emplace_back();
transactions.back().states.push_back({});
- transactions.back().states.front().layerId = 1;
- transactions.back().states.front().state.layerId = 1;
- transactions.back().states.front().state.what = layer_state_t::ePictureProfileHandleChanged;
- transactions.back().states.front().state.pictureProfileHandle = PictureProfileHandle(3);
+ transactions.back().states.back().layerId = 1;
+ transactions.back().states.back().state.layerId = 1;
+ transactions.back().states.back().state.what = layer_state_t::ePictureProfileHandleChanged;
+ transactions.back().states.back().state.pictureProfileHandle = PictureProfileHandle(3);
mLifecycleManager.applyTransactions(transactions);
EXPECT_EQ(mLifecycleManager.getGlobalChanges(), RequestedLayerState::Changes::Content);
@@ -2042,23 +2039,50 @@ TEST_F(LayerSnapshotTest, shouldUpdatePictureProfileHandle) {
}
TEST_F(LayerSnapshotTest, shouldUpdatePictureProfilePriorityFromAppContentPriority) {
- if (!com_android_graphics_libgui_flags_apply_picture_profiles()) {
- GTEST_SKIP() << "Flag disabled, skipping test";
+ {
+ std::vector<TransactionState> transactions;
+ transactions.emplace_back();
+ transactions.back().states.push_back({});
+ transactions.back().states.back().layerId = 1;
+ transactions.back().states.back().state.layerId = 1;
+ transactions.back().states.back().state.what = layer_state_t::eAppContentPriorityChanged;
+ transactions.back().states.back().state.appContentPriority = 1;
+ transactions.back().states.push_back({});
+ transactions.back().states.back().layerId = 2;
+ transactions.back().states.back().state.layerId = 2;
+ transactions.back().states.back().state.what = layer_state_t::eAppContentPriorityChanged;
+ transactions.back().states.back().state.appContentPriority = -1;
+
+ mLifecycleManager.applyTransactions(transactions);
+ EXPECT_EQ(mLifecycleManager.getGlobalChanges(), RequestedLayerState::Changes::Content);
+
+ update(mSnapshotBuilder);
+
+ EXPECT_GT(getSnapshot(1)->pictureProfilePriority, getSnapshot(2)->pictureProfilePriority);
+ EXPECT_EQ(getSnapshot(1)->pictureProfilePriority - getSnapshot(2)->pictureProfilePriority,
+ 2);
+ }
+ {
+ std::vector<TransactionState> transactions;
+ transactions.emplace_back();
+ transactions.back().states.push_back({});
+ transactions.back().states.back().layerId = 1;
+ transactions.back().states.back().state.layerId = 1;
+ transactions.back().states.back().state.what = layer_state_t::eAppContentPriorityChanged;
+ transactions.back().states.back().state.appContentPriority = INT_MIN;
+ transactions.back().states.push_back({});
+ transactions.back().states.back().layerId = 2;
+ transactions.back().states.back().state.layerId = 2;
+ transactions.back().states.back().state.what = layer_state_t::eAppContentPriorityChanged;
+ transactions.back().states.back().state.appContentPriority = INT_MAX;
+
+ mLifecycleManager.applyTransactions(transactions);
+ EXPECT_EQ(mLifecycleManager.getGlobalChanges(), RequestedLayerState::Changes::Content);
+
+ update(mSnapshotBuilder);
+
+ EXPECT_GT(getSnapshot(2)->pictureProfilePriority, getSnapshot(1)->pictureProfilePriority);
}
- std::vector<TransactionState> transactions;
- transactions.emplace_back();
- transactions.back().states.push_back({});
- transactions.back().states.front().layerId = 1;
- transactions.back().states.front().state.layerId = 1;
- transactions.back().states.front().state.what = layer_state_t::eAppContentPriorityChanged;
- transactions.back().states.front().state.appContentPriority = 3;
-
- mLifecycleManager.applyTransactions(transactions);
- EXPECT_EQ(mLifecycleManager.getGlobalChanges(), RequestedLayerState::Changes::Content);
-
- update(mSnapshotBuilder);
-
- EXPECT_EQ(getSnapshot(1)->pictureProfilePriority, 3);
}
} // namespace android::surfaceflinger::frontend