From 5cec4742b3a1d7448bd32ae57cb4cf70b484c64c Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Tue, 11 Aug 2009 22:34:02 -0700 Subject: second take, hopefully this time it doesn't break one of the builds: "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." --- libs/surfaceflinger/LayerBitmap.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'libs/surfaceflinger/LayerBitmap.cpp') diff --git a/libs/surfaceflinger/LayerBitmap.cpp b/libs/surfaceflinger/LayerBitmap.cpp index 5221fed56f4d..5e74451d5f04 100644 --- a/libs/surfaceflinger/LayerBitmap.cpp +++ b/libs/surfaceflinger/LayerBitmap.cpp @@ -38,13 +38,14 @@ namespace android { // Buffer and implementation of android_native_buffer_t // =========================================================================== -Buffer::Buffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t flags) +Buffer::Buffer(uint32_t w, uint32_t h, PixelFormat format, + uint32_t reqUsage, uint32_t flags) : SurfaceBuffer(), mInitCheck(NO_INIT), mFlags(flags), mVStride(0) { this->format = format; if (w>0 && h>0) { - mInitCheck = initSize(w, h); + mInitCheck = initSize(w, h, reqUsage); } } @@ -65,7 +66,7 @@ android_native_buffer_t* Buffer::getNativeBuffer() const return static_cast(const_cast(this)); } -status_t Buffer::initSize(uint32_t w, uint32_t h) +status_t Buffer::initSize(uint32_t w, uint32_t h, uint32_t reqUsage) { status_t err = NO_ERROR; @@ -88,16 +89,9 @@ status_t Buffer::initSize(uint32_t w, uint32_t h) usage = BufferAllocator::USAGE_SW_READ_OFTEN | BufferAllocator::USAGE_SW_WRITE_OFTEN; } else { - 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; - } + // it's allowed to modify the usage flags here, but generally + // the requested flags should be honored. + usage = reqUsage | BufferAllocator::USAGE_HW_TEXTURE; } err = allocator.alloc(w, h, format, usage, &handle, &stride); @@ -174,12 +168,12 @@ status_t LayerBitmap::setSize(uint32_t w, uint32_t h) return NO_ERROR; } -sp LayerBitmap::allocate() +sp LayerBitmap::allocate(uint32_t reqUsage) { Mutex::Autolock _l(mLock); surface_info_t* info = mInfo; mBuffer.clear(); // free buffer before allocating a new one - sp buffer = new Buffer(mWidth, mHeight, mFormat, mFlags); + sp buffer = new Buffer(mWidth, mHeight, mFormat, reqUsage, mFlags); status_t err = buffer->initCheck(); if (LIKELY(err == NO_ERROR)) { info->flags = surface_info_t::eBufferDirty; -- cgit v1.2.3-59-g8ed1b