Loading include/ui/Surface.h +2 −1 Original line number Diff line number Diff line Loading @@ -212,7 +212,7 @@ private: void setUsage(uint32_t reqUsage); uint32_t getUsage() const; bool getUsage(uint32_t* usage); // constants sp<SurfaceComposerClient> mClient; Loading @@ -227,6 +227,7 @@ private: // protected by mSurfaceLock Rect mSwapRectangle; uint32_t mUsage; int32_t mUsageChanged; // protected by mSurfaceLock. These are also used from lock/unlock // but in that case, they must be called form the same thread. Loading libs/ui/Surface.cpp +18 −8 Original line number Diff line number Diff line Loading @@ -361,6 +361,7 @@ void Surface::init() const_cast<uint32_t&>(android_native_window_t::flags) = 0; // be default we request a hardware surface mUsage = GRALLOC_USAGE_HW_RENDER; mUsageChanged = true; mNeedFullUpdate = false; } Loading Loading @@ -498,12 +499,13 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer) return bufIdx; } const uint32_t usage(getUsage()); // FIXME: in case of failure below, we need to undo the dequeue uint32_t usage; const bool usageChanged = getUsage(&usage); const sp<SurfaceBuffer>& backBuffer(mBuffers[bufIdx]); if (backBuffer == 0 || uint32_t(backBuffer->usage) != usage || mSharedBufferClient->needNewBuffer(bufIdx)) { if ((backBuffer == 0) || usageChanged || mSharedBufferClient->needNewBuffer(bufIdx)) { err = getBufferLocked(bufIdx, usage); LOGE_IF(err, "getBufferLocked(%ld, %08x) failed (%s)", bufIdx, usage, strerror(-err)); Loading Loading @@ -598,13 +600,21 @@ int Surface::perform(int operation, va_list args) void Surface::setUsage(uint32_t reqUsage) { Mutex::Autolock _l(mSurfaceLock); if (mUsage != reqUsage) { mUsageChanged = true; mUsage = reqUsage; } } uint32_t Surface::getUsage() const bool Surface::getUsage(uint32_t* usage) { Mutex::Autolock _l(mSurfaceLock); return mUsage; *usage = mUsage; if (mUsageChanged) { mUsageChanged = false; return true; } return false; } // ---------------------------------------------------------------------------- Loading Loading
include/ui/Surface.h +2 −1 Original line number Diff line number Diff line Loading @@ -212,7 +212,7 @@ private: void setUsage(uint32_t reqUsage); uint32_t getUsage() const; bool getUsage(uint32_t* usage); // constants sp<SurfaceComposerClient> mClient; Loading @@ -227,6 +227,7 @@ private: // protected by mSurfaceLock Rect mSwapRectangle; uint32_t mUsage; int32_t mUsageChanged; // protected by mSurfaceLock. These are also used from lock/unlock // but in that case, they must be called form the same thread. Loading
libs/ui/Surface.cpp +18 −8 Original line number Diff line number Diff line Loading @@ -361,6 +361,7 @@ void Surface::init() const_cast<uint32_t&>(android_native_window_t::flags) = 0; // be default we request a hardware surface mUsage = GRALLOC_USAGE_HW_RENDER; mUsageChanged = true; mNeedFullUpdate = false; } Loading Loading @@ -498,12 +499,13 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer) return bufIdx; } const uint32_t usage(getUsage()); // FIXME: in case of failure below, we need to undo the dequeue uint32_t usage; const bool usageChanged = getUsage(&usage); const sp<SurfaceBuffer>& backBuffer(mBuffers[bufIdx]); if (backBuffer == 0 || uint32_t(backBuffer->usage) != usage || mSharedBufferClient->needNewBuffer(bufIdx)) { if ((backBuffer == 0) || usageChanged || mSharedBufferClient->needNewBuffer(bufIdx)) { err = getBufferLocked(bufIdx, usage); LOGE_IF(err, "getBufferLocked(%ld, %08x) failed (%s)", bufIdx, usage, strerror(-err)); Loading Loading @@ -598,13 +600,21 @@ int Surface::perform(int operation, va_list args) void Surface::setUsage(uint32_t reqUsage) { Mutex::Autolock _l(mSurfaceLock); if (mUsage != reqUsage) { mUsageChanged = true; mUsage = reqUsage; } } uint32_t Surface::getUsage() const bool Surface::getUsage(uint32_t* usage) { Mutex::Autolock _l(mSurfaceLock); return mUsage; *usage = mUsage; if (mUsageChanged) { mUsageChanged = false; return true; } return false; } // ---------------------------------------------------------------------------- Loading