downstream: ivi-layout: maintain a pointer to weston_view in 'struct ivi_layout'
authorJanos Kovacs <jankovac503@gmail.com>
Fri, 22 Aug 2014 20:58:18 +0000 (23:58 +0300)
committerJanos Kovacs <jankovac503@gmail.com>
Wed, 10 Dec 2014 14:28:04 +0000 (16:28 +0200)
Change-Id: Ic61c01615571becc16cf607342f7f5be2b5f302a
Signed-off-by: Janos Kovacs <jankovac503@gmail.com>
ivi-shell/ivi-layout-private.h
ivi-shell/ivi-layout.c

index 4113a93..00ffe9c 100644 (file)
@@ -35,6 +35,7 @@ struct ivi_layout_surface {
 
        struct ivi_layout *layout;
        struct weston_surface *surface;
+       struct weston_view *view;
 
        struct wl_listener surface_destroy_listener;
        struct weston_transform surface_rotation;
index 9383bfc..fe55297 100644 (file)
@@ -291,6 +291,7 @@ westonsurface_destroy_from_ivisurface(struct wl_listener *listener, void *data)
        wl_list_remove(&ivisurf->scaling.link);
 
        ivisurf->surface = NULL;
+       ivisurf->view = NULL;
        ivi_layout_surface_remove(ivisurf);
 }
 
@@ -402,13 +403,9 @@ update_opacity(struct ivi_layout_layer *ivilayer,
 
        if ((ivilayer->event_mask & IVI_NOTIFICATION_OPACITY) ||
            (ivisurf->event_mask  & IVI_NOTIFICATION_OPACITY)) {
-               struct weston_view *tmpview = NULL;
-               wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) {
-                       if (tmpview == NULL) {
-                               continue;
-                       }
-                       tmpview->alpha = layer_alpha * surf_alpha;
-               }
+               if (ivisurf->view == NULL)
+                       return;
+               ivisurf->view->alpha = layer_alpha * surf_alpha;
        }
 }
 
