summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/surfaceflinger/FrontEnd/LayerSnapshot.cpp9
-rw-r--r--services/surfaceflinger/FrontEnd/LayerSnapshot.h2
-rw-r--r--services/surfaceflinger/Layer.cpp2
-rw-r--r--services/surfaceflinger/Scheduler/LayerHistory.cpp10
-rw-r--r--services/surfaceflinger/Scheduler/LayerHistory.h4
-rw-r--r--services/surfaceflinger/Scheduler/Scheduler.cpp5
-rw-r--r--services/surfaceflinger/Scheduler/Scheduler.h2
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp13
-rw-r--r--services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp9
9 files changed, 42 insertions, 14 deletions
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
index 899d2dedaf..f9c8e812dd 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
@@ -398,6 +398,15 @@ void LayerSnapshot::merge(const RequestedLayerState& requested, bool forceUpdate
geomCrop = requested.crop;
}
+ if (forceUpdate || requested.what & layer_state_t::eDefaultFrameRateCompatibilityChanged) {
+ const auto compatibility =
+ Layer::FrameRate::convertCompatibility(requested.defaultFrameRateCompatibility);
+ if (defaultFrameRateCompatibility != compatibility) {
+ clientChanges |= layer_state_t::eDefaultFrameRateCompatibilityChanged;
+ }
+ defaultFrameRateCompatibility = compatibility;
+ }
+
if (forceUpdate ||
requested.what &
(layer_state_t::eFlagsChanged | layer_state_t::eBufferChanged |
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshot.h b/services/surfaceflinger/FrontEnd/LayerSnapshot.h
index a5e9368565..a1c72a94e0 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshot.h
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshot.h
@@ -86,6 +86,8 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState {
gui::GameMode gameMode;
scheduler::LayerInfo::FrameRate frameRate;
scheduler::LayerInfo::FrameRateSelectionStrategy frameRateSelectionStrategy;
+ scheduler::FrameRateCompatibility defaultFrameRateCompatibility =
+ scheduler::FrameRateCompatibility::Default;
ui::Transform::RotationFlags fixedTransformHint;
std::optional<ui::Transform::RotationFlags> transformHint;
bool handleSkipScreenshotFlag = false;
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 415f55ae66..5ae29990dc 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1155,7 +1155,7 @@ bool Layer::setDefaultFrameRateCompatibility(FrameRateCompatibility compatibilit
if (mDrawingState.defaultFrameRateCompatibility == compatibility) return false;
mDrawingState.defaultFrameRateCompatibility = compatibility;
mDrawingState.modified = true;
- mFlinger->mScheduler->setDefaultFrameRateCompatibility(this);
+ mFlinger->mScheduler->setDefaultFrameRateCompatibility(sequence, compatibility);
setTransactionFlags(eTransactionNeeded);
return true;
}
diff --git a/services/surfaceflinger/Scheduler/LayerHistory.cpp b/services/surfaceflinger/Scheduler/LayerHistory.cpp
index b98b8007ac..4e5659ec5a 100644
--- a/services/surfaceflinger/Scheduler/LayerHistory.cpp
+++ b/services/surfaceflinger/Scheduler/LayerHistory.cpp
@@ -141,20 +141,20 @@ void LayerHistory::record(int32_t id, const LayerProps& layerProps, nsecs_t pres
}
}
-void LayerHistory::setDefaultFrameRateCompatibility(Layer* layer, bool contentDetectionEnabled) {
+void LayerHistory::setDefaultFrameRateCompatibility(int32_t id,
+ FrameRateCompatibility frameRateCompatibility,
+ bool contentDetectionEnabled) {
std::lock_guard lock(mLock);
- auto id = layer->getSequence();
auto [found, layerPair] = findLayer(id);
if (found == LayerStatus::NotFound) {
// Offscreen layer
- ALOGV("%s: %s not registered", __func__, layer->getName().c_str());
+ ALOGV("%s: %d not registered", __func__, id);
return;
}
const auto& info = layerPair->second;
- info->setDefaultLayerVote(
- getVoteType(layer->getDefaultFrameRateCompatibility(), contentDetectionEnabled));
+ info->setDefaultLayerVote(getVoteType(frameRateCompatibility, contentDetectionEnabled));
}
auto LayerHistory::summarize(const RefreshRateSelector& selector, nsecs_t now) -> Summary {
diff --git a/services/surfaceflinger/Scheduler/LayerHistory.h b/services/surfaceflinger/Scheduler/LayerHistory.h
index 5750ea7898..40bda83e62 100644
--- a/services/surfaceflinger/Scheduler/LayerHistory.h
+++ b/services/surfaceflinger/Scheduler/LayerHistory.h
@@ -29,6 +29,7 @@
#include "EventThread.h"
+#include "FrameRateCompatibility.h"
#include "RefreshRateSelector.h"
namespace android {
@@ -70,7 +71,8 @@ public:
// Updates the default frame rate compatibility which takes effect when the app
// does not set a preference for refresh rate.
- void setDefaultFrameRateCompatibility(Layer*, bool contentDetectionEnabled);
+ void setDefaultFrameRateCompatibility(int32_t id, FrameRateCompatibility frameRateCompatibility,
+ bool contentDetectionEnabled);
using Summary = std::vector<RefreshRateSelector::LayerRequirement>;
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index 68e2ce9b98..76f1af9f56 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -635,8 +635,9 @@ void Scheduler::setModeChangePending(bool pending) {
mLayerHistory.setModeChangePending(pending);
}
-void Scheduler::setDefaultFrameRateCompatibility(Layer* layer) {
- mLayerHistory.setDefaultFrameRateCompatibility(layer,
+void Scheduler::setDefaultFrameRateCompatibility(
+ int32_t id, scheduler::FrameRateCompatibility frameRateCompatibility) {
+ mLayerHistory.setDefaultFrameRateCompatibility(id, frameRateCompatibility,
mFeatures.test(Feature::kContentDetection));
}
diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h
index f652bb2627..e6db654637 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.h
+++ b/services/surfaceflinger/Scheduler/Scheduler.h
@@ -232,7 +232,7 @@ public:
void recordLayerHistory(int32_t id, const LayerProps& layerProps, nsecs_t presentTime,
LayerHistory::LayerUpdateType) EXCLUDES(mDisplayLock);
void setModeChangePending(bool pending);
- void setDefaultFrameRateCompatibility(Layer*);
+ void setDefaultFrameRateCompatibility(int32_t id, scheduler::FrameRateCompatibility);
void deregisterLayer(Layer*);
void onLayerDestroyed(Layer*) EXCLUDES(mChoreographerLock);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 3f52444c40..4d8dc94db5 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2205,8 +2205,12 @@ bool SurfaceFlinger::updateLayerSnapshotsLegacy(VsyncId vsyncId, nsecs_t frameTi
void SurfaceFlinger::updateLayerHistory(const frontend::LayerSnapshot& snapshot) {
using Changes = frontend::RequestedLayerState::Changes;
- if (snapshot.path.isClone() ||
- !snapshot.changes.any(Changes::FrameRate | Changes::Buffer | Changes::Animation)) {
+ if (snapshot.path.isClone()) {
+ return;
+ }
+
+ if (!snapshot.changes.any(Changes::FrameRate | Changes::Buffer | Changes::Animation) &&
+ (snapshot.clientChanges & layer_state_t::eDefaultFrameRateCompatibilityChanged) == 0) {
return;
}
@@ -2226,6 +2230,11 @@ void SurfaceFlinger::updateLayerHistory(const frontend::LayerSnapshot& snapshot)
it->second->recordLayerHistoryAnimationTx(layerProps);
}
+ if (snapshot.clientChanges & layer_state_t::eDefaultFrameRateCompatibilityChanged) {
+ mScheduler->setDefaultFrameRateCompatibility(snapshot.sequence,
+ snapshot.defaultFrameRateCompatibility);
+ }
+
if (snapshot.changes.test(Changes::FrameRate)) {
it->second->setFrameRateForLayerTree(snapshot.frameRate, layerProps);
}
diff --git a/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp b/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp
index cc7a45c78f..549a362af3 100644
--- a/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp
+++ b/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp
@@ -165,7 +165,10 @@ TEST_F(LayerHistoryTest, singleLayerNoVoteDefaultCompatibility) {
history().record(layer->getSequence(), layer->getLayerProps(), 0, time,
LayerHistory::LayerUpdateType::Buffer);
- history().setDefaultFrameRateCompatibility(layer.get(), true /* contentDetectionEnabled */);
+ history().setDefaultFrameRateCompatibility(layer->getSequence(),
+
+ layer->getDefaultFrameRateCompatibility(),
+ true /* contentDetectionEnabled */);
EXPECT_TRUE(summarizeLayerHistory(time).empty());
EXPECT_EQ(1, activeLayerCount());
@@ -188,7 +191,9 @@ TEST_F(LayerHistoryTest, singleLayerMinVoteDefaultCompatibility) {
history().record(layer->getSequence(), layer->getLayerProps(), 0, time,
LayerHistory::LayerUpdateType::Buffer);
- history().setDefaultFrameRateCompatibility(layer.get(), true /* contentDetectionEnabled */);
+ history().setDefaultFrameRateCompatibility(layer->getSequence(),
+ layer->getDefaultFrameRateCompatibility(),
+ true /* contentDetectionEnabled */);
auto summary = summarizeLayerHistory(time);
ASSERT_EQ(1, summarizeLayerHistory(time).size());