e_pixmap: change e_pixmap_buffer_clear 43/132543/5
authorSangjin Lee <lsj119@samsung.com>
Mon, 5 Jun 2017 08:04:04 +0000 (17:04 +0900)
committerSangjin Lee <lsj119@samsung.com>
Sun, 11 Jun 2017 23:53:53 +0000 (08:53 +0900)
For remove just free buffer, add the function parameter.
the only_free param has meaning that only free_buffer on client side shoud be removed.
For this operation, tizen_surface_shm_flusher is added the protocol and version up to 2.
The first usage is quickpanel. For reduse idle memory, quickpaenl has just on active buffer.
so quick-panel service call e_pixmap_buffer_clear() function with only_free value.

Change-Id: I0979552e8dc724bc48603a3c94d2be9eeda1f3f9

src/bin/e_client.c
src/bin/e_pixmap.c
src/bin/e_pixmap.h
src/bin/services/e_service_quickpanel.c
src/bin/tizen-surface-protocol.c
src/bin/tizen-surface-server.h
src/bin/tizen-surface.xml [new file with mode: 0644]

index 55b9e1d7fdc779d2132851736c0dd74460608471..f376ffef23f61cdc9b543ebe0fdbb2c18f47a59d 100644 (file)
@@ -5357,7 +5357,7 @@ e_client_iconify(E_Client *ec)
    _e_client_hook_call(E_CLIENT_HOOK_ICONIFY, ec);
 
    if (e_config->use_buffer_flush)
-     e_pixmap_buffer_clear(ec->pixmap);
+     e_pixmap_buffer_clear(ec->pixmap, EINA_FALSE);
 
    TRACE_DS_END();
 }
index c41cd2d81f257f4927f78b35842f4a5da45805d6..c708052e93092b7e7d1fd8c159480e41206d12e9 100644 (file)
@@ -1002,7 +1002,7 @@ e_pixmap_init(void)
      return EINA_FALSE;
 
    global = wl_global_create(e_comp_wl->wl.disp, &tizen_surface_shm_interface,
-                             1, NULL, _e_pixmap_tzsurf_shm_cb_bind);
+                             2, NULL, _e_pixmap_tzsurf_shm_cb_bind);
    if (!global)
      return EINA_FALSE;
 
@@ -1018,7 +1018,7 @@ e_pixmap_shutdown(void)
  * implementation. the implementation for shared memory is in evas_shm engine.
  */
 E_API void
-e_pixmap_buffer_clear(E_Pixmap *cp)
+e_pixmap_buffer_clear(E_Pixmap *cp, Eina_Bool only_free)
 {
    E_Comp_Wl_Client_Data *cdata;
    struct wl_resource *cb;
@@ -1030,13 +1030,33 @@ e_pixmap_buffer_clear(E_Pixmap *cp)
    if (!e_config->use_buffer_flush)
      return;
 
-   DBG("PIXMAP: Buffer Flush(%s) '%s'(%p)", cp->shm_flusher ? "SHM" : "NATIVE",
-       cp->client->icccm.name?:"", cp->client);
+   DBG("PIXMAP: Buffer Flush(%s) '%s'(%p) only_free:%d", cp->shm_flusher ? "SHM" : "NATIVE",
+       cp->client->icccm.name?:"", cp->client, only_free);
 
    if (cp->shm_flusher)
-     tizen_surface_shm_flusher_send_flush(cp->shm_flusher);
+     {
+        if (only_free == EINA_TRUE)
+          {
+            if (TIZEN_SURFACE_SHM_FLUSHER_FREE_FLUSH_SINCE_VERSION <= wl_resource_get_version(cp->shm_flusher))
+              {
+                 tizen_surface_shm_flusher_send_free_flush(cp->shm_flusher);
+              }
+            else
+              {
+                 /*free_flush was supported from version 2*/
+                 return;
+              }
+           }
+         else
+           {
+              tizen_surface_shm_flusher_send_flush(cp->shm_flusher);
+           }
+     }
    else if (cp->buffer)
      {
+        if (only_free)
+          return;
+
         switch (cp->buffer->type)
           {
            case E_COMP_WL_BUFFER_TYPE_TBM:
@@ -1058,21 +1078,26 @@ e_pixmap_buffer_clear(E_Pixmap *cp)
               break;
           }
      }
+   else
+     return;
 
-   /* release the helded buffer by e_client */
-   if (cp->client->comp_data)
-     e_comp_wl_buffer_reference(&cp->client->comp_data->buffer_ref, NULL);
+   if (only_free == EINA_FALSE)
+     {
+        /* release the helded buffer by e_client */
+        if (cp->client->comp_data)
+          e_comp_wl_buffer_reference(&cp->client->comp_data->buffer_ref, NULL);
 
-   /* composite object clear */
-   e_comp_object_clear(cp->client->frame);
+        /* composite object clear */
+        e_comp_object_clear(cp->client->frame);
 
-   /* pending frame event callback*/
-   if (!cp->client->comp_data) return;
-   cdata = (E_Comp_Wl_Client_Data *)cp->client->comp_data;
-   EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
-     {
-        wl_callback_send_done(cb, ecore_time_unix_get() * 1000);
-        wl_resource_destroy(cb);
+        /* pending frame event callback*/
+        if (!cp->client->comp_data) return;
+        cdata = (E_Comp_Wl_Client_Data *)cp->client->comp_data;
+        EINA_LIST_FOREACH_SAFE(cdata->frames, l, ll, cb)
+          {
+             wl_callback_send_done(cb, ecore_time_unix_get() * 1000);
+             wl_resource_destroy(cb);
+          }
      }
 
 }
index 65d88be3c521bf3227776fe8a0dcc20a140cfde0..94c619d63da3398fec9961510233982564f8683b 100644 (file)
@@ -82,7 +82,7 @@ E_API void e_pixmap_hook_del(E_Pixmap_Hook *ph);
 
 E_API Eina_Bool e_pixmap_init(void);
 E_API void e_pixmap_shutdown(void);
-E_API void e_pixmap_buffer_clear(E_Pixmap *cp);
+E_API void e_pixmap_buffer_clear(E_Pixmap *cp, Eina_Bool only_free);
 
 static inline Eina_Bool
 e_pixmap_is_x(const E_Pixmap *cp)
index 665fb4c940c6841eb36c06133ae1e24f467f2490..9a42cd62824c40d5b73d4fcce505a436e493fd52 100644 (file)
@@ -992,6 +992,10 @@ _quickpanel_cb_buffer_change(void *data, int type, void *event)
    /* make frame event */
    e_pixmap_image_clear(ec->pixmap, EINA_TRUE);
 
+   /* To use single buffer*/
+   if (EINA_FALSE == e_qp_visible_get())
+     e_pixmap_buffer_clear(ec->pixmap, EINA_TRUE);
+
 end:
    return ECORE_CALLBACK_PASS_ON;
 }
