diff options
Diffstat (limited to 'libs/ui')
-rw-r--r-- | libs/ui/Surface.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/libs/ui/Surface.cpp b/libs/ui/Surface.cpp index c3fbea2..4dab3a2 100644 --- a/libs/ui/Surface.cpp +++ b/libs/ui/Surface.cpp @@ -361,7 +361,6 @@ 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; } @@ -499,13 +498,12 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer) return bufIdx; } - // FIXME: in case of failure below, we need to undo the dequeue - - uint32_t usage; - const bool usageChanged = getUsage(&usage); + const uint32_t usage(getUsage()); const sp<SurfaceBuffer>& backBuffer(mBuffers[bufIdx]); - if ((backBuffer == 0) || usageChanged || - mSharedBufferClient->needNewBuffer(bufIdx)) { + if (backBuffer == 0 || + uint32_t(backBuffer->usage) != usage || + mSharedBufferClient->needNewBuffer(bufIdx)) + { err = getBufferLocked(bufIdx, usage); LOGE_IF(err, "getBufferLocked(%ld, %08x) failed (%s)", bufIdx, usage, strerror(-err)); @@ -600,21 +598,13 @@ 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; - } + mUsage = reqUsage; } -bool Surface::getUsage(uint32_t* usage) +uint32_t Surface::getUsage() const { Mutex::Autolock _l(mSurfaceLock); - *usage = mUsage; - if (mUsageChanged) { - mUsageChanged = false; - return true; - } - return false; + return mUsage; } // ---------------------------------------------------------------------------- |