summaryrefslogtreecommitdiff
path: root/libs/surfaceflinger/LayerBitmap.cpp
diff options
context:
space:
mode:
author Android (Google) Code Review <android-gerrit@google.com> 2009-08-11 20:50:32 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2009-08-11 20:50:32 -0700
commitefefd5efb9e20fbcd94c3f4766ca2a64e511da77 (patch)
tree64b527b57b6e206497402e053e0b35a869a57915 /libs/surfaceflinger/LayerBitmap.cpp
parentd7fe92b85812c53079b813543d722922e4ce7a4a (diff)
parent64e89a8aff9a45a491f1d7064a655b9021fe644a (diff)
Merge change 20892
* changes: Revert "SurfaceFlinger will now allocate buffers based on the usage specified by the clients. This allows to allocate the right kind of buffer automatically, without having the user to specify anything."
Diffstat (limited to 'libs/surfaceflinger/LayerBitmap.cpp')
-rw-r--r--libs/surfaceflinger/LayerBitmap.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/libs/surfaceflinger/LayerBitmap.cpp b/libs/surfaceflinger/LayerBitmap.cpp
index 5e74451d5f04..5221fed56f4d 100644
--- a/libs/surfaceflinger/LayerBitmap.cpp
+++ b/libs/surfaceflinger/LayerBitmap.cpp
@@ -38,14 +38,13 @@ namespace android {
// Buffer and implementation of android_native_buffer_t
// ===========================================================================
-Buffer::Buffer(uint32_t w, uint32_t h, PixelFormat format,
- uint32_t reqUsage, uint32_t flags)
+Buffer::Buffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t flags)
: SurfaceBuffer(), mInitCheck(NO_INIT), mFlags(flags),
mVStride(0)
{
this->format = format;
if (w>0 && h>0) {
- mInitCheck = initSize(w, h, reqUsage);
+ mInitCheck = initSize(w, h);
}
}
@@ -66,7 +65,7 @@ android_native_buffer_t* Buffer::getNativeBuffer() const
return static_cast<android_native_buffer_t*>(const_cast<Buffer*>(this));
}
-status_t Buffer::initSize(uint32_t w, uint32_t h, uint32_t reqUsage)
+status_t Buffer::initSize(uint32_t w, uint32_t h)
{
status_t err = NO_ERROR;
@@ -89,9 +88,16 @@ status_t Buffer::initSize(uint32_t w, uint32_t h, uint32_t reqUsage)
usage = BufferAllocator::USAGE_SW_READ_OFTEN |
BufferAllocator::USAGE_SW_WRITE_OFTEN;
} else {
- // it's allowed to modify the usage flags here, but generally
- // the requested flags should be honored.
- usage = reqUsage | BufferAllocator::USAGE_HW_TEXTURE;
+ if (mFlags & Buffer::GPU) {
+ // the client wants to do GL rendering
+ usage = BufferAllocator::USAGE_HW_RENDER |
+ BufferAllocator::USAGE_HW_TEXTURE;
+ } else {
+ // software rendering-client, h/w composition
+ usage = BufferAllocator::USAGE_SW_READ_OFTEN |
+ BufferAllocator::USAGE_SW_WRITE_OFTEN |
+ BufferAllocator::USAGE_HW_TEXTURE;
+ }
}
err = allocator.alloc(w, h, format, usage, &handle, &stride);
@@ -168,12 +174,12 @@ status_t LayerBitmap::setSize(uint32_t w, uint32_t h)
return NO_ERROR;
}
-sp<Buffer> LayerBitmap::allocate(uint32_t reqUsage)
+sp<Buffer> LayerBitmap::allocate()
{
Mutex::Autolock _l(mLock);
surface_info_t* info = mInfo;
mBuffer.clear(); // free buffer before allocating a new one
- sp<Buffer> buffer = new Buffer(mWidth, mHeight, mFormat, reqUsage, mFlags);
+ sp<Buffer> buffer = new Buffer(mWidth, mHeight, mFormat, mFlags);
status_t err = buffer->initCheck();
if (LIKELY(err == NO_ERROR)) {
info->flags = surface_info_t::eBufferDirty;