pui: store a last updated buffer and return 20/220720/1
authorjeon <jhyuni.kang@samsung.com>
Wed, 23 Oct 2019 12:11:04 +0000 (21:11 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Fri, 20 Dec 2019 09:59:04 +0000 (18:59 +0900)
Change-Id: I67ff595beffe5edebb87bc9a0447181040923185

src/PUI.c
src/PUI_internal.h

index e75b09a..b8fbc13 100644 (file)
--- a/src/PUI.c
+++ b/src/PUI.c
@@ -156,25 +156,19 @@ static const struct wl_buffer_listener buffer_listener = {
 pui_ani_control_buffer *
 pui_display_get_last_buffer(pui_h handle)
 {
-       tbm_surface_error_e ret;
-       tbm_surface_h surface;
-       pui_ani_control_buffer *buffer = NULL;
-
        if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
        {
                PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
                return NULL;
        }
 
-       if (handle->current_sinfo.size <= 0)
+       if (handle->last_buffer.size <= 0)
        {
-               pui_err("Failed to get last buffer which is not set\n");
-               return buffer;
+               pui_err("Failed to get last buffer\n");
+               return NULL;
        }
 
-       buffer = (pui_ani_control_buffer *)&(handle->current_sinfo.planes[0].ptr);
-
-       return buffer;
+       return &handle->last_buffer;
 }
 
 
@@ -315,6 +309,9 @@ pui_display_update(pui_h handle)
 
        handle->is_buffer_set = 0;
 
+       if (handle->last_buffer.size > 0)
+               memcpy(handle->last_buffer.ptr, handle->current_sinfo.planes[0].ptr, handle->last_buffer.size);
+
        return PUI_ERROR_NONE;
 }
 
@@ -394,6 +391,8 @@ pui_create(Ecore_Wl2_Window *win)
        pui_h handle = NULL;
        Ecore_Wl2_Display *ewd = ecore_wl2_window_display_get(win);
        struct wayland_tbm_client *wl_tbm_client = NULL;
+       int w = 0, h = 0;
+       pui_bool res;
 
        if (!win || !ewd)
        {
@@ -429,9 +428,22 @@ pui_create(Ecore_Wl2_Window *win)
        handle->manual_render = 0;
        handle->backend_module_data = pui_module->backend_module_data;
 
+       res = pui_display_geometry_get(handle, &w, &h);
+       if (!res)
+       {
+               /* NOTE: This is a default value for tbm_queue.
+                *       This value is set before this patch.
+                */
+               w = h = 100;
+       }
+
+       handle->last_buffer.ptr = (unsigned char *)calloc(w * h * 4, sizeof(unsigned char));
+       if (handle->last_buffer.ptr)
+               handle->last_buffer.size = sizeof(unsigned char) * w * h * 4;
+
        handle->tbm_queue = wayland_tbm_client_create_surface_queue(handle->wl_tbm_client,
                                                                ecore_wl2_window_surface_get(handle->win),
-                                                               3, 100, 100, TBM_FORMAT_ABGR8888);
+                                                               3, w, h, TBM_FORMAT_ABGR8888);
 
        if (!handle->tbm_queue)
        {
@@ -475,6 +487,13 @@ pui_destroy(pui_h handle)
                handle->wl_tbm_client = NULL;
        }
 
+       if (handle->last_buffer.ptr)
+       {
+               free(handle->last_buffer.ptr);
+               handle->last_buffer.ptr = NULL;
+               handle->last_buffer.size = 0;
+       }
+
        PUI_MAGIC_SET(handle, PUI_MAGIC_NONE);
        free(handle);
 }
index cef423b..37aef75 100644 (file)
@@ -101,6 +101,7 @@ struct _pui
        pui_ani_h current_ani_h;
        tbm_surface_info_s current_sinfo;
        tbm_surface_h current_surface;
+       pui_ani_control_buffer last_buffer;
        int is_buffer_set;
        pui_bool manual_render;