diff options
author | Mathias Agopian <mathias@google.com> | 2009-09-15 18:57:06 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-09-15 18:57:06 -0700 |
commit | 8f17a762fe9e9f31e4e86cb60ff2bfb6b10fdee6 (patch) | |
tree | f9500ecdcefae8e859433c2153dcc1b2fe642909 /libs | |
parent | d6b10fb86229ed0e904138ec4604066ea85059db (diff) | |
download | frameworks_base-8f17a762fe9e9f31e4e86cb60ff2bfb6b10fdee6.zip frameworks_base-8f17a762fe9e9f31e4e86cb60ff2bfb6b10fdee6.tar.gz frameworks_base-8f17a762fe9e9f31e4e86cb60ff2bfb6b10fdee6.tar.bz2 |
Revert "fix [2122448] android_native_window_t::setUsage() only reallocates the first buffer"
This reverts commit 486aa963b63e20b7910e1004cebb4f0afabbd80f.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ui/Surface.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/libs/ui/Surface.cpp b/libs/ui/Surface.cpp index 4dab3a2..c3fbea2 100644 --- a/libs/ui/Surface.cpp +++ b/libs/ui/Surface.cpp @@ -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; } @@ -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)); @@ -598,13 +600,21 @@ int Surface::perform(int operation, va_list args) void Surface::setUsage(uint32_t reqUsage) { Mutex::Autolock _l(mSurfaceLock); - mUsage = reqUsage; + 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; } // ---------------------------------------------------------------------------- |