From ba64a65af2567302054b3c2457e5176bb1bcb053 Mon Sep 17 00:00:00 2001 From: Naseer Ahmed Date: Wed, 23 Nov 2011 12:25:38 -0800 Subject: [PATCH] libgralloc: Add gralloc perform to create handle from a buffer Change-Id: I11fb9add49f32cc5d518baf47cb61507474f6809 --- libgralloc/gralloc_priv.h | 7 +++++++ libgralloc/mapper.cpp | 23 ++++++----------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/libgralloc/gralloc_priv.h b/libgralloc/gralloc_priv.h index 5461ede..6118001 100644 --- a/libgralloc/gralloc_priv.h +++ b/libgralloc/gralloc_priv.h @@ -52,6 +52,13 @@ enum { GRALLOC_USAGE_PRIVATE_ION = 0x00020000, }; +enum { + /* Gralloc perform enums + */ + GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER = 0x080000001, +}; + + enum { GPU_COMPOSITION, C2D_COMPOSITION, diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp index 2c01b15..2cecbd5 100755 --- a/libgralloc/mapper.cpp +++ b/libgralloc/mapper.cpp @@ -309,7 +309,6 @@ int gralloc_perform(struct gralloc_module_t const* module, int res = -EINVAL; va_list args; va_start(args, operation); -#if 0 switch (operation) { case GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER: { @@ -317,6 +316,9 @@ int gralloc_perform(struct gralloc_module_t const* module, size_t size = va_arg(args, size_t); size_t offset = va_arg(args, size_t); void* base = va_arg(args, void*); + int width = va_arg(args, int); + int height = va_arg(args, int); + int format = va_arg(args, int); native_handle_t** handle = va_arg(args, native_handle_t**); int memoryFlags = va_arg(args, int); @@ -346,31 +348,18 @@ int gralloc_perform(struct gralloc_module_t const* module, hnd->size = size; hnd->offset = offset; hnd->base = intptr_t(base) + offset; - hnd->lockState = private_handle_t::LOCK_STATE_MAPPED; hnd->gpuaddr = 0; + hnd->width = width; + hnd->height = height; + hnd->format = format; *handle = (native_handle_t *)hnd; res = 0; break; } - case GRALLOC_MODULE_PERFORM_UPDATE_BUFFER_HANDLE: - { - native_handle_t* handle = va_arg(args, native_handle_t*); - int w = va_arg(args, int); - int h = va_arg(args, int); - int f = va_arg(args, int); - private_handle_t* hnd = (private_handle_t*)handle; - hnd->width = w; - hnd->height = h; - if (hnd->format != f) { - hnd->format = f; - } - break; - } default: break; } -#endif va_end(args); return res; }