@@ -1010,6 +1014,8 @@ _quickpanel_client_evas_cb_hide(void *data, Evas *evas, Evas_Object *obj, void *
 
    if (qp->need_scroll_update)
      _e_qp_client_scrollable_update();
+
+   e_pixmap_buffer_clear(qp->ec->pixmap, EINA_TRUE);
 }
 
 static void
index 8420280cf6149742eb4ee38c4500bb9cc9155fec..bd5e8a6a30d5ac1da24ab9bb515bdf5833cfd307 100644 (file)
@@ -15,7 +15,7 @@ static const struct wl_message tizen_surface_shm_requests[] = {
 };
 
 WL_EXPORT const struct wl_interface tizen_surface_shm_interface = {
-       "tizen_surface_shm", 1,
+       "tizen_surface_shm", 2,
        1, tizen_surface_shm_requests,
        0, NULL,
 };
@@ -26,11 +26,12 @@ static const struct wl_message tizen_surface_shm_flusher_requests[] = {
 
 static const struct wl_message tizen_surface_shm_flusher_events[] = {
        { "flush", "", types + 0 },
+       { "free_flush", "2", types + 0 },
 };
 
 WL_EXPORT const struct wl_interface tizen_surface_shm_flusher_interface = {
-       "tizen_surface_shm_flusher", 1,
+       "tizen_surface_shm_flusher", 2,
        1, tizen_surface_shm_flusher_requests,
-       1, tizen_surface_shm_flusher_events,
+       2, tizen_surface_shm_flusher_events,
 };
 
index de98ffbd5e27ede0dcadc16bc390c058b4820b51..14d7bca874d4319627edb5cf8876ecd28cee70eb 100644 (file)
@@ -7,13 +7,14 @@ extern "C" {
 
 #include <stdint.h>
 #include <stddef.h>
-#include "wayland-util.h"
+#include "wayland-server.h"
 
 struct wl_client;
 struct wl_resource;
 
 struct tizen_surface_shm;
 struct tizen_surface_shm_flusher;
+struct wl_surface;
 
 extern const struct wl_interface tizen_surface_shm_interface;
 extern const struct wl_interface tizen_surface_shm_flusher_interface;
@@ -30,6 +31,7 @@ struct tizen_surface_shm_interface {
                            struct wl_resource *surface);
 };
 
+
 struct tizen_surface_shm_flusher_interface {
        /**
         * destroy - (none)
@@ -39,6 +41,10 @@ struct tizen_surface_shm_flusher_interface {
 };
 
 #define TIZEN_SURFACE_SHM_FLUSHER_FLUSH        0
+#define TIZEN_SURFACE_SHM_FLUSHER_FREE_FLUSH   1
+
+#define TIZEN_SURFACE_SHM_FLUSHER_FLUSH_SINCE_VERSION  1
+#define TIZEN_SURFACE_SHM_FLUSHER_FREE_FLUSH_SINCE_VERSION     2
 
 static inline void
 tizen_surface_shm_flusher_send_flush(struct wl_resource *resource_)
@@ -46,6 +52,12 @@ tizen_surface_shm_flusher_send_flush(struct wl_resource *resource_)
        wl_resource_post_event(resource_, TIZEN_SURFACE_SHM_FLUSHER_FLUSH);
 }
 
+static inline void
+tizen_surface_shm_flusher_send_free_flush(struct wl_resource *resource_)
+{
+       wl_resource_post_event(resource_, TIZEN_SURFACE_SHM_FLUSHER_FREE_FLUSH);
+}
+
 #ifdef  __cplusplus
 }
 #endif
diff --git a/src/bin/tizen-surface.xml b/src/bin/tizen-surface.xml
new file mode 100644 (file)
index 0000000..ad516c0
--- /dev/null
@@ -0,0 +1,16 @@
+<protocol name="tizen_surface">
+  <interface name="tizen_surface_shm" version="2">
+    <request name="get_flusher">
+      <arg name="id" type="new_id" interface="tizen_surface_shm_flusher" summary=""/>
+      <arg name="surface" type="object" interface="wl_surface" summary="surface object"/>
+    </request>
+  </interface>
+
+  <interface name="tizen_surface_shm_flusher" version="2">
+    <request name="destroy" type="destructor" />
+    <event name="flush">
+    </event>
+    <event name="free_flush" since="2">
+    </event>
+  </interface>
+</protocol>