Loading services/surfaceflinger/FrontEnd/LayerSnapshot.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -168,4 +168,11 @@ std::string LayerSnapshot::getDebugString() const { return debug.str(); } FloatRect LayerSnapshot::sourceBounds() const { if (!externalTexture) { return geomLayerBounds; } return geomBufferSize.toFloatRect(); } } // namespace android::surfaceflinger::frontend services/surfaceflinger/FrontEnd/LayerSnapshot.h +1 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState { std::string getDebugString() const; std::string getIsVisibleReason() const; bool hasInputInfo() const; FloatRect sourceBounds() const; }; } // namespace android::surfaceflinger::frontend services/surfaceflinger/Layer.cpp +10 −8 Original line number Diff line number Diff line Loading @@ -254,7 +254,7 @@ Layer::~Layer() { } if (hasTrustedPresentationListener()) { mFlinger->mNumTrustedPresentationListeners--; updateTrustedPresentationState(nullptr, -1 /* time_in_ms */, true /* leaveState*/); updateTrustedPresentationState(nullptr, nullptr, -1 /* time_in_ms */, true /* leaveState*/); } } Loading Loading @@ -285,7 +285,7 @@ void Layer::removeFromCurrentState() { 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)); } Loading Loading @@ -384,8 +384,9 @@ FloatRect Layer::getBounds(const Region& activeTransparentRegion) const { } // 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; } Loading @@ -394,12 +395,13 @@ void Layer::updateTrustedPresentationState(const DisplayDevice* display, int64_t 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); } } Loading services/surfaceflinger/Layer.h +2 −1 Original line number Diff line number Diff line Loading @@ -539,7 +539,8 @@ public: const FloatRect& screenBounds, float, const ui::Transform&, const TrustedPresentationThresholds&); void updateTrustedPresentationState(const DisplayDevice* display, int64_t time_in_ms, void updateTrustedPresentationState(const DisplayDevice* display, const frontend::LayerSnapshot* snapshot, int64_t time_in_ms, bool leaveState); inline bool hasTrustedPresentationListener() { Loading services/surfaceflinger/SurfaceFlinger.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -2772,13 +2772,23 @@ void SurfaceFlinger::postComposition(nsecs_t callTime) { } if (mNumTrustedPresentationListeners > 0) { display::DisplayMap<ui::LayerStack, const DisplayDevice*> layerStackToDisplay; { Mutex::Autolock lock(mStateLock); for (const auto& [token, display] : mDisplays) { layerStackToDisplay.emplace_or_replace(display->getLayerStack(), display.get()); } } // We avoid any reverse traversal upwards so this shouldn't be too expensive mDrawingState.traverse([&](Layer* layer) { if (!layer->hasTrustedPresentationListener()) { return; } layer->updateTrustedPresentationState(display, nanoseconds_to_milliseconds(callTime), false); const auto display = layerStackToDisplay.get(layer->getLayerSnapshot()->outputFilter.layerStack); layer->updateTrustedPresentationState(display->get(), layer->getLayerSnapshot(), nanoseconds_to_milliseconds(callTime), false); }); } Loading Loading
services/surfaceflinger/FrontEnd/LayerSnapshot.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -168,4 +168,11 @@ std::string LayerSnapshot::getDebugString() const { return debug.str(); } FloatRect LayerSnapshot::sourceBounds() const { if (!externalTexture) { return geomLayerBounds; } return geomBufferSize.toFloatRect(); } } // namespace android::surfaceflinger::frontend
services/surfaceflinger/FrontEnd/LayerSnapshot.h +1 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState { std::string getDebugString() const; std::string getIsVisibleReason() const; bool hasInputInfo() const; FloatRect sourceBounds() const; }; } // namespace android::surfaceflinger::frontend
services/surfaceflinger/Layer.cpp +10 −8 Original line number Diff line number Diff line Loading @@ -254,7 +254,7 @@ Layer::~Layer() { } if (hasTrustedPresentationListener()) { mFlinger->mNumTrustedPresentationListeners--; updateTrustedPresentationState(nullptr, -1 /* time_in_ms */, true /* leaveState*/); updateTrustedPresentationState(nullptr, nullptr, -1 /* time_in_ms */, true /* leaveState*/); } } Loading Loading @@ -285,7 +285,7 @@ void Layer::removeFromCurrentState() { 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)); } Loading Loading @@ -384,8 +384,9 @@ FloatRect Layer::getBounds(const Region& activeTransparentRegion) const { } // 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; } Loading @@ -394,12 +395,13 @@ void Layer::updateTrustedPresentationState(const DisplayDevice* display, int64_t 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); } } Loading
services/surfaceflinger/Layer.h +2 −1 Original line number Diff line number Diff line Loading @@ -539,7 +539,8 @@ public: const FloatRect& screenBounds, float, const ui::Transform&, const TrustedPresentationThresholds&); void updateTrustedPresentationState(const DisplayDevice* display, int64_t time_in_ms, void updateTrustedPresentationState(const DisplayDevice* display, const frontend::LayerSnapshot* snapshot, int64_t time_in_ms, bool leaveState); inline bool hasTrustedPresentationListener() { Loading
services/surfaceflinger/SurfaceFlinger.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -2772,13 +2772,23 @@ void SurfaceFlinger::postComposition(nsecs_t callTime) { } if (mNumTrustedPresentationListeners > 0) { display::DisplayMap<ui::LayerStack, const DisplayDevice*> layerStackToDisplay; { Mutex::Autolock lock(mStateLock); for (const auto& [token, display] : mDisplays) { layerStackToDisplay.emplace_or_replace(display->getLayerStack(), display.get()); } } // We avoid any reverse traversal upwards so this shouldn't be too expensive mDrawingState.traverse([&](Layer* layer) { if (!layer->hasTrustedPresentationListener()) { return; } layer->updateTrustedPresentationState(display, nanoseconds_to_milliseconds(callTime), false); const auto display = layerStackToDisplay.get(layer->getLayerSnapshot()->outputFilter.layerStack); layer->updateTrustedPresentationState(display->get(), layer->getLayerSnapshot(), nanoseconds_to_milliseconds(callTime), false); }); } Loading