Loading services/surfaceflinger/BufferStateLayer.cpp +9 −17 Original line number Diff line number Diff line Loading @@ -14,11 +14,6 @@ * limitations under the License. */ // TODO(b/129481165): remove the #pragma below and fix conversion issues #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wconversion" #pragma clang diagnostic ignored "-Wextra" //#define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "BufferStateLayer" Loading Loading @@ -596,7 +591,7 @@ bool BufferStateLayer::setTransparentRegionHint(const Region& transparent) { return true; } Rect BufferStateLayer::getBufferSize(const State& s) const { Rect BufferStateLayer::getBufferSize(const State& /*s*/) const { // for buffer state layers we use the display frame size as the buffer size. if (mBufferInfo.mBuffer == nullptr) { Loading @@ -618,7 +613,7 @@ Rect BufferStateLayer::getBufferSize(const State& s) const { } } return Rect(0, 0, bufWidth, bufHeight); return Rect(0, 0, static_cast<int32_t>(bufWidth), static_cast<int32_t>(bufHeight)); } FloatRect BufferStateLayer::computeSourceBounds(const FloatRect& parentBounds) const { Loading Loading @@ -817,7 +812,7 @@ void BufferStateLayer::HwcSlotGenerator::bufferErased(const client_cache_t& clie eraseBufferLocked(clientCacheId); } uint32_t BufferStateLayer::HwcSlotGenerator::getHwcCacheSlot(const client_cache_t& clientCacheId) { int BufferStateLayer::HwcSlotGenerator::getHwcCacheSlot(const client_cache_t& clientCacheId) { std::lock_guard<std::mutex> lock(mMutex); auto itr = mCachedBuffers.find(clientCacheId); if (itr == mCachedBuffers.end()) { Loading @@ -828,7 +823,7 @@ uint32_t BufferStateLayer::HwcSlotGenerator::getHwcCacheSlot(const client_cache_ return hwcCacheSlot; } uint32_t BufferStateLayer::HwcSlotGenerator::addCachedBuffer(const client_cache_t& clientCacheId) int BufferStateLayer::HwcSlotGenerator::addCachedBuffer(const client_cache_t& clientCacheId) REQUIRES(mMutex) { if (!clientCacheId.isValid()) { ALOGE("invalid process, returning invalid slot"); Loading @@ -837,17 +832,17 @@ uint32_t BufferStateLayer::HwcSlotGenerator::addCachedBuffer(const client_cache_ ClientCache::getInstance().registerErasedRecipient(clientCacheId, wp<ErasedRecipient>(this)); uint32_t hwcCacheSlot = getFreeHwcCacheSlot(); int hwcCacheSlot = getFreeHwcCacheSlot(); mCachedBuffers[clientCacheId] = {hwcCacheSlot, mCounter++}; return hwcCacheSlot; } uint32_t BufferStateLayer::HwcSlotGenerator::getFreeHwcCacheSlot() REQUIRES(mMutex) { int BufferStateLayer::HwcSlotGenerator::getFreeHwcCacheSlot() REQUIRES(mMutex) { if (mFreeHwcCacheSlots.empty()) { evictLeastRecentlyUsed(); } uint32_t hwcCacheSlot = mFreeHwcCacheSlots.top(); int hwcCacheSlot = mFreeHwcCacheSlots.top(); mFreeHwcCacheSlots.pop(); return hwcCacheSlot; } Loading Loading @@ -934,8 +929,8 @@ bool BufferStateLayer::bufferNeedsFiltering() const { return false; } uint32_t bufferWidth = s.buffer->getBuffer()->width; uint32_t bufferHeight = s.buffer->getBuffer()->height; int32_t bufferWidth = s.buffer->getBuffer()->width; int32_t bufferHeight = s.buffer->getBuffer()->height; // Undo any transformations on the buffer and return the result. if (s.bufferTransform & ui::Transform::ROT_90) { Loading Loading @@ -994,6 +989,3 @@ Rect BufferStateLayer::getInputBounds() const { } } // namespace android // TODO(b/129481165): remove the #pragma below and fix conversion issues #pragma clang diagnostic pop // ignored "-Wconversion -Wextra" services/surfaceflinger/BufferStateLayer.h +6 −7 Original line number Diff line number Diff line Loading @@ -178,19 +178,19 @@ private: class HwcSlotGenerator : public ClientCache::ErasedRecipient { public: HwcSlotGenerator() { for (uint32_t i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { mFreeHwcCacheSlots.push(i); } } void bufferErased(const client_cache_t& clientCacheId); uint32_t getHwcCacheSlot(const client_cache_t& clientCacheId); int getHwcCacheSlot(const client_cache_t& clientCacheId); private: friend class SlotGenerationTest; uint32_t addCachedBuffer(const client_cache_t& clientCacheId) REQUIRES(mMutex); uint32_t getFreeHwcCacheSlot() REQUIRES(mMutex); int addCachedBuffer(const client_cache_t& clientCacheId) REQUIRES(mMutex); int getFreeHwcCacheSlot() REQUIRES(mMutex); void evictLeastRecentlyUsed() REQUIRES(mMutex); void eraseBufferLocked(const client_cache_t& clientCacheId) REQUIRES(mMutex); Loading @@ -202,11 +202,10 @@ private: std::mutex mMutex; std::unordered_map<client_cache_t, std::pair<uint32_t /*HwcCacheSlot*/, uint32_t /*counter*/>, std::unordered_map<client_cache_t, std::pair<int /*HwcCacheSlot*/, uint64_t /*counter*/>, CachedBufferHash> mCachedBuffers GUARDED_BY(mMutex); std::stack<uint32_t /*HwcCacheSlot*/> mFreeHwcCacheSlots GUARDED_BY(mMutex); std::stack<int /*HwcCacheSlot*/> mFreeHwcCacheSlots GUARDED_BY(mMutex); // The cache increments this counter value when a slot is updated or used. // Used to track the least recently-used buffer Loading services/surfaceflinger/SurfaceFlinger.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -6793,7 +6793,7 @@ status_t SurfaceFlinger::getMaxAcquiredBufferCount(int* buffers) const { return NO_ERROR; } int SurfaceFlinger::getMaxAcquiredBufferCountForCurrentRefreshRate(uid_t uid) const { uint32_t SurfaceFlinger::getMaxAcquiredBufferCountForCurrentRefreshRate(uid_t uid) const { Fps refreshRate(60.f); if (const auto frameRateOverride = mScheduler->getFrameRateOverride(uid)) { Loading services/surfaceflinger/SurfaceFlinger.h +1 −1 Original line number Diff line number Diff line Loading @@ -942,7 +942,7 @@ private: return width > mMaxRenderTargetSize || height > mMaxRenderTargetSize; } int getMaxAcquiredBufferCountForCurrentRefreshRate(uid_t uid) const; uint32_t getMaxAcquiredBufferCountForCurrentRefreshRate(uid_t uid) const; /* * Display and layer stack management Loading services/surfaceflinger/tests/unittests/CachingTest.cpp +8 −16 Original line number Diff line number Diff line Loading @@ -14,11 +14,6 @@ * limitations under the License. */ // TODO(b/129481165): remove the #pragma below and fix conversion issues #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wconversion" #pragma clang diagnostic ignored "-Wextra" #undef LOG_TAG #define LOG_TAG "CachingTest" Loading @@ -42,7 +37,7 @@ TEST_F(SlotGenerationTest, getHwcCacheSlot_Invalid) { sp<IBinder> binder = new BBinder(); // test getting invalid client_cache_id client_cache_t id; uint32_t slot = mHwcSlotGenerator->getHwcCacheSlot(id); int slot = mHwcSlotGenerator->getHwcCacheSlot(id); EXPECT_EQ(BufferQueue::INVALID_BUFFER_SLOT, slot); } Loading @@ -51,7 +46,7 @@ TEST_F(SlotGenerationTest, getHwcCacheSlot_Basic) { client_cache_t id; id.token = binder; id.id = 0; uint32_t slot = mHwcSlotGenerator->getHwcCacheSlot(id); int slot = mHwcSlotGenerator->getHwcCacheSlot(id); EXPECT_EQ(BufferQueue::NUM_BUFFER_SLOTS - 1, slot); client_cache_t idB; Loading @@ -72,31 +67,28 @@ TEST_F(SlotGenerationTest, getHwcCacheSlot_Reuse) { std::vector<client_cache_t> ids; uint32_t cacheId = 0; // fill up cache for (uint32_t i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { client_cache_t id; id.token = binder; id.id = cacheId; ids.push_back(id); uint32_t slot = mHwcSlotGenerator->getHwcCacheSlot(id); int slot = mHwcSlotGenerator->getHwcCacheSlot(id); EXPECT_EQ(BufferQueue::NUM_BUFFER_SLOTS - (i + 1), slot); cacheId++; } for (uint32_t i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { uint32_t slot = mHwcSlotGenerator->getHwcCacheSlot(ids[i]); for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { int slot = mHwcSlotGenerator->getHwcCacheSlot(ids[static_cast<uint32_t>(i)]); EXPECT_EQ(BufferQueue::NUM_BUFFER_SLOTS - (i + 1), slot); } for (uint32_t i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { client_cache_t id; id.token = binder; id.id = cacheId; uint32_t slot = mHwcSlotGenerator->getHwcCacheSlot(id); int slot = mHwcSlotGenerator->getHwcCacheSlot(id); EXPECT_EQ(BufferQueue::NUM_BUFFER_SLOTS - (i + 1), slot); cacheId++; } } } // namespace android // TODO(b/129481165): remove the #pragma below and fix conversion issues #pragma clang diagnostic pop // ignored "-Wconversion -Wextra" Loading
services/surfaceflinger/BufferStateLayer.cpp +9 −17 Original line number Diff line number Diff line Loading @@ -14,11 +14,6 @@ * limitations under the License. */ // TODO(b/129481165): remove the #pragma below and fix conversion issues #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wconversion" #pragma clang diagnostic ignored "-Wextra" //#define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "BufferStateLayer" Loading Loading @@ -596,7 +591,7 @@ bool BufferStateLayer::setTransparentRegionHint(const Region& transparent) { return true; } Rect BufferStateLayer::getBufferSize(const State& s) const { Rect BufferStateLayer::getBufferSize(const State& /*s*/) const { // for buffer state layers we use the display frame size as the buffer size. if (mBufferInfo.mBuffer == nullptr) { Loading @@ -618,7 +613,7 @@ Rect BufferStateLayer::getBufferSize(const State& s) const { } } return Rect(0, 0, bufWidth, bufHeight); return Rect(0, 0, static_cast<int32_t>(bufWidth), static_cast<int32_t>(bufHeight)); } FloatRect BufferStateLayer::computeSourceBounds(const FloatRect& parentBounds) const { Loading Loading @@ -817,7 +812,7 @@ void BufferStateLayer::HwcSlotGenerator::bufferErased(const client_cache_t& clie eraseBufferLocked(clientCacheId); } uint32_t BufferStateLayer::HwcSlotGenerator::getHwcCacheSlot(const client_cache_t& clientCacheId) { int BufferStateLayer::HwcSlotGenerator::getHwcCacheSlot(const client_cache_t& clientCacheId) { std::lock_guard<std::mutex> lock(mMutex); auto itr = mCachedBuffers.find(clientCacheId); if (itr == mCachedBuffers.end()) { Loading @@ -828,7 +823,7 @@ uint32_t BufferStateLayer::HwcSlotGenerator::getHwcCacheSlot(const client_cache_ return hwcCacheSlot; } uint32_t BufferStateLayer::HwcSlotGenerator::addCachedBuffer(const client_cache_t& clientCacheId) int BufferStateLayer::HwcSlotGenerator::addCachedBuffer(const client_cache_t& clientCacheId) REQUIRES(mMutex) { if (!clientCacheId.isValid()) { ALOGE("invalid process, returning invalid slot"); Loading @@ -837,17 +832,17 @@ uint32_t BufferStateLayer::HwcSlotGenerator::addCachedBuffer(const client_cache_ ClientCache::getInstance().registerErasedRecipient(clientCacheId, wp<ErasedRecipient>(this)); uint32_t hwcCacheSlot = getFreeHwcCacheSlot(); int hwcCacheSlot = getFreeHwcCacheSlot(); mCachedBuffers[clientCacheId] = {hwcCacheSlot, mCounter++}; return hwcCacheSlot; } uint32_t BufferStateLayer::HwcSlotGenerator::getFreeHwcCacheSlot() REQUIRES(mMutex) { int BufferStateLayer::HwcSlotGenerator::getFreeHwcCacheSlot() REQUIRES(mMutex) { if (mFreeHwcCacheSlots.empty()) { evictLeastRecentlyUsed(); } uint32_t hwcCacheSlot = mFreeHwcCacheSlots.top(); int hwcCacheSlot = mFreeHwcCacheSlots.top(); mFreeHwcCacheSlots.pop(); return hwcCacheSlot; } Loading Loading @@ -934,8 +929,8 @@ bool BufferStateLayer::bufferNeedsFiltering() const { return false; } uint32_t bufferWidth = s.buffer->getBuffer()->width; uint32_t bufferHeight = s.buffer->getBuffer()->height; int32_t bufferWidth = s.buffer->getBuffer()->width; int32_t bufferHeight = s.buffer->getBuffer()->height; // Undo any transformations on the buffer and return the result. if (s.bufferTransform & ui::Transform::ROT_90) { Loading Loading @@ -994,6 +989,3 @@ Rect BufferStateLayer::getInputBounds() const { } } // namespace android // TODO(b/129481165): remove the #pragma below and fix conversion issues #pragma clang diagnostic pop // ignored "-Wconversion -Wextra"
services/surfaceflinger/BufferStateLayer.h +6 −7 Original line number Diff line number Diff line Loading @@ -178,19 +178,19 @@ private: class HwcSlotGenerator : public ClientCache::ErasedRecipient { public: HwcSlotGenerator() { for (uint32_t i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { mFreeHwcCacheSlots.push(i); } } void bufferErased(const client_cache_t& clientCacheId); uint32_t getHwcCacheSlot(const client_cache_t& clientCacheId); int getHwcCacheSlot(const client_cache_t& clientCacheId); private: friend class SlotGenerationTest; uint32_t addCachedBuffer(const client_cache_t& clientCacheId) REQUIRES(mMutex); uint32_t getFreeHwcCacheSlot() REQUIRES(mMutex); int addCachedBuffer(const client_cache_t& clientCacheId) REQUIRES(mMutex); int getFreeHwcCacheSlot() REQUIRES(mMutex); void evictLeastRecentlyUsed() REQUIRES(mMutex); void eraseBufferLocked(const client_cache_t& clientCacheId) REQUIRES(mMutex); Loading @@ -202,11 +202,10 @@ private: std::mutex mMutex; std::unordered_map<client_cache_t, std::pair<uint32_t /*HwcCacheSlot*/, uint32_t /*counter*/>, std::unordered_map<client_cache_t, std::pair<int /*HwcCacheSlot*/, uint64_t /*counter*/>, CachedBufferHash> mCachedBuffers GUARDED_BY(mMutex); std::stack<uint32_t /*HwcCacheSlot*/> mFreeHwcCacheSlots GUARDED_BY(mMutex); std::stack<int /*HwcCacheSlot*/> mFreeHwcCacheSlots GUARDED_BY(mMutex); // The cache increments this counter value when a slot is updated or used. // Used to track the least recently-used buffer Loading
services/surfaceflinger/SurfaceFlinger.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -6793,7 +6793,7 @@ status_t SurfaceFlinger::getMaxAcquiredBufferCount(int* buffers) const { return NO_ERROR; } int SurfaceFlinger::getMaxAcquiredBufferCountForCurrentRefreshRate(uid_t uid) const { uint32_t SurfaceFlinger::getMaxAcquiredBufferCountForCurrentRefreshRate(uid_t uid) const { Fps refreshRate(60.f); if (const auto frameRateOverride = mScheduler->getFrameRateOverride(uid)) { Loading
services/surfaceflinger/SurfaceFlinger.h +1 −1 Original line number Diff line number Diff line Loading @@ -942,7 +942,7 @@ private: return width > mMaxRenderTargetSize || height > mMaxRenderTargetSize; } int getMaxAcquiredBufferCountForCurrentRefreshRate(uid_t uid) const; uint32_t getMaxAcquiredBufferCountForCurrentRefreshRate(uid_t uid) const; /* * Display and layer stack management Loading
services/surfaceflinger/tests/unittests/CachingTest.cpp +8 −16 Original line number Diff line number Diff line Loading @@ -14,11 +14,6 @@ * limitations under the License. */ // TODO(b/129481165): remove the #pragma below and fix conversion issues #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wconversion" #pragma clang diagnostic ignored "-Wextra" #undef LOG_TAG #define LOG_TAG "CachingTest" Loading @@ -42,7 +37,7 @@ TEST_F(SlotGenerationTest, getHwcCacheSlot_Invalid) { sp<IBinder> binder = new BBinder(); // test getting invalid client_cache_id client_cache_t id; uint32_t slot = mHwcSlotGenerator->getHwcCacheSlot(id); int slot = mHwcSlotGenerator->getHwcCacheSlot(id); EXPECT_EQ(BufferQueue::INVALID_BUFFER_SLOT, slot); } Loading @@ -51,7 +46,7 @@ TEST_F(SlotGenerationTest, getHwcCacheSlot_Basic) { client_cache_t id; id.token = binder; id.id = 0; uint32_t slot = mHwcSlotGenerator->getHwcCacheSlot(id); int slot = mHwcSlotGenerator->getHwcCacheSlot(id); EXPECT_EQ(BufferQueue::NUM_BUFFER_SLOTS - 1, slot); client_cache_t idB; Loading @@ -72,31 +67,28 @@ TEST_F(SlotGenerationTest, getHwcCacheSlot_Reuse) { std::vector<client_cache_t> ids; uint32_t cacheId = 0; // fill up cache for (uint32_t i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { client_cache_t id; id.token = binder; id.id = cacheId; ids.push_back(id); uint32_t slot = mHwcSlotGenerator->getHwcCacheSlot(id); int slot = mHwcSlotGenerator->getHwcCacheSlot(id); EXPECT_EQ(BufferQueue::NUM_BUFFER_SLOTS - (i + 1), slot); cacheId++; } for (uint32_t i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { uint32_t slot = mHwcSlotGenerator->getHwcCacheSlot(ids[i]); for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { int slot = mHwcSlotGenerator->getHwcCacheSlot(ids[static_cast<uint32_t>(i)]); EXPECT_EQ(BufferQueue::NUM_BUFFER_SLOTS - (i + 1), slot); } for (uint32_t i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { client_cache_t id; id.token = binder; id.id = cacheId; uint32_t slot = mHwcSlotGenerator->getHwcCacheSlot(id); int slot = mHwcSlotGenerator->getHwcCacheSlot(id); EXPECT_EQ(BufferQueue::NUM_BUFFER_SLOTS - (i + 1), slot); cacheId++; } } } // namespace android // TODO(b/129481165): remove the #pragma below and fix conversion issues #pragma clang diagnostic pop // ignored "-Wconversion -Wextra"