Merge change 25207 into eclair

* changes:
  fix [2122448] android_native_window_t::setUsage() only reallocates the first buffer
This commit is contained in:
Android (Google) Code Review
2009-09-15 22:26:26 -04:00
2 changed files with 11 additions and 21 deletions

View File

@@ -212,7 +212,7 @@ private:
void setUsage(uint32_t reqUsage); void setUsage(uint32_t reqUsage);
bool getUsage(uint32_t* usage); uint32_t getUsage() const;
// constants // constants
sp<SurfaceComposerClient> mClient; sp<SurfaceComposerClient> mClient;
@@ -227,7 +227,6 @@ private:
// protected by mSurfaceLock // protected by mSurfaceLock
Rect mSwapRectangle; Rect mSwapRectangle;
uint32_t mUsage; uint32_t mUsage;
int32_t mUsageChanged;
// protected by mSurfaceLock. These are also used from lock/unlock // protected by mSurfaceLock. These are also used from lock/unlock
// but in that case, they must be called form the same thread. // but in that case, they must be called form the same thread.

View File

@@ -361,7 +361,6 @@ void Surface::init()
const_cast<uint32_t&>(android_native_window_t::flags) = 0; const_cast<uint32_t&>(android_native_window_t::flags) = 0;
// be default we request a hardware surface // be default we request a hardware surface
mUsage = GRALLOC_USAGE_HW_RENDER; mUsage = GRALLOC_USAGE_HW_RENDER;
mUsageChanged = true;
mNeedFullUpdate = false; mNeedFullUpdate = false;
} }
@@ -498,14 +497,14 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer)
LOGE("error dequeuing a buffer (%s)", strerror(bufIdx)); LOGE("error dequeuing a buffer (%s)", strerror(bufIdx));
return bufIdx; return bufIdx;
} }
// FIXME: in case of failure below, we need to undo the dequeue // below we make sure we AT LEAST have the usage flags we want
const uint32_t usage(getUsage());
uint32_t usage;
const bool usageChanged = getUsage(&usage);
const sp<SurfaceBuffer>& backBuffer(mBuffers[bufIdx]); const sp<SurfaceBuffer>& backBuffer(mBuffers[bufIdx]);
if ((backBuffer == 0) || usageChanged || if (backBuffer == 0 ||
mSharedBufferClient->needNewBuffer(bufIdx)) { ((uint32_t(backBuffer->usage) & usage) != usage) ||
mSharedBufferClient->needNewBuffer(bufIdx))
{
err = getBufferLocked(bufIdx, usage); err = getBufferLocked(bufIdx, usage);
LOGE_IF(err, "getBufferLocked(%ld, %08x) failed (%s)", LOGE_IF(err, "getBufferLocked(%ld, %08x) failed (%s)",
bufIdx, usage, strerror(-err)); bufIdx, usage, strerror(-err));
@@ -600,21 +599,13 @@ int Surface::perform(int operation, va_list args)
void Surface::setUsage(uint32_t reqUsage) void Surface::setUsage(uint32_t reqUsage)
{ {
Mutex::Autolock _l(mSurfaceLock); Mutex::Autolock _l(mSurfaceLock);
if (mUsage != reqUsage) { mUsage = reqUsage;
mUsageChanged = true;
mUsage = reqUsage;
}
} }
bool Surface::getUsage(uint32_t* usage) uint32_t Surface::getUsage() const
{ {
Mutex::Autolock _l(mSurfaceLock); Mutex::Autolock _l(mSurfaceLock);
*usage = mUsage; return mUsage;
if (mUsageChanged) {
mUsageChanged = false;
return true;
}
return false;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------