gralloc: Add automatic format selection

Have gralloc_alloc be able to select the appropriate pixel format
given the endpoints, triggered by new
GRALLOC_EMULATOR_PIXEL_FORMAT_AUTO format.

Currently supports camera->screen, and camera->video encoder.

Bug: 6243944
Change-Id: Ib1bf8da8d9184ac99e7f50aad09212c146c32809
This commit is contained in:
Eino-Ville Talvala
2012-07-17 16:13:52 -07:00
parent cefc43263a
commit ac4d519f43
3 changed files with 76 additions and 19 deletions

View File

@@ -24,23 +24,36 @@
#define BUFFER_HANDLE_MAGIC ((int)0xabfabfab)
#define CB_HANDLE_NUM_INTS(nfds) (int)((sizeof(cb_handle_t) - (nfds)*sizeof(int)) / sizeof(int))
//
// Emulator-specific gralloc formats
//
enum {
// Request that gralloc select the proper format given the usage
// flags. Pass this as the format to gralloc_alloc, and then the concrete
// format can be found in cb_handle_t.format. It is invalid for
// cb_handle_t.format to be AUTO; it must be a concrete format in either the
// standard HAL_PIXEL_FORMAT enum or other values in this enum.
GRALLOC_EMULATOR_PIXEL_FORMAT_AUTO = 0x100
};
//
// Our buffer handle structure
//
struct cb_handle_t : public native_handle {
cb_handle_t(int p_fd, int p_ashmemSize, int p_usage,
int p_width, int p_height,
int p_width, int p_height, int p_format,
int p_glFormat, int p_glType) :
fd(p_fd),
magic(BUFFER_HANDLE_MAGIC),
usage(p_usage),
width(p_width),
height(p_height),
format(p_format),
glFormat(p_glFormat),
glType(p_glType),
ashmemSize(p_ashmemSize),
ashmemBase(NULL),
ashmemBase(0),
ashmemBasePid(0),
mappedPid(0),
lockedLeft(0),
@@ -88,6 +101,7 @@ struct cb_handle_t : public native_handle {
int usage; // usage bits the buffer was created with
int width; // buffer width
int height; // buffer height
int format; // real internal pixel format format
int glFormat; // OpenGL format enum used for host h/w color buffer
int glType; // OpenGL type enum used when uploading to host
int ashmemSize; // ashmem region size for the buffer (0 unless is HW_FB buffer or