summaryrefslogtreecommitdiffstats
path: root/libs/ui
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2009-09-15 19:10:47 -0700
committerMathias Agopian <mathias@google.com>2009-09-15 19:21:31 -0700
commite611a6ed33d157b7ae15bdfe4e1873dc20ce7d48 (patch)
treefc1e8f0b97d6f2c4cb43c52055e5f015ffe8204a /libs/ui
parentdd8f6186775f69a8fef6213bcdc23be633d1ab6f (diff)
downloadframeworks_base-e611a6ed33d157b7ae15bdfe4e1873dc20ce7d48.zip
frameworks_base-e611a6ed33d157b7ae15bdfe4e1873dc20ce7d48.tar.gz
frameworks_base-e611a6ed33d157b7ae15bdfe4e1873dc20ce7d48.tar.bz2
fix [2122448] android_native_window_t::setUsage() only reallocates the first buffer
Take 2. We needed to check that the usage flags are "good enough" as opposed to "the same". This reverts commit 8f17a762fe9e9f31e4e86cb60ff2bfb6b10fdee6.
Diffstat (limited to 'libs/ui')
-rw-r--r--libs/ui/Surface.cpp29
1 files changed, 10 insertions, 19 deletions
diff --git a/libs/ui/Surface.cpp b/libs/ui/Surface.cpp
index c3fbea2..64522fb 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;
}
@@ -498,14 +497,14 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer)
LOGE("error dequeuing a buffer (%s)", strerror(bufIdx));
return bufIdx;
}
-
- // FIXME: in case of failure below, we need to undo the dequeue
-
- uint32_t usage;
- const bool usageChanged = getUsage(&usage);
+
+ // below we make sure we AT LEAST have the usage flags we want
+ 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) != usage) ||
+ mSharedBufferClient->needNewBuffer(bufIdx))
+ {
err = getBufferLocked(bufIdx, usage);
LOGE_IF(err, "getBufferLocked(%ld, %08x) failed (%s)",
bufIdx, usage, strerror(-err));
@@ -600,21 +599,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;
}
// ----------------------------------------------------------------------------