@@ -416,7 +413,7 @@ static void
 update_surface_orientation(struct ivi_layout_layer *ivilayer,
                           struct ivi_layout_surface *ivisurf)
 {
-       struct weston_view *view;
+       struct weston_view *view = ivisurf->view;
        struct weston_matrix  *matrix = &ivisurf->surface_rotation.matrix;
        float width  = 0.0f;
        float height = 0.0f;
@@ -427,15 +424,8 @@ update_surface_orientation(struct ivi_layout_layer *ivilayer,
        float sx = 1.0f;
        float sy = 1.0f;
 
-       wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
-               if (view != NULL) {
-                       break;
-               }
-       }
-
-       if (view == NULL) {
+       if (view == NULL)
                return;
-       }
 
        if ((ivilayer->prop.dest_width == 0) ||
            (ivilayer->prop.dest_height == 0)) {
@@ -489,7 +479,7 @@ update_layer_orientation(struct ivi_layout_layer *ivilayer,
                         struct ivi_layout_surface *ivisurf)
 {
        struct weston_surface *es = ivisurf->surface;
-       struct weston_view    *view;
+       struct weston_view    *view = ivisurf->view;
        struct weston_matrix  *matrix = &ivisurf->layer_rotation.matrix;
        struct weston_output  *output = NULL;
        float width  = 0.0f;
@@ -501,12 +491,6 @@ update_layer_orientation(struct ivi_layout_layer *ivilayer,
        float sx = 1.0f;
        float sy = 1.0f;
 
-       wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
-               if (view != NULL) {
-                       break;
-               }
-       }
-
        if (es == NULL || view == NULL) {
                return;
        }
@@ -564,17 +548,11 @@ update_layer_orientation(struct ivi_layout_layer *ivilayer,
 static void
 update_surface_position(struct ivi_layout_surface *ivisurf)
 {
-       struct weston_view *view;
+       struct weston_view *view = ivisurf->view;
        float tx  = (float)ivisurf->prop.dest_x;
        float ty  = (float)ivisurf->prop.dest_y;
        struct weston_matrix *matrix = &ivisurf->surface_pos.matrix;
 
-       wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
-               if (view != NULL) {
-                       break;
-               }
-       }
-
        if (view == NULL) {
                return;
        }
@@ -594,17 +572,11 @@ static void
 update_layer_position(struct ivi_layout_layer *ivilayer,
                      struct ivi_layout_surface *ivisurf)
 {
-       struct weston_view *view;
+       struct weston_view *view = ivisurf->view;
        struct weston_matrix *matrix = &ivisurf->layer_pos.matrix;
        float tx  = (float)ivilayer->prop.dest_x;
        float ty  = (float)ivilayer->prop.dest_y;
 
-       wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
-               if (view != NULL) {
-                       break;
-               }
-       }
-
        if (view == NULL) {
                return;
        }
@@ -624,7 +596,7 @@ static void
 update_scale(struct ivi_layout_layer *ivilayer,
             struct ivi_layout_surface *ivisurf)
 {
-       struct weston_view *view;
+       struct weston_view *view = ivisurf->view;
        struct weston_matrix *matrix = &ivisurf->scaling.matrix;
        float sx = 0.0f;
        float sy = 0.0f;
@@ -633,12 +605,6 @@ update_scale(struct ivi_layout_layer *ivilayer,
        float lh = 0.0f;
        float sh = 0.0f;
 
-       wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
-               if (view != NULL) {
-                       break;
-               }
-       }
-
        if (view == NULL) {
                return;
        }
@@ -671,7 +637,6 @@ update_prop(struct ivi_layout_layer *ivilayer,
            struct ivi_layout_surface *ivisurf)
 {
        if (ivilayer->event_mask | ivisurf->event_mask) {
-               struct weston_view *tmpview;
                update_opacity(ivilayer, ivisurf);
                update_layer_orientation(ivilayer, ivisurf);
                update_layer_position(ivilayer, ivisurf);
@@ -681,14 +646,8 @@ update_prop(struct ivi_layout_layer *ivilayer,
 
                ivisurf->update_count++;
 
-               wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) {
-                       if (tmpview != NULL) {
-                               break;
-                       }
-               }
-
-               if (tmpview != NULL) {
-                       weston_view_geometry_dirty(tmpview);
+               if (ivisurf->view != NULL) {
+                 weston_view_geometry_dirty(ivisurf->view);
                }
 
                if (ivisurf->surface != NULL) {
@@ -2643,18 +2602,7 @@ ivi_layout_get_weston_surface(struct ivi_layout_surface *surface)
 static struct weston_view *
 ivi_layout_get_weston_view(struct ivi_layout_surface *surface)
 {
-       struct weston_view *tmpview = NULL;
-
-       if(surface == NULL)
-               return NULL;
-
-       wl_list_for_each(tmpview, &surface->surface->views, surface_link)
-       {
-               if (tmpview != NULL) {
-                       break;
-               }
-       }
-       return tmpview;
+    return (surface != NULL) ? surface->view : NULL;
 }
 
 static void
@@ -2709,7 +2657,6 @@ ivi_layout_surface_create(struct weston_surface *wl_surface,
 {
        struct ivi_layout *layout = get_layout_instance();
        struct ivi_layout_surface *ivisurf = NULL;
-       struct weston_view *tmpview = NULL;
 
        if (wl_surface == NULL) {
                weston_log("ivi_layout_surface_create: invalid argument\n");
@@ -2743,8 +2690,8 @@ ivi_layout_surface_create(struct weston_surface *wl_surface,
        wl_resource_add_destroy_listener(wl_surface->resource,
                                         &ivisurf->surface_destroy_listener);
 
-       tmpview = weston_view_create(wl_surface);
-       if (tmpview == NULL) {
+       ivisurf->view = weston_view_create(wl_surface);
+       if (ivisurf->view == NULL) {
                weston_log("fails to allocate memory\n");
        }