helper: add tdm_helper_get_buffer_full_size() to get the real buffer size 24/133624/1
authorBoram Park <boram1288.park@samsung.com>
Sat, 10 Jun 2017 23:24:07 +0000 (08:24 +0900)
committerBoram Park <boram1288.park@samsung.com>
Sat, 10 Jun 2017 23:24:07 +0000 (08:24 +0900)
Change-Id: Ie27d3b52ab57171b25628e8a85fc509d1e643e21

include/tdm_helper.h
src/tdm_helper.c

index c80057d..ef0a657 100644 (file)
@@ -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
index 4adbcb8..21758f6 100644 (file)
@@ -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)
 {