} \
}
+#define TBM_SURFACE_RETURN_ERR_IF_FAIL(cond, error_type) {\
+ if (!(cond)) {\
+ TBM_ERR("'%s' failed.\n", #cond);\
+ _tbm_set_last_result(error_type);\
+ _tbm_surface_mutex_unlock();\
+ return;\
+ } \
+}
+
+#define TBM_SURFACE_RETURN_SET_ERR_IF_FAIL(cond, error, error_type) {\
+ if (!(cond)) {\
+ TBM_ERR("'%s' failed.\n", #cond);\
+ error = error_type;\
+ _tbm_set_last_result(error_type);\
+ _tbm_surface_mutex_unlock();\
+ return;\
+ } \
+}
+
#define TBM_SURFACE_RETURN_VAL_IF_FAIL(cond, val) {\
if (!(cond)) {\
TBM_ERR("'%s' failed.\n", #cond);\
} \
}
+
+#define TBM_SURFACE_RETURN_VAL_ERR_IF_FAIL(cond, val, error_type) {\
+ if (!(cond)) {\
+ TBM_ERR("'%s' failed.\n", #cond);\
+ _tbm_set_last_result(error_type);\
+ _tbm_surface_mutex_unlock();\
+ return val;\
+ } \
+}
+
+#define TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(cond, val, error, error_type) {\
+ if (!(cond)) {\
+ TBM_ERR("'%s' failed.\n", #cond);\
+ if (error)\
+ *error = error_type;\
+ _tbm_set_last_result(error_type);\
+ _tbm_surface_mutex_unlock();\
+ return val;\
+ } \
+}
+
/* LCOV_EXCL_START */
static double
_tbm_surface_internal_get_time(void)
struct _tbm_surface *surf = (struct _tbm_surface *)surface;
struct _tbm_bufmgr *bufmgr = surf->bufmgr;
- int ret = 0;
tbm_error_e error;
TBM_RETURN_VAL_IF_FAIL(bufmgr != NULL, 0);
TBM_RETURN_VAL_IF_FAIL(surf->info.height > 0, 0);
TBM_RETURN_VAL_IF_FAIL(surf->info.format > 0, 0);
- if (bufmgr->use_hal_tbm) {
- error = (tbm_error_e)hal_tbm_bufmgr_get_plane_data(bufmgr->hal_bufmgr, (hal_tbm_format)surf->info.format,
- plane_idx, surf->info.width, surf->info.height, size, offset, pitch, bo_idx);
- /* LCOV_EXCL_START */
- if (error == TBM_ERROR_NOT_SUPPORTED) {
- _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
- return 0;
- } else if (error != TBM_ERROR_NONE) {
- TBM_ERR("Fail to surface_get_plane_data. surface(%p) error(%d)\n", surface, error);
- _tbm_set_last_result(error);
- return 0;
- }
- /* LCOV_EXCL_STOP */
- ret = 1;
- } else if (bufmgr->backend_module_data) {
- if (!bufmgr->bufmgr_func->bufmgr_get_plane_data) {
- _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
- return 0;
- }
-
- error = bufmgr->bufmgr_func->bufmgr_get_plane_data(bufmgr->bufmgr_data, surf->info.format, plane_idx,
- surf->info.width, surf->info.height, size, offset, pitch, bo_idx);
- if (error != TBM_ERROR_NONE) {
- /* LCOV_EXCL_START */
- TBM_ERR("Fail to surface_get_plane_data. surface(%p) error(%d)\n", surface, error);
- _tbm_set_last_result(error);
- return 0;
- /* LCOV_EXCL_STOP */
- }
- ret = 1;
- } else {
- if (!bufmgr->backend->surface_get_plane_data) {
- _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
- return 0;
- }
-
- ret = bufmgr->backend->surface_get_plane_data(surf->info.width,
- surf->info.height, surf->info.format, plane_idx, size, offset, pitch, bo_idx);
- if (!ret) {
- /* LCOV_EXCL_START */
- TBM_ERR("Fail to surface_get_plane_data. surface(%p)\n", surface);
- _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
- return 0;
- /* LCOV_EXCL_STOP */
- }
+ error = tbm_module_get_plane_data(bufmgr->module, surf->info.format, plane_idx, surf->info.width, surf->info.height, size, offset, pitch, bo_idx);
+ if (error != TBM_ERROR_NONE) {
+ _tbm_set_last_result(error);
+ return 0;
}
- return ret;
+ return 1;
}
static void
LIST_DEL(&surface->item_link);
surface->magic = 0;
+ if (surface->surface_data) {
+ tbm_surface_data_free(surface->surface_data);
+ surface->surface_data = NULL;
+ }
+
free(surface);
surface = NULL;
return bpp;
}
+static void
+_tbm_surface_internal_free(struct _tbm_surface *surf)
+{
+ if (!surf)
+ return;
+
+ free(surf);
+}
+
static struct _tbm_surface *
-_tbm_surface_internal_create_surface(tbm_bufmgr bufmgr, int width, int height, int format, int flags, tbm_error_e *error)
+_tbm_surface_internal_alloc(tbm_bufmgr bufmgr, int width, int height, int format, tbm_error_e *error)
{
struct _tbm_surface *surf = NULL;
- uint32_t size = 0, offset = 0, stride = 0, bo_size = 0;
- int i, j, bo_idx;
surf = calloc(1, sizeof(struct _tbm_surface));
if (!surf) {
/* LCOV_EXCL_START */
- TBM_ERR("fail to alloc surf\n");
+ TBM_ERR("memory allocation failed.");
*error = TBM_ERROR_OUT_OF_MEMORY;
- goto alloc_surf_fail;
+ return NULL;
/* LCOV_EXCL_STOP */
}
+ surf->refcnt = 1;
surf->magic = TBM_SURFACE_MAGIC;
surf->bufmgr = bufmgr;
surf->info.format = format;
surf->info.bpp = _tbm_surface_internal_get_bpp(format);
if (!surf->info.bpp) {
- TBM_ERR("fail to get bpp from format(%d), error(%s)\n", format, tbm_error_str(*error));
+ /* LCOV_EXCL_START */
+ TBM_ERR("_tbm_surface_internal_get_bpp failed. format:%d error:%s", format, tbm_error_str(*error));
*error = tbm_get_last_error();
- goto bpp_fail;
+ free(surf);
+ return NULL;
+ /* LCOV_EXCL_STOP */
}
+ // get number of planes
surf->info.num_planes = _tbm_surface_internal_get_num_planes(format);
if (!surf->info.num_planes) {
- TBM_ERR("fail to get num_planes from format(%d), error(%s)\n", format, tbm_error_str(*error));
+ /* LCOV_EXCL_START */
+ TBM_ERR("_tbm_surface_internal_get_num_planes failed. format:%d error:%s", format, tbm_error_str(*error));
*error = tbm_get_last_error();
- goto num_planes_fail;
+ free(surf);
+ return NULL;
+ /* LCOV_EXCL_STOP */
}
- surf->refcnt = 1;
- /* get size, stride and offset bo_idx */
- for (i = 0; i < surf->info.num_planes; i++) {
- if (!_tbm_surface_internal_query_plane_data(surf, i, &size, &offset, &stride, &bo_idx)) {
- TBM_ERR("fail to query plane data\n");
- *error = tbm_get_last_error();
- goto query_plane_data_fail;
+ return surf;
+}
+
+static tbm_error_e
+_tbm_surface_internal_set_data(struct _tbm_surface *surf, int flags, int is_surface_data)
+{
+ tbm_error_e error;
+ uint32_t size = 0, offset = 0, stride = 0, bo_size = 0;;
+ int i, j, bo_idx;
+ tbm_bo_data **bo_data_array = NULL;
+ int num_bos = 0;
+ int memory_types;
+
+ // set data with surface
+ if (is_surface_data) {
+ // set infomation of planes
+ for (i = 0; i < surf->info.num_planes; i++) {
+ error = tbm_surface_data_get_plane_data(surf->surface_data, i, &size, &offset, &stride, &bo_idx);
+ if (error != TBM_ERROR_NONE) {
+ TBM_ERR("tbm_surface_data_get_plane_data failed. error:%s", tbm_error_str(error));
+ return error;
+ }
+
+ surf->info.planes[i].size = size;
+ surf->info.planes[i].offset = offset;
+ surf->info.planes[i].stride = stride;
+ surf->planes_bo_idx[i] = bo_idx;
}
- surf->info.planes[i].size = size;
- surf->info.planes[i].offset = offset;
- surf->info.planes[i].stride = stride;
- surf->planes_bo_idx[i] = bo_idx;
- }
+ // get the bo_data_array
+ bo_data_array = tbm_surface_data_get_bo_data_array(surf->surface_data, &num_bos, &error);
+ if (!bo_data_array) {
+ TBM_ERR("tbm_surface_data_get_bo_data_array failed. error:%s", tbm_error_str(error));
+ return error;
+ }
+ surf->num_bos = num_bos;
- surf->num_bos = 1;
+ // calculate the size of a surface
+ for (i = 0; i < surf->info.num_planes; i++)
+ surf->info.size += surf->info.planes[i].size;
- for (i = 0; i < surf->info.num_planes; i++) {
- surf->info.size += surf->info.planes[i].size;
+ // get memory_types(bo flags)
+ memory_types = tbm_bo_data_get_memory_types(bo_data_array[0], &error);
+ if (error != TBM_ERROR_NONE) {
+ TBM_ERR("tbm_bo_data_get_memory_types failed. error:%s", tbm_error_str(error));
+ return error;
+ }
+ // set flags
+ surf->flags = memory_types;
- if (surf->num_bos < surf->planes_bo_idx[i] + 1)
- surf->num_bos = surf->planes_bo_idx[i] + 1;
- }
+ // allocate the array of tbm_bos
+ for (i = 0; i < num_bos; i++) {
+ surf->bos[i] = tbm_bufmgr_internal_alloc_bo_with_bo_data(surf->bufmgr, bo_data_array[i], memory_types, &error);
+ if (!surf->bos[i]) {
+ TBM_ERR("tbm_bufmgr_internal_alloc_bo_with_bo_data failed. error:%s idx:%d", tbm_error_str(error), i);
+ goto failed;
+ }
+
+ _tbm_bo_set_surface(surf->bos[i], surf);
+ }
+ } else {
+ // set infomation of planes
+ for (i = 0; i < surf->info.num_planes; i++) {
+ if (!_tbm_surface_internal_query_plane_data(surf, i, &size, &offset, &stride, &bo_idx)) {
+ TBM_ERR("_tbm_surface_internal_query_plane_data failed.");
+ error = tbm_get_last_error();
+ return error;
+ }
+
+ surf->info.planes[i].size = size;
+ surf->info.planes[i].offset = offset;
+ surf->info.planes[i].stride = stride;
+ surf->planes_bo_idx[i] = bo_idx;
+ }
- surf->flags = flags;
+ // calculate the number of bos
+ surf->num_bos = 1;
+ for (i = 0; i < surf->info.num_planes; i++) {
+ surf->info.size += surf->info.planes[i].size;
- for (i = 0; i < surf->num_bos; i++) {
- bo_size = 0;
- for (j = 0; j < surf->info.num_planes; j++) {
- if (surf->planes_bo_idx[j] == i)
- bo_size += surf->info.planes[j].size;
+ if (surf->num_bos < surf->planes_bo_idx[i] + 1)
+ surf->num_bos = surf->planes_bo_idx[i] + 1;
}
- if (bufmgr->use_hal_tbm) {
- surf->bos[i] = tbm_bo_alloc_with_format(bufmgr, format, i, width, height, surf->info.bpp/8, flags, error);
- if (*error == TBM_ERROR_NOT_SUPPORTED) {
- surf->bos[i] = tbm_bo_alloc(bufmgr, bo_size, flags);
- if (!surf->bos[i]) {
- TBM_ERR("fail to alloc bo idx:%d\n", i);
- *error = tbm_get_last_error();
- goto alloc_bo_fail;
- }
- }
- } else if (bufmgr->backend_module_data) {
- if (bufmgr->bufmgr_func->bufmgr_alloc_bo_with_format) {
- /* LCOV_EXCL_START */
- surf->bos[i] = tbm_bo_alloc_with_format(bufmgr, format, i, width, height, surf->info.bpp/8, flags, error);
- if (!surf->bos[i]) {
- TBM_ERR("fail to tbm_bo_alloc_with_format idx:%d\n", i);
- *error = tbm_get_last_error();
- goto alloc_bo_fail;
- }
- /* LCOV_EXCL_STOP */
- } else if (bufmgr->bufmgr_func->bufmgr_alloc_bo_with_tiled_format && (flags & TBM_BO_TILED)) {
- /* LCOV_EXCL_START */
- surf->bos[i] = tbm_bo_alloc_with_tiled_format(bufmgr, width, height, surf->info.bpp/8, format, flags, i, error);
- if (!surf->bos[i]) {
- TBM_ERR("fail to tbm_bo_alloc_with_tiled_format idx:%d\n", i);
- *error = tbm_get_last_error();
- goto alloc_bo_fail;
- }
- /* LCOV_EXCL_STOP */
- } else {
- surf->bos[i] = tbm_bo_alloc(bufmgr, bo_size, flags);
- if (!surf->bos[i]) {
- TBM_ERR("fail to alloc bo idx:%d\n", i);
- *error = tbm_get_last_error();
- goto alloc_bo_fail;
- }
+ // set flags
+ surf->flags = flags;
+
+ // allocate the array of tbm_bos
+ for (i = 0; i < surf->num_bos; i++) {
+ bo_size = 0;
+ for (j = 0; j < surf->info.num_planes; j++) {
+ if (surf->planes_bo_idx[j] == i)
+ bo_size += surf->info.planes[j].size;
}
- } else {
- if (bufmgr->backend->surface_bo_alloc) {
- /* LCOV_EXCL_START */
- surf->bos[i] = tbm_bo_alloc_with_surface(bufmgr, width, height, format, flags, i);
- if (!surf->bos[i]) {
- TBM_ERR("fail to tbm_bo_alloc_with_surface idx:%d\n", i);
- *error = tbm_get_last_error();
- goto alloc_bo_fail;
- /* LCOV_EXCL_STOP */
- }
- } else {
- surf->bos[i] = tbm_bo_alloc(bufmgr, bo_size, flags);
+
+ surf->bos[i] = tbm_bufmgr_internal_alloc_bo_with_format(surf->bufmgr,
+ surf->info.format, i, surf->info.width, surf->info.height,
+ surf->info.bpp/8, flags, &error);
+ if (!surf->bos[i]) {
+ surf->bos[i] = tbm_bo_alloc(surf->bufmgr, bo_size, flags);
if (!surf->bos[i]) {
- TBM_ERR("fail to alloc bo idx:%d\n", i);
- *error = tbm_get_last_error();
- goto alloc_bo_fail;
+ TBM_ERR("tbm_bo_alloc failed. idx:%d", i);
+ error = tbm_get_last_error();
+ goto failed;
}
}
- }
- _tbm_bo_set_surface(surf->bos[i], surf);
+ _tbm_bo_set_surface(surf->bos[i], surf);
+ }
}
- *error = TBM_ERROR_NONE;
-
- return surf;
+ return TBM_ERROR_NONE;
-alloc_bo_fail:
+failed:
for (j = 0; j < i; j++) {
if (surf->bos[j])
tbm_bo_unref(surf->bos[j]);
}
-query_plane_data_fail:
-bpp_fail:
-num_planes_fail:
- free(surf);
-alloc_surf_fail:
- return NULL;
+ return error;
+}
+
+static struct _tbm_surface *
+_tbm_surface_internal_create_surface(tbm_bufmgr bufmgr, int width, int height, int format, int flags, tbm_error_e *error)
+{
+ struct _tbm_surface *surf;
+ int is_surface_data = 0;
+
+ surf = _tbm_surface_internal_alloc(bufmgr, width, height, format, error);
+ if (!surf) {
+ /* LCOV_EXCL_START */
+ TBM_ERR("_tbm_surface_internal_alloc failed.");
+ return NULL;
+ /* LCOV_EXCL_STOP */
+ }
+
+ is_surface_data = tbm_module_support_surface_data(bufmgr->module);
+ if (is_surface_data) {
+ // alloc surface_data
+ surf->surface_data = tbm_module_alloc_surface_data(bufmgr->module, width, height, format, flags, error);
+ if (!surf->surface_data) {
+ TBM_ERR("tbm_module_alloc_surface_data failed. width:%d height:%d format:%d error:%s",
+ width, height, format, tbm_error_str(*error));
+ return NULL;
+ }
+ }
+
+ // set the surface data
+ *error = _tbm_surface_internal_set_data(surf, flags, is_surface_data);
+ if (*error != TBM_ERROR_NONE) {
+ tbm_surface_data_free(surf->surface_data);
+ surf->surface_data = NULL;
+ _tbm_surface_internal_free(surf);
+ return NULL;
+ }
+
+ return surf;
+}
+
+static struct _tbm_surface *
+_tbm_surface_internal_import_surface(tbm_bufmgr bufmgr, int width, int height, int format, tbm_surface_buffer_data *buffer_data, tbm_error_e *error)
+{
+ struct _tbm_surface *surf = NULL;
+
+ surf = _tbm_surface_internal_alloc(bufmgr, width, height, format, error);
+ if (!surf) {
+ /* LCOV_EXCL_START */
+ TBM_ERR("_tbm_surface_internal_alloc failed.");
+ return NULL;
+ /* LCOV_EXCL_STOP */
+ }
+
+ // import surface_data
+ surf->surface_data = tbm_module_import_surface_data(bufmgr->module, width, height, format, buffer_data, error);
+ if (!surf->surface_data) {
+ /* LCOV_EXCL_START */
+ TBM_ERR("tbm_module_import_surface_data failed. width:%d height:%d format:%d error:%s",
+ width, height, format, tbm_error_str(*error));
+ return NULL;
+ /* LCOV_EXCL_STOP */
+ }
+
+ // set the surface data
+ *error = _tbm_surface_internal_set_data(surf, TBM_BO_DEFAULT, 1);
+ if (*error != TBM_ERROR_NONE) {
+ /* LCOV_EXCL_START */
+ tbm_surface_data_free(surf->surface_data);
+ surf->surface_data = NULL;
+ _tbm_surface_internal_free(surf);
+ return NULL;
+ /* LCOV_EXCL_STOP */
+ }
+
+ return surf;
}
int
uint32_t *num)
{
struct _tbm_bufmgr *bufmgr;
- int ret = 0;
bool bufmgr_initialized = false;
tbm_error_e error;
bufmgr = g_surface_bufmgr;
- if (bufmgr->use_hal_tbm) {
- error = (tbm_error_e)hal_tbm_bufmgr_get_supported_formats(bufmgr->hal_bufmgr, formats, num);
- /* LCOV_EXCL_START */
- if (error == TBM_ERROR_NOT_SUPPORTED) {
- _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
- goto fail;
- } else if (error != TBM_ERROR_NONE) {
- _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
- goto fail;
- }
- /* LCOV_EXCL_STOP */
- ret = 1;
- } else if (bufmgr->backend_module_data) {
- if (!bufmgr->bufmgr_func->bufmgr_get_supported_formats) {
- _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
- goto fail;
- }
-
- error = bufmgr->bufmgr_func->bufmgr_get_supported_formats(bufmgr->bufmgr_data, formats, num);
- if (error != TBM_ERROR_NONE) {
- /* LCOV_EXCL_START */
- TBM_ERR("Fail to surface_supported_format. error(%d)\n", error);
- goto fail;
- /* LCOV_EXCL_START */
- }
- ret = 1;
- } else {
- if (!bufmgr->backend->surface_supported_format) {
- _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
- goto fail;
- }
-
- ret = bufmgr->backend->surface_supported_format(formats, num);
- if (!ret) {
- /* LCOV_EXCL_START */
- TBM_ERR("Fail to surface_supported_format.\n");
- _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
- goto fail;
- /* LCOV_EXCL_START */
- }
+ error = tbm_module_get_supported_formats(bufmgr->module, formats, num);
+ if (error != TBM_ERROR_NONE) {
+ _tbm_set_last_result(error);
+ goto fail;
}
TBM_TRACE_SURFACE_INTERNAL("tbm_bufmgr(%p) format num(%u)\n", g_surface_bufmgr, *num);
_tbm_surface_mutex_unlock();
- return ret;
+ return 1;
/* LCOV_EXCL_START */
fail:
goto check_valid_fail;
}
- // TODO: use_hal_tbm
surf = _tbm_surface_internal_create_surface(bufmgr, width, height, format, flags, &error);
if (!surf) {
TBM_ERR("_tbm_surface_internal_create_surface failed.");
for (x = 0; x < width; ++x) {
unsigned int curBlock = blocks[(y * (stride >> 2)) + x];
- if (pixel_size == 3) { // XRGB8888
- row[x * pixel_size] = (curBlock & 0xFF);
- row[1 + x * pixel_size] = (curBlock >> 8) & 0xFF;
- row[2 + x * pixel_size] = (curBlock >> 16) & 0xFF;
- } else { // ARGB8888
- row[x * pixel_size] = (curBlock & 0xFF);
- row[1 + x * pixel_size] = (curBlock >> 8) & 0xFF;
- row[2 + x * pixel_size] = (curBlock >> 16) & 0xFF;
- row[3 + x * pixel_size] = (curBlock >> 24) & 0xFF;
+ if (pixel_size == 3) { // XRGB8888 or XBGR8888
+ if (format == TBM_FORMAT_XRGB8888) {
+ row[x * pixel_size] = (curBlock & 0xFF);
+ row[1 + x * pixel_size] = (curBlock >> 8) & 0xFF;
+ row[2 + x * pixel_size] = (curBlock >> 16) & 0xFF;
+ } else {
+ row[x * pixel_size] = (curBlock >> 16) & 0xFF;
+ row[1 + x * pixel_size] = (curBlock >> 8) & 0xFF;
+ row[2 + x * pixel_size] = (curBlock & 0xFF);
+ }
+ } else { // ARGB8888 or ABGR8888
+ if (format == TBM_FORMAT_ARGB8888) {
+ row[x * pixel_size] = (curBlock & 0xFF);
+ row[1 + x * pixel_size] = (curBlock >> 8) & 0xFF;
+ row[2 + x * pixel_size] = (curBlock >> 16) & 0xFF;
+ row[3 + x * pixel_size] = (curBlock >> 24) & 0xFF;
+ } else {
+ row[x * pixel_size] = (curBlock >> 16) & 0xFF;
+ row[1 + x * pixel_size] = (curBlock >> 8) & 0xFF;
+ row[2 + x * pixel_size] = (curBlock & 0xFF);
+ row[3 + x * pixel_size] = (curBlock >> 24) & 0xFF;
+ }
}
}
}
buf_info->info.planes[0].stride,
TBM_FORMAT_XRGB8888);
break;
+ case TBM_FORMAT_ABGR8888:
+ _tbm_surface_internal_dump_file_png(file, bo_handle.ptr,
+ buf_info->info.planes[0].stride >> 2,
+ buf_info->info.height,
+ buf_info->info.planes[0].stride,
+ TBM_FORMAT_ABGR8888);
+ break;
+ case TBM_FORMAT_XBGR8888:
+ _tbm_surface_internal_dump_file_png(file, bo_handle.ptr,
+ buf_info->info.planes[0].stride >> 2,
+ buf_info->info.height,
+ buf_info->info.planes[0].stride,
+ TBM_FORMAT_XBGR8888);
+ break;
case TBM_FORMAT_YVU420:
case TBM_FORMAT_YUV420:
ptr1 = bo_handle.ptr + buf_info->info.planes[0].stride * buf_info->info.height;
{
switch (format) {
case TBM_FORMAT_ARGB8888:
+ case TBM_FORMAT_ABGR8888:
return PIXMAN_a8r8g8b8;
case TBM_FORMAT_XRGB8888:
+ case TBM_FORMAT_XBGR8888:
return PIXMAN_x8r8g8b8;
default:
return 0;
* This function supports only if a buffer has below formats.
* - TBM_FORMAT_ARGB8888
* - TBM_FORMAT_XRGB8888
+ * - TBM_FORMAT_ABGR8888
+ * - TBM_FORMAT_XBGR8888
*/
static tbm_surface_error_e
_tbm_surface_internal_buffer_scale(void *src_ptr, void *dst_ptr,
if (scale_factor > 0.0) {
const int bpp = 4;
- if (info.format != TBM_FORMAT_ARGB8888 && info.format != TBM_FORMAT_XRGB8888) {
+ if ((info.format != TBM_FORMAT_ARGB8888) && (info.format != TBM_FORMAT_XRGB8888) &&
+ (info.format != TBM_FORMAT_ABGR8888) && (info.format != TBM_FORMAT_XBGR8888)) {
TBM_WRN("Dump with scale skip. unsupported format(%s)\n",
_tbm_surface_internal_format_to_str(info.format));
tbm_surface_unmap(surface);
memcpy(&buf_info->info, &info, sizeof(tbm_surface_info_s));
}
- if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888) {
+ if ((info.format == TBM_FORMAT_ARGB8888) || (info.format == TBM_FORMAT_XRGB8888) ||
+ (info.format == TBM_FORMAT_ABGR8888) || (info.format == TBM_FORMAT_XBGR8888)) {
postfix = dump_postfix[0];
format = _tbm_surface_internal_format_to_str(info.format);
} else
switch (info.format) {
case TBM_FORMAT_ARGB8888:
case TBM_FORMAT_XRGB8888:
+ case TBM_FORMAT_ABGR8888:
+ case TBM_FORMAT_XBGR8888:
snprintf(buf_info->name, sizeof(buf_info->name),
"%10.3f_%03d%s_%p_%s-%s.%s",
_tbm_surface_internal_get_time(),
ret = tbm_surface_map(surface, TBM_SURF_OPTION_READ|TBM_SURF_OPTION_WRITE, &info);
TBM_RETURN_VAL_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE, 0);
- if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888)
+ if ((info.format == TBM_FORMAT_ARGB8888) || (info.format == TBM_FORMAT_XRGB8888) ||
+ (info.format == TBM_FORMAT_ABGR8888) || (info.format == TBM_FORMAT_XBGR8888))
postfix = dump_postfix[0];
else
postfix = dump_postfix[1];
info.planes[0].stride,
TBM_FORMAT_XRGB8888);
break;
+ case TBM_FORMAT_ABGR8888:
+ _tbm_surface_internal_dump_file_png(file, info.planes[0].ptr,
+ info.width,
+ info.height,
+ info.planes[0].stride,
+ TBM_FORMAT_ABGR8888);
+ break;
+ case TBM_FORMAT_XBGR8888:
+ _tbm_surface_internal_dump_file_png(file, info.planes[0].ptr,
+ info.width,
+ info.height,
+ info.planes[0].stride,
+ TBM_FORMAT_XBGR8888);
+ break;
case TBM_FORMAT_YVU420:
case TBM_FORMAT_YUV420:
_tbm_surface_internal_dump_file_raw(file, info.planes[0].ptr,
tbm_surface_buffer_data *
tbm_surface_internal_export(tbm_surface_h surface, tbm_error_e *error)
{
- // TODO: implement
- return NULL;
+ tbm_surface_buffer_data *buffer_data = NULL;
+ struct _tbm_bufmgr *bufmgr;
+
+ _tbm_surface_mutex_lock();
+
+ bufmgr = g_surface_bufmgr;
+ TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr != NULL, NULL, error, TBM_ERROR_INVALID_OPERATION);
+
+ // this function supports when the module suppport surface_data.
+ TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(tbm_module_support_surface_data(bufmgr->module), NULL, error, TBM_ERROR_NOT_SUPPORTED);
+
+ TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(_tbm_surface_internal_is_valid(surface), NULL, error, TBM_ERROR_INVALID_PARAMETER);
+
+ // export a surface
+ buffer_data = tbm_surface_data_export(surface->surface_data, error);
+ TBM_SURFACE_RETURN_VAL_ERR_IF_FAIL(buffer_data != NULL, NULL, *error);
+
+ TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) buffer_data(%p)", surface, buffer_data);
+
+ _tbm_set_last_result(TBM_ERROR_NONE);
+ _tbm_surface_mutex_unlock();
+
+ return buffer_data;
}
tbm_surface_h
tbm_surface_internal_import(tbm_surface_info_s *surface_info, tbm_surface_buffer_data *buffer_data, tbm_error_e *error)
{
- // TODO: implement
- return NULL;
+ struct _tbm_surface *surf;
+ struct _tbm_bufmgr *bufmgr;
+
+ _tbm_surface_mutex_lock();
+
+ bufmgr = g_surface_bufmgr;
+ TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr != NULL, NULL, error, TBM_ERROR_INVALID_OPERATION);
+
+ // this function supports when the module suppport surface_data.
+ TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(tbm_module_support_surface_data(bufmgr->module), NULL, error, TBM_ERROR_NOT_SUPPORTED);
+
+ TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(surface_info != NULL, NULL, error, TBM_ERROR_INVALID_PARAMETER);
+ TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(surface_info->width > 0, NULL, error, TBM_ERROR_INVALID_PARAMETER);
+ TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(surface_info->height > 0, NULL, error, TBM_ERROR_INVALID_PARAMETER);
+ TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(buffer_data != NULL, NULL, error, TBM_ERROR_INVALID_PARAMETER);
+
+ // import a surface
+ surf = _tbm_surface_internal_import_surface(bufmgr,
+ (int)surface_info->width,
+ (int)surface_info->height,
+ (int)surface_info->format,
+ buffer_data,
+ error);
+ TBM_SURFACE_RETURN_VAL_ERR_IF_FAIL(surf != NULL, NULL, *error);
+
+ LIST_INITHEAD(&surf->user_data_list);
+ LIST_INITHEAD(&surf->debug_data_list);
+ LIST_INITHEAD(&surf->destroy_funcs);
+
+ LIST_ADD(&surf->item_link, &bufmgr->surf_list);
+
+ TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p)", surf);
+
+ _tbm_set_last_result(TBM_ERROR_NONE);
+ _tbm_surface_mutex_unlock();
+
+ return (tbm_surface_h)surf;
}
/*LCOV_EXCL_STOP*/