Loading services/surfaceflinger/Layer.cpp +17 −11 Original line number Diff line number Diff line Loading @@ -362,7 +362,7 @@ aidl::android::hardware::graphics::composer3::Composition Layer::getCompositionT // transaction // ---------------------------------------------------------------------------- void Layer::commitTransaction() { void Layer::commitTransaction() REQUIRES(mFlinger->mStateLock) { // Set the present state for all bufferlessSurfaceFramesTX to Presented. The // bufferSurfaceFrameTX will be presented in latchBuffer. for (auto& [token, surfaceFrame] : mDrawingState.bufferlessSurfaceFramesTX) { Loading Loading @@ -394,7 +394,8 @@ bool Layer::isLayerFocusedBasedOnPriority(int32_t priority) { }; void Layer::setFrameTimelineVsyncForBufferTransaction(const FrameTimelineInfo& info, nsecs_t postTime, gui::GameMode gameMode) { nsecs_t postTime, gui::GameMode gameMode) REQUIRES(mFlinger->mStateLock) { mDrawingState.postTime = postTime; // Check if one of the bufferlessSurfaceFramesTX contains the same vsyncId. This can happen if Loading Loading @@ -458,7 +459,7 @@ void Layer::addSurfaceFrameDroppedForBuffer( void Layer::addSurfaceFramePresentedForBuffer( std::shared_ptr<frametimeline::SurfaceFrame>& surfaceFrame, nsecs_t acquireFenceTime, nsecs_t currentLatchTime) { nsecs_t currentLatchTime) REQUIRES(mFlinger->mStateLock) { surfaceFrame->setAcquireFenceTime(acquireFenceTime); surfaceFrame->setPresentState(PresentState::Presented, mLastLatchTime); mFlinger->mFrameTimeline->addSurfaceFrame(surfaceFrame); Loading @@ -466,7 +467,8 @@ void Layer::addSurfaceFramePresentedForBuffer( } std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForTransaction( const FrameTimelineInfo& info, nsecs_t postTime, gui::GameMode gameMode) { const FrameTimelineInfo& info, nsecs_t postTime, gui::GameMode gameMode) REQUIRES(mFlinger->mStateLock) { auto surfaceFrame = mFlinger->mFrameTimeline->createSurfaceFrameForToken(info, mOwnerPid, mOwnerUid, getSequence(), mName, Loading @@ -488,7 +490,7 @@ std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForTransac std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForBuffer( const FrameTimelineInfo& info, nsecs_t queueTime, std::string debugName, gui::GameMode gameMode) { gui::GameMode gameMode) REQUIRES(mFlinger->mStateLock) { auto surfaceFrame = mFlinger->mFrameTimeline->createSurfaceFrameForToken(info, mOwnerPid, mOwnerUid, getSequence(), mName, debugName, Loading @@ -506,7 +508,8 @@ std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForBuffer( } void Layer::setFrameTimelineVsyncForSkippedFrames(const FrameTimelineInfo& info, nsecs_t postTime, std::string debugName, gui::GameMode gameMode) { std::string debugName, gui::GameMode gameMode) REQUIRES(mFlinger->mStateLock) { if (info.skippedFrameVsyncId == FrameTimelineInfo::INVALID_VSYNC_ID) { return; } Loading Loading @@ -842,7 +845,7 @@ bool Layer::setTransformToDisplayInverse(bool transformToDisplayInverse) { return true; } void Layer::releasePreviousBuffer() { void Layer::releasePreviousBuffer() REQUIRES(mFlinger->mStateLock) { mReleasePreviousBuffer = true; if (!mBufferInfo.mBuffer || (!mDrawingState.buffer->hasSameBuffer(*mBufferInfo.mBuffer) || Loading Loading @@ -884,7 +887,8 @@ void Layer::resetDrawingStateBufferInfo() { bool Layer::setBuffer(std::shared_ptr<renderengine::ExternalTexture>& buffer, const BufferData& bufferData, nsecs_t postTime, nsecs_t desiredPresentTime, bool isAutoTimestamp, const FrameTimelineInfo& info, gui::GameMode gameMode) { bool isAutoTimestamp, const FrameTimelineInfo& info, gui::GameMode gameMode) REQUIRES(mFlinger->mStateLock) { SFTRACE_FORMAT("setBuffer %s - hasBuffer=%s", getDebugName(), (buffer ? "true" : "false")); const bool frameNumberChanged = Loading Loading @@ -1074,7 +1078,8 @@ bool Layer::setDesiredHdrHeadroom(float desiredRatio) { } bool Layer::setSidebandStream(const sp<NativeHandle>& sidebandStream, const FrameTimelineInfo& info, nsecs_t postTime, gui::GameMode gameMode) { nsecs_t postTime, gui::GameMode gameMode) REQUIRES(mFlinger->mStateLock) { if (mDrawingState.sidebandStream == sidebandStream) return false; if (mDrawingState.sidebandStream != nullptr && sidebandStream == nullptr) { Loading Loading @@ -1207,7 +1212,7 @@ bool Layer::latchSidebandStream(bool& recomputeVisibleRegions) { return false; } void Layer::updateTexImage(nsecs_t latchTime, bool bgColorOnly) { void Layer::updateTexImage(nsecs_t latchTime, bool bgColorOnly) REQUIRES(mFlinger->mStateLock) { const State& s(getDrawingState()); if (!s.buffer) { Loading Loading @@ -1457,7 +1462,8 @@ void Layer::onCompositionPresented(const DisplayDevice* display, mBufferInfo.mFrameLatencyNeeded = false; } bool Layer::latchBufferImpl(bool& recomputeVisibleRegions, nsecs_t latchTime, bool bgColorOnly) { bool Layer::latchBufferImpl(bool& recomputeVisibleRegions, nsecs_t latchTime, bool bgColorOnly) REQUIRES(mFlinger->mStateLock) { SFTRACE_FORMAT_INSTANT("latchBuffer %s - %" PRIu64, getDebugName(), getDrawingState().frameNumber); Loading services/surfaceflinger/SurfaceFlinger.cpp +15 −14 Original line number Diff line number Diff line Loading @@ -2483,7 +2483,8 @@ void SurfaceFlinger::updateLayerHistory(nsecs_t now) { } bool SurfaceFlinger::updateLayerSnapshots(VsyncId vsyncId, nsecs_t frameTimeNs, bool flushTransactions, bool& outTransactionsAreEmpty) { bool flushTransactions, bool& outTransactionsAreEmpty) EXCLUDES(mStateLock) { using Changes = frontend::RequestedLayerState::Changes; SFTRACE_CALL(); SFTRACE_NAME_FOR_TRACK(WorkloadTracer::TRACK_NAME, "Transaction Handling"); Loading Loading @@ -2680,7 +2681,7 @@ bool SurfaceFlinger::updateLayerSnapshots(VsyncId vsyncId, nsecs_t frameTimeNs, } bool SurfaceFlinger::commit(PhysicalDisplayId pacesetterId, const scheduler::FrameTargets& frameTargets) { const scheduler::FrameTargets& frameTargets) EXCLUDES(mStateLock) { const scheduler::FrameTarget& pacesetterFrameTarget = *frameTargets.get(pacesetterId)->get(); const VsyncId vsyncId = pacesetterFrameTarget.vsyncId(); Loading Loading @@ -4893,12 +4894,14 @@ bool SurfaceFlinger::flushTransactionQueues() { return applyTransactions(transactions); } bool SurfaceFlinger::applyTransactions(std::vector<QueuedTransactionState>& transactions) { bool SurfaceFlinger::applyTransactions(std::vector<QueuedTransactionState>& transactions) EXCLUDES(mStateLock) { Mutex::Autolock lock(mStateLock); return applyTransactionsLocked(transactions); } bool SurfaceFlinger::applyTransactionsLocked(std::vector<QueuedTransactionState>& transactions) { bool SurfaceFlinger::applyTransactionsLocked(std::vector<QueuedTransactionState>& transactions) REQUIRES(mStateLock) { bool needsTraversal = false; // Now apply all transactions. for (auto& transaction : transactions) { Loading Loading @@ -5115,15 +5118,13 @@ status_t SurfaceFlinger::setTransactionState( return NO_ERROR; } bool SurfaceFlinger::applyTransactionState(const FrameTimelineInfo& frameTimelineInfo, std::vector<ResolvedComposerState>& states, bool SurfaceFlinger::applyTransactionState( const FrameTimelineInfo& frameTimelineInfo, std::vector<ResolvedComposerState>& states, Vector<DisplayState>& displays, uint32_t flags, const InputWindowCommands& inputWindowCommands, const int64_t desiredPresentTime, bool isAutoTimestamp, const std::vector<uint64_t>& uncacheBufferIds, const int64_t postTime, bool hasListenerCallbacks, const std::vector<ListenerCallbacks>& listenerCallbacks, int originPid, int originUid, uint64_t transactionId) { const InputWindowCommands& inputWindowCommands, const int64_t desiredPresentTime, bool isAutoTimestamp, const std::vector<uint64_t>& uncacheBufferIds, const int64_t postTime, bool hasListenerCallbacks, const std::vector<ListenerCallbacks>& listenerCallbacks, int originPid, int originUid, uint64_t transactionId) REQUIRES(mStateLock) { uint32_t transactionFlags = 0; // start and end registration for listeners w/ no surface so they can get their callback. Note Loading Loading @@ -5275,7 +5276,7 @@ uint32_t SurfaceFlinger::updateLayerCallbacksAndStats(const FrameTimelineInfo& f ResolvedComposerState& composerState, int64_t desiredPresentTime, bool isAutoTimestamp, int64_t postTime, uint64_t transactionId) { uint64_t transactionId) REQUIRES(mStateLock) { layer_state_t& s = composerState.state; std::vector<ListenerCallbacks> filteredListeners; Loading Loading
services/surfaceflinger/Layer.cpp +17 −11 Original line number Diff line number Diff line Loading @@ -362,7 +362,7 @@ aidl::android::hardware::graphics::composer3::Composition Layer::getCompositionT // transaction // ---------------------------------------------------------------------------- void Layer::commitTransaction() { void Layer::commitTransaction() REQUIRES(mFlinger->mStateLock) { // Set the present state for all bufferlessSurfaceFramesTX to Presented. The // bufferSurfaceFrameTX will be presented in latchBuffer. for (auto& [token, surfaceFrame] : mDrawingState.bufferlessSurfaceFramesTX) { Loading Loading @@ -394,7 +394,8 @@ bool Layer::isLayerFocusedBasedOnPriority(int32_t priority) { }; void Layer::setFrameTimelineVsyncForBufferTransaction(const FrameTimelineInfo& info, nsecs_t postTime, gui::GameMode gameMode) { nsecs_t postTime, gui::GameMode gameMode) REQUIRES(mFlinger->mStateLock) { mDrawingState.postTime = postTime; // Check if one of the bufferlessSurfaceFramesTX contains the same vsyncId. This can happen if Loading Loading @@ -458,7 +459,7 @@ void Layer::addSurfaceFrameDroppedForBuffer( void Layer::addSurfaceFramePresentedForBuffer( std::shared_ptr<frametimeline::SurfaceFrame>& surfaceFrame, nsecs_t acquireFenceTime, nsecs_t currentLatchTime) { nsecs_t currentLatchTime) REQUIRES(mFlinger->mStateLock) { surfaceFrame->setAcquireFenceTime(acquireFenceTime); surfaceFrame->setPresentState(PresentState::Presented, mLastLatchTime); mFlinger->mFrameTimeline->addSurfaceFrame(surfaceFrame); Loading @@ -466,7 +467,8 @@ void Layer::addSurfaceFramePresentedForBuffer( } std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForTransaction( const FrameTimelineInfo& info, nsecs_t postTime, gui::GameMode gameMode) { const FrameTimelineInfo& info, nsecs_t postTime, gui::GameMode gameMode) REQUIRES(mFlinger->mStateLock) { auto surfaceFrame = mFlinger->mFrameTimeline->createSurfaceFrameForToken(info, mOwnerPid, mOwnerUid, getSequence(), mName, Loading @@ -488,7 +490,7 @@ std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForTransac std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForBuffer( const FrameTimelineInfo& info, nsecs_t queueTime, std::string debugName, gui::GameMode gameMode) { gui::GameMode gameMode) REQUIRES(mFlinger->mStateLock) { auto surfaceFrame = mFlinger->mFrameTimeline->createSurfaceFrameForToken(info, mOwnerPid, mOwnerUid, getSequence(), mName, debugName, Loading @@ -506,7 +508,8 @@ std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForBuffer( } void Layer::setFrameTimelineVsyncForSkippedFrames(const FrameTimelineInfo& info, nsecs_t postTime, std::string debugName, gui::GameMode gameMode) { std::string debugName, gui::GameMode gameMode) REQUIRES(mFlinger->mStateLock) { if (info.skippedFrameVsyncId == FrameTimelineInfo::INVALID_VSYNC_ID) { return; } Loading Loading @@ -842,7 +845,7 @@ bool Layer::setTransformToDisplayInverse(bool transformToDisplayInverse) { return true; } void Layer::releasePreviousBuffer() { void Layer::releasePreviousBuffer() REQUIRES(mFlinger->mStateLock) { mReleasePreviousBuffer = true; if (!mBufferInfo.mBuffer || (!mDrawingState.buffer->hasSameBuffer(*mBufferInfo.mBuffer) || Loading Loading @@ -884,7 +887,8 @@ void Layer::resetDrawingStateBufferInfo() { bool Layer::setBuffer(std::shared_ptr<renderengine::ExternalTexture>& buffer, const BufferData& bufferData, nsecs_t postTime, nsecs_t desiredPresentTime, bool isAutoTimestamp, const FrameTimelineInfo& info, gui::GameMode gameMode) { bool isAutoTimestamp, const FrameTimelineInfo& info, gui::GameMode gameMode) REQUIRES(mFlinger->mStateLock) { SFTRACE_FORMAT("setBuffer %s - hasBuffer=%s", getDebugName(), (buffer ? "true" : "false")); const bool frameNumberChanged = Loading Loading @@ -1074,7 +1078,8 @@ bool Layer::setDesiredHdrHeadroom(float desiredRatio) { } bool Layer::setSidebandStream(const sp<NativeHandle>& sidebandStream, const FrameTimelineInfo& info, nsecs_t postTime, gui::GameMode gameMode) { nsecs_t postTime, gui::GameMode gameMode) REQUIRES(mFlinger->mStateLock) { if (mDrawingState.sidebandStream == sidebandStream) return false; if (mDrawingState.sidebandStream != nullptr && sidebandStream == nullptr) { Loading Loading @@ -1207,7 +1212,7 @@ bool Layer::latchSidebandStream(bool& recomputeVisibleRegions) { return false; } void Layer::updateTexImage(nsecs_t latchTime, bool bgColorOnly) { void Layer::updateTexImage(nsecs_t latchTime, bool bgColorOnly) REQUIRES(mFlinger->mStateLock) { const State& s(getDrawingState()); if (!s.buffer) { Loading Loading @@ -1457,7 +1462,8 @@ void Layer::onCompositionPresented(const DisplayDevice* display, mBufferInfo.mFrameLatencyNeeded = false; } bool Layer::latchBufferImpl(bool& recomputeVisibleRegions, nsecs_t latchTime, bool bgColorOnly) { bool Layer::latchBufferImpl(bool& recomputeVisibleRegions, nsecs_t latchTime, bool bgColorOnly) REQUIRES(mFlinger->mStateLock) { SFTRACE_FORMAT_INSTANT("latchBuffer %s - %" PRIu64, getDebugName(), getDrawingState().frameNumber); Loading
services/surfaceflinger/SurfaceFlinger.cpp +15 −14 Original line number Diff line number Diff line Loading @@ -2483,7 +2483,8 @@ void SurfaceFlinger::updateLayerHistory(nsecs_t now) { } bool SurfaceFlinger::updateLayerSnapshots(VsyncId vsyncId, nsecs_t frameTimeNs, bool flushTransactions, bool& outTransactionsAreEmpty) { bool flushTransactions, bool& outTransactionsAreEmpty) EXCLUDES(mStateLock) { using Changes = frontend::RequestedLayerState::Changes; SFTRACE_CALL(); SFTRACE_NAME_FOR_TRACK(WorkloadTracer::TRACK_NAME, "Transaction Handling"); Loading Loading @@ -2680,7 +2681,7 @@ bool SurfaceFlinger::updateLayerSnapshots(VsyncId vsyncId, nsecs_t frameTimeNs, } bool SurfaceFlinger::commit(PhysicalDisplayId pacesetterId, const scheduler::FrameTargets& frameTargets) { const scheduler::FrameTargets& frameTargets) EXCLUDES(mStateLock) { const scheduler::FrameTarget& pacesetterFrameTarget = *frameTargets.get(pacesetterId)->get(); const VsyncId vsyncId = pacesetterFrameTarget.vsyncId(); Loading Loading @@ -4893,12 +4894,14 @@ bool SurfaceFlinger::flushTransactionQueues() { return applyTransactions(transactions); } bool SurfaceFlinger::applyTransactions(std::vector<QueuedTransactionState>& transactions) { bool SurfaceFlinger::applyTransactions(std::vector<QueuedTransactionState>& transactions) EXCLUDES(mStateLock) { Mutex::Autolock lock(mStateLock); return applyTransactionsLocked(transactions); } bool SurfaceFlinger::applyTransactionsLocked(std::vector<QueuedTransactionState>& transactions) { bool SurfaceFlinger::applyTransactionsLocked(std::vector<QueuedTransactionState>& transactions) REQUIRES(mStateLock) { bool needsTraversal = false; // Now apply all transactions. for (auto& transaction : transactions) { Loading Loading @@ -5115,15 +5118,13 @@ status_t SurfaceFlinger::setTransactionState( return NO_ERROR; } bool SurfaceFlinger::applyTransactionState(const FrameTimelineInfo& frameTimelineInfo, std::vector<ResolvedComposerState>& states, bool SurfaceFlinger::applyTransactionState( const FrameTimelineInfo& frameTimelineInfo, std::vector<ResolvedComposerState>& states, Vector<DisplayState>& displays, uint32_t flags, const InputWindowCommands& inputWindowCommands, const int64_t desiredPresentTime, bool isAutoTimestamp, const std::vector<uint64_t>& uncacheBufferIds, const int64_t postTime, bool hasListenerCallbacks, const std::vector<ListenerCallbacks>& listenerCallbacks, int originPid, int originUid, uint64_t transactionId) { const InputWindowCommands& inputWindowCommands, const int64_t desiredPresentTime, bool isAutoTimestamp, const std::vector<uint64_t>& uncacheBufferIds, const int64_t postTime, bool hasListenerCallbacks, const std::vector<ListenerCallbacks>& listenerCallbacks, int originPid, int originUid, uint64_t transactionId) REQUIRES(mStateLock) { uint32_t transactionFlags = 0; // start and end registration for listeners w/ no surface so they can get their callback. Note Loading Loading @@ -5275,7 +5276,7 @@ uint32_t SurfaceFlinger::updateLayerCallbacksAndStats(const FrameTimelineInfo& f ResolvedComposerState& composerState, int64_t desiredPresentTime, bool isAutoTimestamp, int64_t postTime, uint64_t transactionId) { uint64_t transactionId) REQUIRES(mStateLock) { layer_state_t& s = composerState.state; std::vector<ListenerCallbacks> filteredListeners; Loading