e_client: add bind_ref value in E_Client structure 43/154543/2
authorDoyoun Kang <doyoun.kang@samsung.com>
Tue, 10 Oct 2017 11:36:00 +0000 (20:36 +0900)
committerJuyeon Lee <juyeonne.lee@samsung.com>
Tue, 10 Oct 2017 12:40:55 +0000 (12:40 +0000)
We add a bind_ref value to handle a reference count when the ec is bound to remote surface.

Change-Id: I27fae54dd9037b76a0d3e534c0b2e3ff2ecfbfad

src/bin/e_client.h
src/bin/e_comp_wl_rsm.c
src/bin/e_policy.c

index 154e197d76e24d9d2731bebc4df215479e6df7f8..88227b84212872cf274f06ee125fc26ad9c6653a 100644 (file)
@@ -931,6 +931,7 @@ struct E_Client
      {
         Eina_Bool provider : 1;
         Eina_Bool consumer : 1;
+        int       bind_ref;
      } remote_surface;
 
    Eina_Bool is_cursor : 1; // The client is a cursor client
index e7066c541fcceba444bf0cb44b3703f8c7faf74c..b92ab4f3158d403573bfa8a8db50bc83e3f709ec 100644 (file)
@@ -727,6 +727,33 @@ _remote_surface_visible_set(E_Comp_Wl_Remote_Surface *remote_surface, Eina_Bool
    _remote_provider_visible_set(provider, set);
 }
 
+static void
+_remote_surface_bind_client_set(E_Comp_Wl_Remote_Surface *remote_surface, E_Client *ec)
+{
+   if (!remote_surface) return;
+
+   RSMINF("Set bind_ec:%p, bind_ref:%d",
+          NULL, NULL,
+          "SURFACE", remote_surface, ec, ec->remote_surface.bind_ref + 1);
+
+   remote_surface->bind_ec = ec;
+   remote_surface->bind_ec->remote_surface.bind_ref++;
+}
+
+static void
+_remote_surface_bind_client_unset(E_Comp_Wl_Remote_Surface *remote_surface)
+{
+   if (!remote_surface) return;
+
+   RSMINF("Unset bind_ec:%p, bind_ref:%d",
+          NULL, NULL,
+          "SURFACE", remote_surface, remote_surface->bind_ec,
+          remote_surface->bind_ec->remote_surface.bind_ref - 1);
+
+   remote_surface->bind_ec->remote_surface.bind_ref--;
+   remote_surface->bind_ec = NULL;
+}
+
 static void
 _remote_surface_bind_client(E_Comp_Wl_Remote_Surface *remote_surface, E_Client *ec)
 {
@@ -754,7 +781,7 @@ _remote_surface_bind_client(E_Comp_Wl_Remote_Surface *remote_surface, E_Client *
         e_comp_wl_surface_attach(remote_surface->bind_ec, NULL);
 
         eina_hash_del(_rsm->bind_surface_hash, &remote_surface->bind_ec, remote_surface);
-        remote_surface->bind_ec = NULL;
+        _remote_surface_bind_client_unset(remote_surface);
 
         /* try to send latest buffer of the provider to the consumer when unbinding
          * the remote surface to avoid showing old buffer on consumer's window for a while.
@@ -792,13 +819,9 @@ bind_ec_set:
              return;
           }
 
-        RSMINF("Set bind_ec:%p",
-               NULL, NULL,
-               "SURFACE", remote_surface, ec);
-
         /* TODO: enable user geometry? */
         e_policy_allow_user_geometry_set(ec, EINA_TRUE);
-        remote_surface->bind_ec = ec;
+        _remote_surface_bind_client_set(remote_surface, ec);
         eina_hash_add(_rsm->bind_surface_hash, &remote_surface->bind_ec, remote_surface);
 
         /* try to set latest buffer of the provider to bind_ec */
index ec483a048b6f8bf7c7e2237f8a171d77a924a119..8fc9017419a08edd5333bb1499ce7fe653faaa0e 100644 (file)
@@ -983,6 +983,7 @@ _e_policy_cb_hook_pixmap_unusable(void *data EINA_UNUSED, E_Pixmap *cp)
    if (ec->exp_iconify.by_client) return;
    if (ec->exp_iconify.skip_iconify) return;
    if (ec->exp_iconify.skip_by_remote) return;
+   if (ec->remote_surface.bind_ref > 0) return;
 
    e_policy_client_unmap(ec);
 }