subsurface: Add E_Subsurface data type 73/261073/1
authorSeunghun Lee <shiin.lee@samsung.com>
Tue, 29 Jun 2021 02:41:10 +0000 (11:41 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Fri, 9 Jul 2021 08:48:07 +0000 (17:48 +0900)
E_Subsurface is a data type wrapping E_Comp_Wl_Subsurf_Data, which can
be accessed from a sub-surface implementation.
This is for adding new field for sub-surface restricting of direct access
to the data.

Change-Id: I1e5b2a8ed840f390f7c92817b36990df1ef9258c

src/bin/e_comp_wl_subsurface.c

index f7cdb3ca9dede5a54c4b6b2dd4180cd4a01be17a..b6db20c64119c913ca72d857df65bb4be23917d1 100644 (file)
@@ -2,6 +2,17 @@
 
 #include <tizen-extension-server-protocol.h>
 
+typedef struct _E_Subsurface     E_Subsurface;
+
+struct _E_Subsurface
+{
+   /* NOTE
+    * DO NOT move 'base' from first field.
+    * The address of it is assigned to ec->comp_data->sub.data and be used
+    * to access not only E_Comp_Wl_Subsurf_Data, but also E_Subsurface. */
+   E_Comp_Wl_Subsurf_Data base;
+};
+
 static struct wl_global *global = NULL;
 static Eina_List *hooks = NULL;
 static Eina_List *handlers = NULL;
@@ -998,6 +1009,7 @@ e_comp_wl_subsurface_create(E_Client *ec, E_Client *epc, uint32_t id, struct wl_
 {
    struct wl_client *client;
    struct wl_resource *res;
+   E_Subsurface *sub;
    E_Comp_Wl_Subsurf_Data *sdata;
    E_Client *offscreen_parent = NULL;
 
@@ -1056,10 +1068,10 @@ e_comp_wl_subsurface_create(E_Client *ec, E_Client *epc, uint32_t id, struct wl_
     * to not post error to wl_client. */
    e_comp_wl_surface_role_set(ec, e_comp_wl_subsurface_role_name, NULL, 0);
 
-   /* try to allocate subsurface data */
-   if (!(sdata = E_NEW(E_Comp_Wl_Subsurf_Data, 1)))
+   sub = E_NEW(E_Subsurface, 1);
+   if (!sub)
      {
-        ERR("Could not allocate space for subsurface data");
+        ERR("Could not allocate space for E_Subsurface");
         wl_resource_destroy(res);
         return EINA_FALSE;
      }
@@ -1069,6 +1081,7 @@ e_comp_wl_subsurface_create(E_Client *ec, E_Client *epc, uint32_t id, struct wl_
                                   _e_comp_wl_subsurface_destroy);
    e_object_ref(E_OBJECT(ec));
 
+   sdata = &sub->base;
    e_comp_wl_surface_state_init(&sdata->cached, ec->w, ec->h);
 
    /* set subsurface data properties */