X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftbm_surface.c;h=0766cf5a0623a6ebf0d7d9e6d50cd6776ac13c41;hb=7aca14d80aeab3cd919dee892f7acc4394287394;hp=fb9c710ec374b327ad87edf688aef61118098ec6;hpb=ced0ea3fe85091351cd6b67325698c605f3db4d2;p=platform%2Fcore%2Fuifw%2Flibtbm.git diff --git a/src/tbm_surface.c b/src/tbm_surface.c old mode 100755 new mode 100644 index fb9c710..0766cf5 --- a/src/tbm_surface.c +++ b/src/tbm_surface.c @@ -30,185 +30,195 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ #include "config.h" + #include "tbm_bufmgr.h" #include "tbm_bufmgr_int.h" #include "tbm_surface_internal.h" -static int -_tbm_surface_get_info (struct _tbm_surface *surf, int opt, tbm_surface_info_s *info, int map) -{ - tbm_bo_handle bo_handles[4]; - int i; - - info->width = surf->info.width; - info->height = surf->info.height; - info->format = surf->info.format; - info->bpp = surf->info.bpp; - info->size = surf->info.size; - info->num_planes = surf->info.num_planes; - - if (surf->num_bos == 1) - { - if (map == 1) - { - bo_handles[0] = tbm_bo_map (surf->bos[0], TBM_DEVICE_CPU, opt); - if (bo_handles[0].ptr == NULL) - return 0; - } - else - { - bo_handles[0] = tbm_bo_get_handle (surf->bos[0], TBM_DEVICE_CPU); - if (bo_handles[0].ptr == NULL) - return 0; - } - - for (i = 0; i < surf->info.num_planes; i++) - { - info->planes[i].size = surf->info.planes[i].size; - info->planes[i].offset = surf->info.planes[i].offset; - info->planes[i].stride = surf->info.planes[i].stride; - info->planes[i].ptr = bo_handles[0].ptr + surf->info.planes[i].offset; - } - } - else - { - /* TODO: calculate the virtaul address when num_bos is over 1 */ - } - - return 1; -} - int -tbm_surface_query_formats (uint32_t **formats, uint32_t *num) +tbm_surface_query_formats(uint32_t **formats, uint32_t *num) { - if (!tbm_surface_internal_query_supported_formats (formats, num)) - return TBM_SURFACE_ERROR_INVALID_OPERATION; + TBM_TRACE_SURFACE("\n"); + + if (!tbm_surface_internal_query_supported_formats(formats, num)) + return tbm_get_last_error(); - return TBM_SURFACE_ERROR_NONE; + return TBM_SURFACE_ERROR_NONE; } tbm_surface_h -tbm_surface_create (int width, int height, tbm_format format) +tbm_surface_create(int width, int height, tbm_format format) { - if (!(width > 0) || !(height > 0)) - { + TBM_TRACE_SURFACE("width(%d) height(%d)\n", width, height); + + _tbm_set_last_result(TBM_ERROR_NONE); + + if (!(width > 0) || !(height > 0)) { #ifdef HAVE_CAPI_0_1_1 - set_last_result (TBM_SURFACE_ERROR_INVALID_PARAMETER); + set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); #endif - return NULL; - } + _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER); + return NULL; + } - struct _tbm_surface *surf = NULL; + struct _tbm_surface *surf = NULL; - surf = tbm_surface_internal_create_with_flags (width, height, format, TBM_BO_DEFAULT); - if (!surf) - { + surf = tbm_surface_internal_create_with_flags(width, height, format, + TBM_BO_DEFAULT); + if (!surf) { #ifdef HAVE_CAPI_0_1_1 - set_last_result (TBM_SURFACE_ERROR_INVALID_OPERATION); + set_last_result(TBM_SURFACE_ERROR_INVALID_OPERATION); #endif - return NULL; - } + return NULL; + } #ifdef HAVE_CAPI_0_1_1 - set_last_result (TBM_SURFACE_ERROR_NONE); + set_last_result(TBM_SURFACE_ERROR_NONE); #endif - return surf; -} + return surf; +} int -tbm_surface_destroy (tbm_surface_h surface) +tbm_surface_destroy(tbm_surface_h surface) { - if (!surface) - return TBM_SURFACE_ERROR_INVALID_PARAMETER; + TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface); + + TBM_RETURN_VAL_IF_FAIL(surface, TBM_SURFACE_ERROR_INVALID_PARAMETER); - tbm_surface_internal_destroy (surface); + tbm_surface_internal_destroy(surface); - return TBM_SURFACE_ERROR_NONE; + return tbm_get_last_error(); } int -tbm_surface_map (tbm_surface_h surface, int opt, tbm_surface_info_s *info) +tbm_surface_map(tbm_surface_h surface, int opt, tbm_surface_info_s *info) { - TBM_RETURN_VAL_IF_FAIL (surface != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER); - TBM_RETURN_VAL_IF_FAIL (info != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER); + TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface); - struct _tbm_surface *surf = (struct _tbm_surface *)surface; - int ret = 0; + TBM_RETURN_VAL_IF_FAIL(surface, TBM_SURFACE_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_IF_FAIL(info != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER); - ret = _tbm_surface_get_info (surf, opt, info, 1); - if (ret == 0) - return TBM_SURFACE_ERROR_INVALID_OPERATION; + int ret = 0; - return TBM_SURFACE_ERROR_NONE; + ret = tbm_surface_internal_get_info(surface, opt, info, 1); + if (ret == 0) + return tbm_get_last_error(); + + return TBM_SURFACE_ERROR_NONE; } int -tbm_surface_unmap (tbm_surface_h surface) +tbm_surface_unmap(tbm_surface_h surface) { - TBM_RETURN_VAL_IF_FAIL (surface != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER); + TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface); - struct _tbm_surface *surf = (struct _tbm_surface *)surface; - int i; + TBM_RETURN_VAL_IF_FAIL(surface, TBM_SURFACE_ERROR_INVALID_PARAMETER); - for (i = 0; i < surf->num_bos; i++) - tbm_bo_unmap (surf->bos[i]); + tbm_surface_internal_unmap(surface); - return TBM_SURFACE_ERROR_NONE; + return tbm_get_last_error(); } int -tbm_surface_get_info (tbm_surface_h surface, tbm_surface_info_s *info) +tbm_surface_get_info(tbm_surface_h surface, tbm_surface_info_s *info) { - TBM_RETURN_VAL_IF_FAIL (surface != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER); - TBM_RETURN_VAL_IF_FAIL (info != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER); + TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface); + + TBM_RETURN_VAL_IF_FAIL(surface, TBM_SURFACE_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_IF_FAIL(info != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER); - struct _tbm_surface *surf = (struct _tbm_surface *)surface; - int ret = 0; + int ret = 0; - ret = _tbm_surface_get_info (surf, 0, info, 0); - if (ret == 0) - return TBM_SURFACE_ERROR_INVALID_OPERATION; + ret = tbm_surface_internal_get_info(surface, 0, info, 0); + if (ret == 0) + return tbm_get_last_error(); - return TBM_SURFACE_ERROR_NONE; + return TBM_SURFACE_ERROR_NONE; } int -tbm_surface_get_width (tbm_surface_h surface) +tbm_surface_get_width(tbm_surface_h surface) { - TBM_RETURN_VAL_IF_FAIL (surface != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER); + TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface); + + int width = 0; - struct _tbm_surface *surf = (struct _tbm_surface *)surface; + _tbm_set_last_result(TBM_ERROR_NONE); + + if (!surface) { +#ifdef HAVE_CAPI_0_1_1 + set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); +#endif + _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER); + return TBM_SURFACE_ERROR_INVALID_PARAMETER; + } + + width = tbm_surface_internal_get_width(surface); + if (tbm_get_last_error() != TBM_ERROR_NONE) { +#ifdef HAVE_CAPI_0_1_1 + set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); +#endif + return TBM_SURFACE_ERROR_INVALID_PARAMETER; + } - return surf->info.width; +#ifdef HAVE_CAPI_0_1_1 + set_last_result(TBM_SURFACE_ERROR_NONE); +#endif + + return width; } int -tbm_surface_get_height (tbm_surface_h surface) +tbm_surface_get_height(tbm_surface_h surface) { - TBM_RETURN_VAL_IF_FAIL (surface != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER); + TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface); + + int height = 0; + + _tbm_set_last_result(TBM_ERROR_NONE); + + if (!surface) { +#ifdef HAVE_CAPI_0_1_1 + set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); +#endif + _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER); + return TBM_SURFACE_ERROR_INVALID_PARAMETER; + } + + height = tbm_surface_internal_get_height(surface); + if (tbm_get_last_error() != TBM_ERROR_NONE) { +#ifdef HAVE_CAPI_0_1_1 + set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); +#endif + return TBM_SURFACE_ERROR_INVALID_PARAMETER; + } - struct _tbm_surface *surf = (struct _tbm_surface *)surface; +#ifdef HAVE_CAPI_0_1_1 + set_last_result(TBM_SURFACE_ERROR_NONE); +#endif - return surf->info.height; + return height; } tbm_format -tbm_surface_get_format (tbm_surface_h surface) +tbm_surface_get_format(tbm_surface_h surface) { - if (!surface) - { + TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface); + + _tbm_set_last_result(TBM_ERROR_NONE); + + if (!surface) { #ifdef HAVE_CAPI_0_1_1 - set_last_result (TBM_SURFACE_ERROR_INVALID_PARAMETER); + set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); #endif - return 0; - } - - struct _tbm_surface *surf = (struct _tbm_surface *)surface; + _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER); + return 0; + } #ifdef HAVE_CAPI_0_1_1 - set_last_result (TBM_SURFACE_ERROR_NONE); + set_last_result(TBM_SURFACE_ERROR_NONE); #endif - return surf->info.format; -} + return tbm_surface_internal_get_format(surface); +}