viewport: Replace E_Client variables with E_Subsurface's API 21/304821/2
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 18 Jan 2024 07:04:44 +0000 (16:04 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 24 Jan 2024 04:21:55 +0000 (04:21 +0000)
Instead of directly modifying E_Client's variables, it utilizes
E_Subsurface APIs.

Change-Id: Id291a5109f8da225c79e7f8603d7a798b202d0af

src/bin/e_comp_wl_viewport.c
src/bin/e_compositor.c
src/bin/e_compositor.h

index 2eff0c0..2adf9ec 100644 (file)
@@ -1342,13 +1342,11 @@ static Eina_Bool
 _e_comp_wl_viewport_apply_destination(E_Viewport *viewport, Eina_Rectangle *rrect)
 {
    E_Client *ec;
-   E_Comp_Wl_Buffer_Viewport *vp;
+   E_Subsurface *subsurface;
    Eina_Rectangle dst = {0,}, prect;
    Eina_Bool changed = EINA_FALSE;
-   int sx = 0, sy = 0;
 
    ec = viewport->ec;
-   vp = &ec->comp_data->scaler.buffer_viewport;
    if (!viewport->epc)
      {
         E_Zone *zone = e_comp_zone_xy_get(ec->x, ec->y);
@@ -1408,16 +1406,10 @@ _e_comp_wl_viewport_apply_destination(E_Viewport *viewport, Eina_Rectangle *rrec
    _e_comp_wl_viewport_crop_by_parent(viewport, &prect, &dst);
 
    /* The values of below x, y, w, h are specified in the transform 0 and in the parent */
-   if (ec->comp_data->sub.data)
+   subsurface = e_subsurface_from_surface(viewport->surface);
+   if (subsurface)
      {
-        e_comp_wl_subsurface_position_get(ec, &sx, &sy);
-        if ((sx != dst.x) || (sy != dst.y))
-          {
-             ec->comp_data->sub.data->position.x = dst.x;
-             ec->comp_data->sub.data->position.y = dst.y;
-             ec->comp_data->sub.data->position.set = EINA_TRUE;
-             vp->changed = changed = EINA_TRUE;
-          }
+        changed = e_subsurface_position_set(subsurface, dst.x, dst.y);
      }
    else
      {
index 09cccf9..e9a6f38 100644 (file)
@@ -91,6 +91,7 @@ static void _ds_surface_buffer_transform_set(struct ds_surface *ds_surface, enum
 static void _ds_surface_viewport_source_box_set(struct ds_surface *ds_surface, Eina_Rectangle *box);
 static void _ds_surface_viewport_destination_set(struct ds_surface *ds_surface, int32_t width, int32_t height);
 static void _ds_surface_viewport_unset(struct ds_surface *ds_surface);
+static void _ds_subsurface_position_set(struct ds_subsurface *ds_subsurface, int x, int y);
 
 static const char *e_comp_wl_subsurface_role_name = "ds_subsurface";
 static E_Compositor *_compositor;
@@ -405,6 +406,30 @@ e_surface_viewport_changed_get(E_Surface *surface)
    return surface->base.scaler.buffer_viewport.changed;
 }
 
+EINTERN E_Subsurface *
+e_subsurface_from_surface(E_Surface *surface)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(surface, NULL);
+   return _e_subsurface_from_surface(surface);
+}
+
+EINTERN Eina_Bool
+e_subsurface_position_set(E_Subsurface *subsurface, int x, int y)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(subsurface, EINA_FALSE);
+
+   if ((subsurface->base.position.x == x) && (subsurface->base.position.y == y))
+    return EINA_FALSE;
+
+   subsurface->base.position.x = x;
+   subsurface->base.position.y = y;
+   subsurface->base.position.set = EINA_TRUE;
+
+   _ds_subsurface_position_set(subsurface->ds_subsurface, x, y);
+
+   return EINA_TRUE;
+}
+
 static void
 _e_compositor_cb_display_destroy(struct wl_listener *listener EINA_UNUSED, void *data EINA_UNUSED)
 {
@@ -1521,3 +1546,13 @@ _ds_surface_viewport_unset(struct ds_surface *ds_surface)
    ds_surface->current.viewport.has_src = false;
    ds_surface->current.viewport.has_dst = false;
 }
+
+static void
+_ds_subsurface_position_set(struct ds_subsurface *ds_subsurface, int x, int y)
+{
+   ds_subsurface->pending.x = x;
+   ds_subsurface->pending.y = y;
+
+   ds_subsurface->current.x = x;
+   ds_subsurface->current.y = y;
+}
index 21dc398..f08dde8 100644 (file)
@@ -2,6 +2,7 @@
 #define E_COMPOSITOR_H
 
 typedef struct _E_Surface E_Surface;
+typedef struct _E_Subsurface E_Subsurface;
 
 EINTERN Eina_Bool e_compositor_init(struct wl_display *display);
 EINTERN E_Client *e_compositor_util_client_from_surface_resource(struct wl_resource *surface_resource);
@@ -19,4 +20,7 @@ EINTERN Eina_Bool e_surface_viewport_source_box_set(E_Surface *surface, Eina_Rec
 EINTERN Eina_Bool e_surface_viewport_destination_set(E_Surface *surface, int32_t width, int32_t height);
 EINTERN Eina_Bool e_surface_viewport_changed_get(E_Surface *surface);
 
+EINTERN E_Subsurface *e_subsurface_from_surface(E_Surface *surface);
+EINTERN Eina_Bool e_subsurface_position_set(E_Subsurface *subsurface, int x, int y);
+
 #endif