Loading libs/gui/BLASTBufferQueue.cpp +13 −5 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include <gui/GLConsumer.h> #include <gui/IProducerListener.h> #include <gui/Surface.h> #include <gui/TraceUtils.h> #include <utils/Singleton.h> #include <utils/Trace.h> Loading Loading @@ -57,6 +58,10 @@ namespace android { #define BQA_LOGE(x, ...) \ ALOGE("[%s](f:%u,a:%u) " x, mName.c_str(), mNumFrameAvailable, mNumAcquired, ##__VA_ARGS__) #define BBQ_TRACE(x, ...) \ ATRACE_FORMAT("%s - %s(f:%u,a:%u)" x, __FUNCTION__, mName.c_str(), mNumFrameAvailable, \ mNumAcquired, ##__VA_ARGS__) void BLASTBufferItemConsumer::onDisconnect() { Mutex::Autolock lock(mMutex); mPreviouslyConnected = mCurrentlyConnected; Loading Loading @@ -254,7 +259,7 @@ void BLASTBufferQueue::transactionCommittedCallback(nsecs_t /*latchTime*/, const std::vector<SurfaceControlStats>& stats) { { std::unique_lock _lock{mMutex}; ATRACE_CALL(); BBQ_TRACE(); BQA_LOGV("transactionCommittedCallback"); if (!mSurfaceControlsWithPendingCallback.empty()) { sp<SurfaceControl> pendingSC = mSurfaceControlsWithPendingCallback.front(); Loading Loading @@ -304,7 +309,7 @@ void BLASTBufferQueue::transactionCallback(nsecs_t /*latchTime*/, const sp<Fence const std::vector<SurfaceControlStats>& stats) { { std::unique_lock _lock{mMutex}; ATRACE_CALL(); BBQ_TRACE(); BQA_LOGV("transactionCallback"); if (!mSurfaceControlsWithPendingCallback.empty()) { Loading Loading @@ -367,7 +372,7 @@ void BLASTBufferQueue::flushShadowQueue() { void BLASTBufferQueue::releaseBufferCallback( const ReleaseCallbackId& id, const sp<Fence>& releaseFence, std::optional<uint32_t> currentMaxAcquiredBufferCount) { ATRACE_CALL(); BBQ_TRACE(); std::unique_lock _lock{mMutex}; BQA_LOGV("releaseBufferCallback %s", id.to_string().c_str()); Loading Loading @@ -415,6 +420,7 @@ void BLASTBufferQueue::releaseBuffer(const ReleaseCallbackId& callbackId, return; } mNumAcquired--; BBQ_TRACE("frame=%" PRIu64, callbackId.framenumber); BQA_LOGV("released %s", callbackId.to_string().c_str()); mBufferItemConsumer->releaseBuffer(it->second, releaseFence); mSubmitted.erase(it); Loading @@ -422,7 +428,6 @@ void BLASTBufferQueue::releaseBuffer(const ReleaseCallbackId& callbackId, void BLASTBufferQueue::acquireNextBufferLocked( const std::optional<SurfaceComposerClient::Transaction*> transaction) { ATRACE_CALL(); // If the next transaction is set, we want to guarantee the our acquire will not fail, so don't // include the extra buffer when checking if we can acquire the next buffer. const bool includeExtraAcquire = !transaction; Loading Loading @@ -456,8 +461,10 @@ void BLASTBufferQueue::acquireNextBufferLocked( BQA_LOGE("Failed to acquire a buffer, err=%s", statusToString(status).c_str()); return; } auto buffer = bufferItem.mGraphicBuffer; mNumFrameAvailable--; BBQ_TRACE("frame=%" PRIu64, bufferItem.mFrameNumber); if (buffer == nullptr) { mBufferItemConsumer->releaseBuffer(bufferItem, Fence::NO_FENCE); Loading Loading @@ -600,7 +607,7 @@ void BLASTBufferQueue::flushAndWaitForFreeBuffer(std::unique_lock<std::mutex>& l } void BLASTBufferQueue::onFrameAvailable(const BufferItem& item) { ATRACE_CALL(); BBQ_TRACE(); std::unique_lock _lock{mMutex}; const bool syncTransactionSet = mSyncTransaction != nullptr; Loading Loading @@ -674,6 +681,7 @@ void BLASTBufferQueue::onFrameCancelled(const uint64_t bufferId) { void BLASTBufferQueue::setSyncTransaction(SurfaceComposerClient::Transaction* t, bool acquireSingleBuffer) { BBQ_TRACE(); std::lock_guard _lock{mMutex}; mSyncTransaction = t; mAcquireSingleBuffer = mSyncTransaction ? acquireSingleBuffer : true; Loading libs/gui/WindowInfosListenerReporter.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -68,8 +68,7 @@ status_t WindowInfosListenerReporter::removeWindowInfosListener( binder::Status WindowInfosListenerReporter::onWindowInfosChanged( const std::vector<WindowInfo>& windowInfos, const std::vector<DisplayInfo>& displayInfos, const sp<IWindowInfosReportedListener>& windowInfosReportedListener) { std::unordered_set<sp<WindowInfosListener>, ISurfaceComposer::SpHash<WindowInfosListener>> windowInfosListeners; std::unordered_set<sp<WindowInfosListener>, SpHash<WindowInfosListener>> windowInfosListeners; { std::scoped_lock lock(mListenersMutex); Loading libs/gui/include/gui/ISurfaceComposer.h +2 −5 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <ftl/Flags.h> #include <gui/FrameTimelineInfo.h> #include <gui/ITransactionCompletedListener.h> #include <gui/SpHash.h> #include <math/vec4.h> #include <stdint.h> #include <sys/types.h> Loading Loading @@ -70,6 +71,7 @@ enum class FrameEvent; using gui::IDisplayEventConnection; using gui::IRegionSamplingListener; using gui::IScreenCaptureListener; using gui::SpHash; namespace ui { Loading Loading @@ -118,11 +120,6 @@ public: using EventRegistrationFlags = Flags<EventRegistration>; template <typename T> struct SpHash { size_t operator()(const sp<T>& k) const { return std::hash<T*>()(k.get()); } }; /* * Create a connection with SurfaceFlinger. */ Loading libs/gui/include/gui/LayerState.h +2 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include <gui/ISurfaceComposer.h> #include <gui/LayerMetadata.h> #include <gui/SpHash.h> #include <gui/SurfaceControl.h> #include <gui/WindowInfo.h> #include <math/vec3.h> Loading Loading @@ -412,7 +413,7 @@ struct DisplayCaptureArgs : CaptureArgs { struct LayerCaptureArgs : CaptureArgs { sp<IBinder> layerHandle; std::unordered_set<sp<IBinder>, ISurfaceComposer::SpHash<IBinder>> excludeHandles; std::unordered_set<sp<IBinder>, SpHash<IBinder>> excludeHandles; bool childrenOnly{false}; status_t write(Parcel& output) const override; Loading libs/gui/include/gui/SpHash.h 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <stdint.h> #include <sys/types.h> #include <functional> namespace android::gui { template <typename T> struct SpHash { size_t operator()(const sp<T>& k) const { return std::hash<T*>()(k.get()); } }; }; // namespace android::gui Loading
libs/gui/BLASTBufferQueue.cpp +13 −5 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include <gui/GLConsumer.h> #include <gui/IProducerListener.h> #include <gui/Surface.h> #include <gui/TraceUtils.h> #include <utils/Singleton.h> #include <utils/Trace.h> Loading Loading @@ -57,6 +58,10 @@ namespace android { #define BQA_LOGE(x, ...) \ ALOGE("[%s](f:%u,a:%u) " x, mName.c_str(), mNumFrameAvailable, mNumAcquired, ##__VA_ARGS__) #define BBQ_TRACE(x, ...) \ ATRACE_FORMAT("%s - %s(f:%u,a:%u)" x, __FUNCTION__, mName.c_str(), mNumFrameAvailable, \ mNumAcquired, ##__VA_ARGS__) void BLASTBufferItemConsumer::onDisconnect() { Mutex::Autolock lock(mMutex); mPreviouslyConnected = mCurrentlyConnected; Loading Loading @@ -254,7 +259,7 @@ void BLASTBufferQueue::transactionCommittedCallback(nsecs_t /*latchTime*/, const std::vector<SurfaceControlStats>& stats) { { std::unique_lock _lock{mMutex}; ATRACE_CALL(); BBQ_TRACE(); BQA_LOGV("transactionCommittedCallback"); if (!mSurfaceControlsWithPendingCallback.empty()) { sp<SurfaceControl> pendingSC = mSurfaceControlsWithPendingCallback.front(); Loading Loading @@ -304,7 +309,7 @@ void BLASTBufferQueue::transactionCallback(nsecs_t /*latchTime*/, const sp<Fence const std::vector<SurfaceControlStats>& stats) { { std::unique_lock _lock{mMutex}; ATRACE_CALL(); BBQ_TRACE(); BQA_LOGV("transactionCallback"); if (!mSurfaceControlsWithPendingCallback.empty()) { Loading Loading @@ -367,7 +372,7 @@ void BLASTBufferQueue::flushShadowQueue() { void BLASTBufferQueue::releaseBufferCallback( const ReleaseCallbackId& id, const sp<Fence>& releaseFence, std::optional<uint32_t> currentMaxAcquiredBufferCount) { ATRACE_CALL(); BBQ_TRACE(); std::unique_lock _lock{mMutex}; BQA_LOGV("releaseBufferCallback %s", id.to_string().c_str()); Loading Loading @@ -415,6 +420,7 @@ void BLASTBufferQueue::releaseBuffer(const ReleaseCallbackId& callbackId, return; } mNumAcquired--; BBQ_TRACE("frame=%" PRIu64, callbackId.framenumber); BQA_LOGV("released %s", callbackId.to_string().c_str()); mBufferItemConsumer->releaseBuffer(it->second, releaseFence); mSubmitted.erase(it); Loading @@ -422,7 +428,6 @@ void BLASTBufferQueue::releaseBuffer(const ReleaseCallbackId& callbackId, void BLASTBufferQueue::acquireNextBufferLocked( const std::optional<SurfaceComposerClient::Transaction*> transaction) { ATRACE_CALL(); // If the next transaction is set, we want to guarantee the our acquire will not fail, so don't // include the extra buffer when checking if we can acquire the next buffer. const bool includeExtraAcquire = !transaction; Loading Loading @@ -456,8 +461,10 @@ void BLASTBufferQueue::acquireNextBufferLocked( BQA_LOGE("Failed to acquire a buffer, err=%s", statusToString(status).c_str()); return; } auto buffer = bufferItem.mGraphicBuffer; mNumFrameAvailable--; BBQ_TRACE("frame=%" PRIu64, bufferItem.mFrameNumber); if (buffer == nullptr) { mBufferItemConsumer->releaseBuffer(bufferItem, Fence::NO_FENCE); Loading Loading @@ -600,7 +607,7 @@ void BLASTBufferQueue::flushAndWaitForFreeBuffer(std::unique_lock<std::mutex>& l } void BLASTBufferQueue::onFrameAvailable(const BufferItem& item) { ATRACE_CALL(); BBQ_TRACE(); std::unique_lock _lock{mMutex}; const bool syncTransactionSet = mSyncTransaction != nullptr; Loading Loading @@ -674,6 +681,7 @@ void BLASTBufferQueue::onFrameCancelled(const uint64_t bufferId) { void BLASTBufferQueue::setSyncTransaction(SurfaceComposerClient::Transaction* t, bool acquireSingleBuffer) { BBQ_TRACE(); std::lock_guard _lock{mMutex}; mSyncTransaction = t; mAcquireSingleBuffer = mSyncTransaction ? acquireSingleBuffer : true; Loading
libs/gui/WindowInfosListenerReporter.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -68,8 +68,7 @@ status_t WindowInfosListenerReporter::removeWindowInfosListener( binder::Status WindowInfosListenerReporter::onWindowInfosChanged( const std::vector<WindowInfo>& windowInfos, const std::vector<DisplayInfo>& displayInfos, const sp<IWindowInfosReportedListener>& windowInfosReportedListener) { std::unordered_set<sp<WindowInfosListener>, ISurfaceComposer::SpHash<WindowInfosListener>> windowInfosListeners; std::unordered_set<sp<WindowInfosListener>, SpHash<WindowInfosListener>> windowInfosListeners; { std::scoped_lock lock(mListenersMutex); Loading
libs/gui/include/gui/ISurfaceComposer.h +2 −5 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <ftl/Flags.h> #include <gui/FrameTimelineInfo.h> #include <gui/ITransactionCompletedListener.h> #include <gui/SpHash.h> #include <math/vec4.h> #include <stdint.h> #include <sys/types.h> Loading Loading @@ -70,6 +71,7 @@ enum class FrameEvent; using gui::IDisplayEventConnection; using gui::IRegionSamplingListener; using gui::IScreenCaptureListener; using gui::SpHash; namespace ui { Loading Loading @@ -118,11 +120,6 @@ public: using EventRegistrationFlags = Flags<EventRegistration>; template <typename T> struct SpHash { size_t operator()(const sp<T>& k) const { return std::hash<T*>()(k.get()); } }; /* * Create a connection with SurfaceFlinger. */ Loading
libs/gui/include/gui/LayerState.h +2 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include <gui/ISurfaceComposer.h> #include <gui/LayerMetadata.h> #include <gui/SpHash.h> #include <gui/SurfaceControl.h> #include <gui/WindowInfo.h> #include <math/vec3.h> Loading Loading @@ -412,7 +413,7 @@ struct DisplayCaptureArgs : CaptureArgs { struct LayerCaptureArgs : CaptureArgs { sp<IBinder> layerHandle; std::unordered_set<sp<IBinder>, ISurfaceComposer::SpHash<IBinder>> excludeHandles; std::unordered_set<sp<IBinder>, SpHash<IBinder>> excludeHandles; bool childrenOnly{false}; status_t write(Parcel& output) const override; Loading
libs/gui/include/gui/SpHash.h 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <stdint.h> #include <sys/types.h> #include <functional> namespace android::gui { template <typename T> struct SpHash { size_t operator()(const sp<T>& k) const { return std::hash<T*>()(k.get()); } }; }; // namespace android::gui