ivi-shell: introduce get_weston_view

The internal API "get_weston_view" is introduced, which returns the
weston_view of the given ivi_layout_surface. The API returns a NULL
pointer, if the ivi_layout_surface does not have any weston_view.

The weston_view is required in many places of ivi-shell implementation.
Therefore, this API will reduce lines of code. Furthermore, it will
increase the maintainability of the ivi-shell implementation.

Old way of getting the weston_view was flawed, because the views list of
the weston_surface is read without controlling the existence of the
weston_surface.  New implementation explicitly throws an error if the
weston_surface does not exist.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Tested-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
[Pekka: Line-wrapped the commit message.]
dev
Ucan, Emre (ADITG/SW1) 9 years ago committed by Pekka Paalanen
parent 4a18364595
commit 64635ee699
  1. 75
      ivi-shell/ivi-layout.c

@ -150,6 +150,22 @@ get_layer(struct wl_list *layer_list, uint32_t id_layer)
return NULL; return NULL;
} }
static struct weston_view *
get_weston_view(struct ivi_layout_surface *ivisurf)
{
struct weston_view *view = NULL;
assert(ivisurf->surface != NULL);
/* One view per surface */
if(wl_list_empty(&ivisurf->surface->views))
view = NULL;
else
view = wl_container_of(ivisurf->surface->views.next, view, surface_link);
return view;
}
static void static void
remove_configured_listener(struct ivi_layout_surface *ivisurf) remove_configured_listener(struct ivi_layout_surface *ivisurf)
{ {
@ -302,18 +318,15 @@ static void
update_opacity(struct ivi_layout_layer *ivilayer, update_opacity(struct ivi_layout_layer *ivilayer,
struct ivi_layout_surface *ivisurf) struct ivi_layout_surface *ivisurf)
{ {
struct weston_view *tmpview = NULL;
double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity); double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity);
double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity); double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity);
if ((ivilayer->event_mask & IVI_NOTIFICATION_OPACITY) || if ((ivilayer->event_mask & IVI_NOTIFICATION_OPACITY) ||
(ivisurf->event_mask & IVI_NOTIFICATION_OPACITY)) { (ivisurf->event_mask & IVI_NOTIFICATION_OPACITY)) {
struct weston_view *tmpview = NULL; tmpview = get_weston_view(ivisurf);
wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) { assert(tmpview != NULL);
if (tmpview == NULL) { tmpview->alpha = layer_alpha * surf_alpha;
continue;
}
tmpview->alpha = layer_alpha * surf_alpha;
}
} }
} }
@ -590,11 +603,8 @@ update_prop(struct ivi_layout_layer *ivilayer,
update_opacity(ivilayer, ivisurf); update_opacity(ivilayer, ivisurf);
wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) { tmpview = get_weston_view(ivisurf);
if (tmpview != NULL) { assert(tmpview != NULL);
break;
}
}
if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) { if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) {
weston_log("ivi-shell: source rectangle is not yet set by ivi_layout_surface_set_source_rectangle\n"); weston_log("ivi-shell: source rectangle is not yet set by ivi_layout_surface_set_source_rectangle\n");
@ -613,24 +623,18 @@ update_prop(struct ivi_layout_layer *ivilayer,
calc_surface_to_global_matrix_and_mask_to_weston_surface( calc_surface_to_global_matrix_and_mask_to_weston_surface(
ivilayer, ivisurf, &ivisurf->transform.matrix, &r); ivilayer, ivisurf, &ivisurf->transform.matrix, &r);
if (tmpview != NULL) { weston_view_set_mask(tmpview, r.x, r.y, r.width, r.height);
weston_view_set_mask(tmpview, r.x, r.y, r.width, r.height); wl_list_insert(&tmpview->geometry.transformation_list,
wl_list_insert(&tmpview->geometry.transformation_list, &ivisurf->transform.link);
&ivisurf->transform.link);
weston_view_set_transform_parent(tmpview, NULL); weston_view_set_transform_parent(tmpview, NULL);
}
} }
ivisurf->update_count++; ivisurf->update_count++;
if (tmpview != NULL) { weston_view_geometry_dirty(tmpview);
weston_view_geometry_dirty(tmpview);
}
if (ivisurf->surface != NULL) { weston_surface_damage(ivisurf->surface);
weston_surface_damage(ivisurf->surface);
}
} }
static void static void
@ -799,6 +803,7 @@ commit_screen_list(struct ivi_layout *layout)
struct ivi_layout_layer *ivilayer = NULL; struct ivi_layout_layer *ivilayer = NULL;
struct ivi_layout_layer *next = NULL; struct ivi_layout_layer *next = NULL;
struct ivi_layout_surface *ivisurf = NULL; struct ivi_layout_surface *ivisurf = NULL;
struct weston_view *tmpview = NULL;
wl_list_for_each(iviscrn, &layout->screen_list, link) { wl_list_for_each(iviscrn, &layout->screen_list, link) {
if (iviscrn->order.dirty) { if (iviscrn->order.dirty) {
@ -831,17 +836,11 @@ commit_screen_list(struct ivi_layout *layout)
continue; continue;
wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) { wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) {
struct weston_view *tmpview = NULL;
wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) {
if (tmpview != NULL) {
break;
}
}
if (ivisurf->prop.visibility == false) if (ivisurf->prop.visibility == false)
continue; continue;
if (ivisurf->surface == NULL || tmpview == NULL)
continue; tmpview = get_weston_view(ivisurf);
assert(tmpview != NULL);
weston_layer_entry_insert(&layout->layout_layer.view_list, weston_layer_entry_insert(&layout->layout_layer.view_list,
&tmpview->layer_link); &tmpview->layer_link);
@ -2555,18 +2554,10 @@ ivi_layout_surface_dump(struct weston_surface *surface,
struct weston_view * struct weston_view *
ivi_layout_get_weston_view(struct ivi_layout_surface *surface) ivi_layout_get_weston_view(struct ivi_layout_surface *surface)
{ {
struct weston_view *tmpview = NULL;
if (surface == NULL) if (surface == NULL)
return NULL; return NULL;
wl_list_for_each(tmpview, &surface->surface->views, surface_link) return get_weston_view(surface);
{
if (tmpview != NULL) {
break;
}
}
return tmpview;
} }
void void

Loading…
Cancel
Save