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."
This commit is contained in:
@@ -63,7 +63,6 @@ private:
|
||||
static int lockBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
|
||||
static int queueBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
|
||||
static int query(android_native_window_t* window, int what, int* value);
|
||||
static int perform(android_native_window_t* window, int operation, ...);
|
||||
|
||||
framebuffer_device_t* fbDev;
|
||||
alloc_device_t* grDev;
|
||||
|
||||
@@ -50,7 +50,7 @@ protected:
|
||||
public:
|
||||
DECLARE_META_INTERFACE(Surface);
|
||||
|
||||
virtual sp<SurfaceBuffer> getBuffer(int usage) = 0;
|
||||
virtual sp<SurfaceBuffer> getBuffer() = 0;
|
||||
|
||||
class BufferHeap {
|
||||
public:
|
||||
|
||||
@@ -184,7 +184,7 @@ private:
|
||||
friend class IOMX;
|
||||
const sp<ISurface>& getISurface() const { return mSurface; }
|
||||
|
||||
status_t getBufferLocked(int index, int usage);
|
||||
status_t getBufferLocked(int index);
|
||||
|
||||
status_t validate(per_client_cblk_t const* cblk) const;
|
||||
static void _send_dirty_region(layer_cblk_t* lcblk, const Region& dirty);
|
||||
@@ -197,13 +197,11 @@ private:
|
||||
static int lockBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
|
||||
static int queueBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
|
||||
static int query(android_native_window_t* window, int what, int* value);
|
||||
static int perform(android_native_window_t* window, int operation, ...);
|
||||
|
||||
int dequeueBuffer(android_native_buffer_t** buffer);
|
||||
int lockBuffer(android_native_buffer_t* buffer);
|
||||
int queueBuffer(android_native_buffer_t* buffer);
|
||||
int query(int what, int* value);
|
||||
int perform(int operation, va_list args);
|
||||
|
||||
status_t dequeueBuffer(sp<SurfaceBuffer>* buffer);
|
||||
status_t lockBuffer(const sp<SurfaceBuffer>& buffer);
|
||||
@@ -219,7 +217,6 @@ private:
|
||||
uint32_t mIdentity;
|
||||
uint32_t mWidth;
|
||||
uint32_t mHeight;
|
||||
uint32_t mUsage;
|
||||
PixelFormat mFormat;
|
||||
uint32_t mFlags;
|
||||
mutable Region mDirtyRegion;
|
||||
|
||||
@@ -67,11 +67,6 @@ enum {
|
||||
NATIVE_WINDOW_FORMAT = 2,
|
||||
};
|
||||
|
||||
/* valid operations for the (*perform)() hook */
|
||||
enum {
|
||||
NATIVE_WINDOW_SET_USAGE = 0
|
||||
};
|
||||
|
||||
struct android_native_window_t
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
@@ -147,45 +142,11 @@ struct android_native_window_t
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*query)(struct android_native_window_t* window,
|
||||
int what, int* value);
|
||||
int what, int* value);
|
||||
|
||||
/*
|
||||
* hook used to perform various operations on the surface.
|
||||
* (*perform)() is a generic mechanism to add functionality to
|
||||
* android_native_window_t while keeping backward binary compatibility.
|
||||
*
|
||||
* This hook should not be called directly, instead use the helper functions
|
||||
* defined below.
|
||||
*
|
||||
* The valid operations are:
|
||||
* NATIVE_WINDOW_SET_USAGE
|
||||
*
|
||||
*/
|
||||
|
||||
int (*perform)(struct android_native_window_t* window,
|
||||
int operation, ... );
|
||||
|
||||
void* reserved_proc[3];
|
||||
void* reserved_proc[4];
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* native_window_set_usage() sets the intended usage flags for the next
|
||||
* buffers acquired with (*lockBuffer)() and on.
|
||||
* By default (if this function is never called), a usage of
|
||||
* GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
|
||||
* is assumed.
|
||||
* Calling this function will usually cause following buffers to be
|
||||
* reallocated.
|
||||
*/
|
||||
|
||||
inline int native_window_set_usage(
|
||||
struct android_native_window_t* window, int usage)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/* FIXME: this is legacy for pixmaps */
|
||||
|
||||
@@ -217,7 +217,7 @@ void Layer::onDraw(const Region& clip) const
|
||||
drawWithOpenGL(clip, mTextures[index]);
|
||||
}
|
||||
|
||||
sp<SurfaceBuffer> Layer::peekBuffer(int usage)
|
||||
sp<SurfaceBuffer> Layer::peekBuffer()
|
||||
{
|
||||
/*
|
||||
* This is called from the client's Surface::lock(), after it locked
|
||||
@@ -250,7 +250,7 @@ sp<SurfaceBuffer> Layer::peekBuffer(int usage)
|
||||
}
|
||||
|
||||
LayerBitmap& layerBitmap(mBuffers[backBufferIndex]);
|
||||
sp<SurfaceBuffer> buffer = layerBitmap.allocate(usage);
|
||||
sp<SurfaceBuffer> buffer = layerBitmap.allocate();
|
||||
|
||||
LOGD_IF(DEBUG_RESIZE,
|
||||
"Layer::getBuffer(this=%p), index=%d, (%d,%d), (%d,%d)",
|
||||
@@ -649,12 +649,12 @@ Layer::SurfaceLayer::~SurfaceLayer()
|
||||
{
|
||||
}
|
||||
|
||||
sp<SurfaceBuffer> Layer::SurfaceLayer::getBuffer(int usage)
|
||||
sp<SurfaceBuffer> Layer::SurfaceLayer::getBuffer()
|
||||
{
|
||||
sp<SurfaceBuffer> buffer = 0;
|
||||
sp<Layer> owner(getOwner());
|
||||
if (owner != 0) {
|
||||
buffer = owner->peekBuffer(usage);
|
||||
buffer = owner->peekBuffer();
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ private:
|
||||
|
||||
status_t resize(int32_t index, uint32_t w, uint32_t h, const char* what);
|
||||
Region post(uint32_t* oldState, bool& recomputeVisibleRegions);
|
||||
sp<SurfaceBuffer> peekBuffer(int usage);
|
||||
sp<SurfaceBuffer> peekBuffer();
|
||||
void destroy();
|
||||
void scheduleBroadcast();
|
||||
|
||||
@@ -114,7 +114,7 @@ private:
|
||||
~SurfaceLayer();
|
||||
|
||||
private:
|
||||
virtual sp<SurfaceBuffer> getBuffer(int usage);
|
||||
virtual sp<SurfaceBuffer> getBuffer();
|
||||
|
||||
sp<Layer> getOwner() const {
|
||||
return static_cast<Layer*>(Surface::getOwner().get());
|
||||
|
||||
@@ -759,7 +759,7 @@ status_t LayerBaseClient::Surface::onTransact(
|
||||
return BnSurface::onTransact(code, data, reply, flags);
|
||||
}
|
||||
|
||||
sp<SurfaceBuffer> LayerBaseClient::Surface::getBuffer(int)
|
||||
sp<SurfaceBuffer> LayerBaseClient::Surface::getBuffer()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ public:
|
||||
sp<LayerBaseClient> getOwner() const;
|
||||
|
||||
private:
|
||||
virtual sp<SurfaceBuffer> getBuffer(int usage);
|
||||
virtual sp<SurfaceBuffer> getBuffer();
|
||||
virtual status_t registerBuffers(const ISurface::BufferHeap& buffers);
|
||||
virtual void postBuffer(ssize_t offset);
|
||||
virtual void unregisterBuffers();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -58,8 +58,7 @@ public:
|
||||
};
|
||||
|
||||
// creates w * h buffer
|
||||
Buffer(uint32_t w, uint32_t h, PixelFormat format,
|
||||
uint32_t reqUsage, uint32_t flags = 0);
|
||||
Buffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t flags = 0);
|
||||
|
||||
// return status
|
||||
status_t initCheck() const;
|
||||
@@ -82,7 +81,7 @@ private:
|
||||
Buffer& operator = (const Buffer& rhs);
|
||||
const Buffer& operator = (const Buffer& rhs) const;
|
||||
|
||||
status_t initSize(uint32_t w, uint32_t h, uint32_t reqUsage);
|
||||
status_t initSize(uint32_t w, uint32_t h);
|
||||
|
||||
ssize_t mInitCheck;
|
||||
uint32_t mFlags;
|
||||
@@ -109,7 +108,7 @@ public:
|
||||
|
||||
status_t setSize(uint32_t w, uint32_t h);
|
||||
|
||||
sp<Buffer> allocate(uint32_t reqUsage);
|
||||
sp<Buffer> allocate();
|
||||
status_t free();
|
||||
|
||||
sp<const Buffer> getBuffer() const { return mBuffer; }
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
#include <hardware/copybit.h>
|
||||
|
||||
#include "BufferAllocator.h"
|
||||
#include "LayerBuffer.h"
|
||||
#include "SurfaceFlinger.h"
|
||||
#include "DisplayHardware/DisplayHardware.h"
|
||||
@@ -465,10 +464,7 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const
|
||||
mTempBitmap->getWidth() < tmp_w ||
|
||||
mTempBitmap->getHeight() < tmp_h) {
|
||||
mTempBitmap.clear();
|
||||
mTempBitmap = new android::Buffer(
|
||||
tmp_w, tmp_h, src.img.format,
|
||||
BufferAllocator::USAGE_HW_TEXTURE |
|
||||
BufferAllocator::USAGE_HW_2D);
|
||||
mTempBitmap = new android::Buffer(tmp_w, tmp_h, src.img.format);
|
||||
err = mTempBitmap->initCheck();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <utils/Errors.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "BufferAllocator.h"
|
||||
#include "LayerDim.h"
|
||||
#include "SurfaceFlinger.h"
|
||||
#include "DisplayHardware/DisplayHardware.h"
|
||||
@@ -69,11 +68,7 @@ void LayerDim::initDimmer(SurfaceFlinger* flinger, uint32_t w, uint32_t h)
|
||||
|
||||
if (LIKELY(flags & DisplayHardware::DIRECT_TEXTURE)) {
|
||||
// TODO: api to pass the usage flags
|
||||
sp<Buffer> buffer = new Buffer(w, h, PIXEL_FORMAT_RGB_565,
|
||||
BufferAllocator::USAGE_SW_WRITE_OFTEN |
|
||||
BufferAllocator::USAGE_HW_TEXTURE |
|
||||
BufferAllocator::USAGE_HW_2D);
|
||||
|
||||
sp<Buffer> buffer = new Buffer(w, h, PIXEL_FORMAT_RGB_565);
|
||||
android_native_buffer_t* clientBuf = buffer->getNativeBuffer();
|
||||
|
||||
glGenTextures(1, &sTexId);
|
||||
|
||||
@@ -132,7 +132,6 @@ FramebufferNativeWindow::FramebufferNativeWindow()
|
||||
android_native_window_t::lockBuffer = lockBuffer;
|
||||
android_native_window_t::queueBuffer = queueBuffer;
|
||||
android_native_window_t::query = query;
|
||||
android_native_window_t::perform = perform;
|
||||
}
|
||||
|
||||
FramebufferNativeWindow::~FramebufferNativeWindow()
|
||||
@@ -236,18 +235,6 @@ int FramebufferNativeWindow::query(android_native_window_t* window,
|
||||
return BAD_VALUE;
|
||||
}
|
||||
|
||||
int FramebufferNativeWindow::perform(android_native_window_t* window,
|
||||
int operation, ...)
|
||||
{
|
||||
switch (operation) {
|
||||
case NATIVE_WINDOW_SET_USAGE:
|
||||
break;
|
||||
default:
|
||||
return NAME_NOT_FOUND;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
}; // namespace android
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -71,11 +71,10 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual sp<SurfaceBuffer> getBuffer(int usage)
|
||||
virtual sp<SurfaceBuffer> getBuffer()
|
||||
{
|
||||
Parcel data, reply;
|
||||
data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
|
||||
data.writeInt32(usage);
|
||||
remote()->transact(GET_BUFFER, data, &reply);
|
||||
sp<SurfaceBuffer> buffer = new SurfaceBuffer(reply);
|
||||
return buffer;
|
||||
@@ -136,8 +135,7 @@ status_t BnSurface::onTransact(
|
||||
switch(code) {
|
||||
case GET_BUFFER: {
|
||||
CHECK_INTERFACE(ISurface, data, reply);
|
||||
int usage = data.readInt32();
|
||||
sp<SurfaceBuffer> buffer(getBuffer(usage));
|
||||
sp<SurfaceBuffer> buffer(getBuffer());
|
||||
return SurfaceBuffer::writeToParcel(reply, buffer.get());
|
||||
}
|
||||
case REGISTER_BUFFERS: {
|
||||
|
||||
@@ -414,7 +414,6 @@ void Surface::init()
|
||||
android_native_window_t::lockBuffer = lockBuffer;
|
||||
android_native_window_t::queueBuffer = queueBuffer;
|
||||
android_native_window_t::query = query;
|
||||
android_native_window_t::perform = perform;
|
||||
mSwapRectangle.makeInvalid();
|
||||
DisplayInfo dinfo;
|
||||
SurfaceComposerClient::getDisplayInfo(0, &dinfo);
|
||||
@@ -424,8 +423,6 @@ void Surface::init()
|
||||
const_cast<int&>(android_native_window_t::minSwapInterval) = 1;
|
||||
const_cast<int&>(android_native_window_t::maxSwapInterval) = 1;
|
||||
const_cast<uint32_t&>(android_native_window_t::flags) = 0;
|
||||
// be default we request a hardware surface
|
||||
mUsage = GRALLOC_USAGE_HW_RENDER;
|
||||
}
|
||||
|
||||
|
||||
@@ -515,17 +512,6 @@ int Surface::query(android_native_window_t* window,
|
||||
return self->query(what, value);
|
||||
}
|
||||
|
||||
int Surface::perform(android_native_window_t* window,
|
||||
int operation, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, operation);
|
||||
Surface* self = getSelf(window);
|
||||
int res = self->perform(operation, args);
|
||||
va_end(args);
|
||||
return res;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
status_t Surface::dequeueBuffer(sp<SurfaceBuffer>* buffer)
|
||||
@@ -575,7 +561,7 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer)
|
||||
|
||||
volatile const surface_info_t* const back = lcblk->surface + backIdx;
|
||||
if (back->flags & surface_info_t::eNeedNewBuffer) {
|
||||
err = getBufferLocked(backIdx, mUsage);
|
||||
err = getBufferLocked(backIdx);
|
||||
}
|
||||
|
||||
if (err == NO_ERROR) {
|
||||
@@ -641,20 +627,6 @@ int Surface::query(int what, int* value)
|
||||
return BAD_VALUE;
|
||||
}
|
||||
|
||||
int Surface::perform(int operation, va_list args)
|
||||
{
|
||||
int res = NO_ERROR;
|
||||
switch (operation) {
|
||||
case NATIVE_WINDOW_SET_USAGE:
|
||||
mUsage = va_arg(args, int);
|
||||
break;
|
||||
default:
|
||||
res = NAME_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
status_t Surface::lock(SurfaceInfo* info, bool blocking) {
|
||||
@@ -664,9 +636,6 @@ status_t Surface::lock(SurfaceInfo* info, bool blocking) {
|
||||
status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn, bool blocking)
|
||||
{
|
||||
// FIXME: needs some locking here
|
||||
|
||||
// we're intending to do software rendering from this point
|
||||
mUsage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN;
|
||||
|
||||
sp<SurfaceBuffer> backBuffer;
|
||||
status_t err = dequeueBuffer(&backBuffer);
|
||||
@@ -756,10 +725,10 @@ void Surface::setSwapRectangle(const Rect& r) {
|
||||
mSwapRectangle = r;
|
||||
}
|
||||
|
||||
status_t Surface::getBufferLocked(int index, int usage)
|
||||
status_t Surface::getBufferLocked(int index)
|
||||
{
|
||||
status_t err = NO_MEMORY;
|
||||
sp<SurfaceBuffer> buffer = mSurface->getBuffer(usage);
|
||||
sp<SurfaceBuffer> buffer = mSurface->getBuffer();
|
||||
LOGE_IF(buffer==0, "ISurface::getBuffer() returned NULL");
|
||||
if (buffer != 0) {
|
||||
sp<SurfaceBuffer>& currentBuffer(mBuffers[index]);
|
||||
|
||||
@@ -384,10 +384,6 @@ egl_window_surface_v2_t::~egl_window_surface_v2_t() {
|
||||
|
||||
EGLBoolean egl_window_surface_v2_t::connect()
|
||||
{
|
||||
// we're intending to do software rendering
|
||||
native_window_set_usage(nativeWindow,
|
||||
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
|
||||
|
||||
// dequeue a buffer
|
||||
if (nativeWindow->dequeueBuffer(nativeWindow, &buffer) != NO_ERROR) {
|
||||
return setError(EGL_BAD_ALLOC, EGL_FALSE);
|
||||
|
||||
Reference in New Issue
Block a user