From 1578d492620801adc40404340d546adcb9c76645 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Sun, 11 Jun 2017 08:24:07 +0900 Subject: [PATCH] helper: add tdm_helper_get_buffer_full_size() to get the real buffer size Change-Id: Ie27d3b52ab57171b25628e8a85fc509d1e643e21 --- include/tdm_helper.h | 11 +++++++++++ src/tdm_helper.c | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/tdm_helper.h b/include/tdm_helper.h index c80057d..ef0a657 100644 --- a/include/tdm_helper.h +++ b/include/tdm_helper.h @@ -110,6 +110,17 @@ void tdm_helper_clear_buffer(tbm_surface_h buffer); /** + * @brief Get the buffer full size. + * @details + * In some hardware, the buffer width or height is aligned with the fixed size. + * eg. 8, 16, etc. In this case, the real size of buffer could be bigger than + * the buffer size of tbm_surface_info_s. + * @param[in] buffer A TDM buffer + */ +void +tdm_helper_get_buffer_full_size(tbm_surface_h buffer, int *buffer_w, int *buffer_h); + +/** * @brief convert the source buffer to the destination buffer with given rectangles * trannsform * @details diff --git a/src/tdm_helper.c b/src/tdm_helper.c index 4adbcb8..21758f6 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -390,6 +390,28 @@ tdm_helper_clear_buffer(tbm_surface_h buffer) tdm_helper_clear_buffer_pos(buffer, NULL); } +EXTERN void +tdm_helper_get_buffer_full_size(tbm_surface_h buffer, int *buffer_w, int *buffer_h) +{ + tbm_surface_info_s info; + int ret; + + TDM_RETURN_IF_FAIL(buffer != NULL); + + ret = tbm_surface_get_info(buffer, &info); + TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE); + + if (buffer_w) { + if (IS_RGB(info.format)) + *buffer_w = info.planes[0].stride >> 2; + else + *buffer_w = info.planes[0].stride; + } + + if (buffer_h) + *buffer_h = info.planes[0].size / info.planes[0].stride; +} + static pixman_format_code_t _tdm_helper_pixman_format_get(tbm_format format) { -- 2.7.4