From: Seunghun Lee Date: Thu, 13 Jul 2023 08:02:08 +0000 (+0900) Subject: surface: Simplify ds_surface_is_ancestor_of() X-Git-Tag: accepted/tizen/unified/20230720.164642~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be027f76cca6e0041da3da96d7e6b8fdd2c717a8;p=platform%2Fcore%2Fuifw%2Flibds.git surface: Simplify ds_surface_is_ancestor_of() This also moves the surface_is_ancestor_of() to private header. Change-Id: Ie099d68b2bff1b5786d0440809197b0327f8667f --- diff --git a/src/compositor/compositor_private.h b/src/compositor/compositor_private.h index 84b00c4..b474802 100644 --- a/src/compositor/compositor_private.h +++ b/src/compositor/compositor_private.h @@ -43,4 +43,7 @@ void subsurface_commit(struct ds_subsurface *subsurface); void subsurface_parent_commit(struct ds_subsurface *subsurface, bool synchronized); +bool surface_is_ancestor_of(struct ds_surface *surface, + struct ds_surface *target_surface); + #endif diff --git a/src/compositor/subsurface.c b/src/compositor/subsurface.c index 0b2aafc..d9aaa62 100644 --- a/src/compositor/subsurface.c +++ b/src/compositor/subsurface.c @@ -42,7 +42,7 @@ create_subsurface(struct wl_resource *factory_resource, return NULL; } - if (ds_surface_is_ancestor_of(surface, parent)) { + if (surface_is_ancestor_of(surface, parent)) { ds_inf("ds_surface(%p) is an ancestor of given parent(%p)", surface, parent); wl_resource_post_error(factory_resource, diff --git a/src/compositor/surface.c b/src/compositor/surface.c index 5401b5f..5f883cc 100644 --- a/src/compositor/surface.c +++ b/src/compositor/surface.c @@ -248,23 +248,20 @@ create_surface(struct wl_client *client, uint32_t version, uint32_t id) } bool -ds_surface_is_ancestor_of(struct ds_surface *surface, +surface_is_ancestor_of(struct ds_surface *surface, struct ds_surface *target_surface) { - struct ds_subsurface *target_subsurface; - struct ds_surface *parent_surface; + struct ds_subsurface *subsurface; + struct ds_surface *iter = target_surface; - while (target_surface && - ds_surface_is_subsurface(target_surface)) { - target_subsurface = ds_subsurface_from_surface(target_surface); - if (!target_subsurface) + while (iter) { + subsurface = ds_subsurface_from_surface(iter); + if (!subsurface) break; - parent_surface = subsurface_get_parent(target_subsurface); - if (surface == parent_surface) + iter = subsurface_get_parent(subsurface); + if (surface == iter) return true; - - target_surface = parent_surface; } return false; diff --git a/src/surface.h b/src/surface.h index 24e12d8..fbb092a 100644 --- a/src/surface.h +++ b/src/surface.h @@ -9,10 +9,6 @@ bool ds_surface_has_buffer(struct ds_surface *surface); bool -ds_surface_is_ancestor_of(struct ds_surface *surface, - struct ds_surface *target_surface); - -bool ds_surface_is_subsurface(struct ds_surface *surface); #endif