subsurface: Add ds_subsurface_from_surface() 67/294267/2
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 27 Apr 2023 04:46:28 +0000 (13:46 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Mon, 19 Jun 2023 00:36:48 +0000 (00:36 +0000)
As the name explains itself, the API is to get a ds_subsurface from a
ds_surface.

Change-Id: Iada285039de4e78c1df171d885128c72cd3cdc1c

include/libds/subsurface.h
src/compositor/compositor_private.h
src/compositor/subsurface.c
src/compositor/surface.c

index 5549f0a..7a86720 100644 (file)
@@ -14,6 +14,8 @@ bool ds_surface_is_subsurface(struct ds_surface *surface);
 struct ds_subsurface *
 ds_subsurface_from_resource(struct wl_resource *resource);
 
+struct ds_subsurface *ds_subsurface_from_surface(struct ds_surface *surface);
+
 #ifdef __cplusplus
 }
 #endif
index 1663014..5a15e11 100644 (file)
@@ -45,9 +45,6 @@ create_subsurface(struct wl_resource *subcomp_resource,
         struct ds_surface *surface, struct ds_surface *parent,
         uint32_t version, uint32_t id);
 
-struct ds_subsurface *
-subsurface_from_ds_surface(struct ds_surface *surface);
-
 struct ds_surface *
 subsurface_get_parent(struct ds_subsurface *subsurface);
 
index b3bc455..3845066 100644 (file)
@@ -127,10 +127,11 @@ subsurface_get_parent(struct ds_subsurface *subsurface)
     return subsurface->parent;
 }
 
-struct ds_subsurface *
-subsurface_from_ds_surface(struct ds_surface *surface)
+WL_EXPORT struct ds_subsurface *
+ds_subsurface_from_surface(struct ds_surface *surface)
 {
-    DS_ASSERT(ds_surface_is_subsurface(surface));
+    if (!ds_surface_is_subsurface(surface))
+        return NULL;
     return (struct ds_subsurface *)surface->role_data;
 }
 
@@ -390,7 +391,7 @@ subsurface_is_synchronized(struct ds_subsurface *subsurface)
     do {
         if (iter->synchronized)
             return true;
-    } while ((iter = subsurface_from_ds_surface(iter->parent)));
+    } while ((iter = ds_subsurface_from_surface(iter->parent)));
 
     return false;
 }
index 7ab9b29..ebf2a6e 100644 (file)
@@ -256,7 +256,7 @@ ds_surface_is_ancestor_of(struct ds_surface *surface,
 
     while (target_surface &&
             ds_surface_is_subsurface(target_surface)) {
-        target_subsurface = subsurface_from_ds_surface(target_surface);
+        target_subsurface = ds_subsurface_from_surface(target_surface);
         if (!target_subsurface)
             break;
 
@@ -276,7 +276,7 @@ ds_surface_get_root_surface(struct ds_surface *surface)
     struct ds_subsurface *subsurface;
 
     while (ds_surface_is_subsurface(surface)) {
-        subsurface = subsurface_from_ds_surface(surface);
+        subsurface = ds_subsurface_from_surface(surface);
         if (!subsurface)
             break;
 
@@ -587,7 +587,7 @@ surface_handle_commit(struct wl_client *client, struct wl_resource *resource)
     ds_dbg("ds_surface(%p) commit", surface);
 
     if (ds_surface_is_subsurface(surface)) {
-        subsurface = subsurface_from_ds_surface(surface);
+        subsurface = ds_subsurface_from_surface(surface);
         subsurface_commit(subsurface);
         return;
     }