SF: Use snapshots for TrustedPresentationListener updates
Also pass the correct display to
the compute function.
Bug: 238781169
Test: presubmit
Change-Id: I465f275fa1247ff98b4d578a26416d8c100170de
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 7a4b337..8cf25af 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -254,7 +254,7 @@
}
if (hasTrustedPresentationListener()) {
mFlinger->mNumTrustedPresentationListeners--;
- updateTrustedPresentationState(nullptr, -1 /* time_in_ms */, true /* leaveState*/);
+ updateTrustedPresentationState(nullptr, nullptr, -1 /* time_in_ms */, true /* leaveState*/);
}
}
@@ -285,7 +285,7 @@
mRemovedFromDrawingState = true;
mFlinger->mScheduler->deregisterLayer(this);
}
- updateTrustedPresentationState(nullptr, -1 /* time_in_ms */, true /* leaveState*/);
+ updateTrustedPresentationState(nullptr, nullptr, -1 /* time_in_ms */, true /* leaveState*/);
mFlinger->markLayerPendingRemovalLocked(sp<Layer>::fromExisting(this));
}
@@ -384,8 +384,9 @@
}
// No early returns.
-void Layer::updateTrustedPresentationState(const DisplayDevice* display, int64_t time_in_ms,
- bool leaveState) {
+void Layer::updateTrustedPresentationState(const DisplayDevice* display,
+ const frontend::LayerSnapshot* snapshot,
+ int64_t time_in_ms, bool leaveState) {
if (!hasTrustedPresentationListener()) {
return;
}
@@ -394,12 +395,13 @@
if (!leaveState) {
const auto outputLayer = findOutputLayerForDisplay(display);
- if (outputLayer != nullptr) {
+ if (outputLayer != nullptr && snapshot != nullptr) {
mLastComputedTrustedPresentationState =
- computeTrustedPresentationState(mBounds, mSourceBounds,
+ computeTrustedPresentationState(snapshot->geomLayerBounds,
+ snapshot->sourceBounds(),
outputLayer->getState().coveredRegion,
- mScreenBounds, getCompositionState()->alpha,
- getCompositionState()->geomLayerTransform,
+ snapshot->transformedBounds, snapshot->alpha,
+ snapshot->geomLayerTransform,
mTrustedPresentationThresholds);
}
}