[PATCH weston-ivi-shell 05/15] The weston-layout library supports:
Nobuhiko Tanibata
NOBUHIKO_TANIBATA at xddp.denso.co.jp
Thu Mar 6 01:57:58 PST 2014
API set of controlling properties of surface and layer which groups
surfaces. An unique ID whose type is integer is required to create
surface and layer. With the unique ID, surface and layer are identified
to control them. The API set consists of APIs to control properties of
surface and layers about followings,
- visibility.
- opacity.
- clipping (x,y,width,height).
- position and size of it to be displayed.
- orientation per 90 degree.
- add or remove surfaces to a layer.
- order of surfaces/layers in layer/screen to be displayed.
- commit to apply property changes.
- notifications of property change.
Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA at xddp.denso.co.jp>
---
ivi-shell/weston-layout.c | 2633 +++++++++++++++++++++++++++++++++++++++++++++
ivi-shell/weston-layout.h | 920 ++++++++++++++++
2 files changed, 3553 insertions(+)
create mode 100644 ivi-shell/weston-layout.c
create mode 100644 ivi-shell/weston-layout.h
diff --git a/ivi-shell/weston-layout.c b/ivi-shell/weston-layout.c
new file mode 100644
index 0000000..0517e2d
--- /dev/null
+++ b/ivi-shell/weston-layout.c
@@ -0,0 +1,2633 @@
+/*
+ * Copyright (C) 2013 DENSO CORPORATION
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * Implementation of weston-layout library. The actual view on screen is
+ * not updated till calling weston_layout_commitChanges. A overview from
+ * calling API for updating properties of surfaces/layer to asking compositor
+ * to compose them by using weston_compositor_schedule_repaint,
+ * 0/ initialize this library by weston_layout_initWithCompositor
+ * with (struct weston_compositor *ec) from ivi-shell.
+ * 1/ When a API for updating properties of surface/layer, it updates
+ * pending prop of weston_layout_surface/layer/screen which are structure to
+ * store properties.
+ * 2/ Before calling commitChanges, in case of calling a API to get a property,
+ * return current property, not pending property.
+ * 3/ At the timing of calling weston_layout_commitChanges, pending properties
+ * are applied
+ * to properties.
+ * 4/ According properties, set transformation by using weston_matrix and
+ * weston_view per surfaces and layers in while loop.
+ * 5/ Set damage and trigger transform by using weston_view_geometry_dirty and
+ * weston_view_geometry_dirty.
+ * 6/ Notify update of properties.
+ * 7/ Trigger composition by weston_compositor_schedule_repaint.
+ *
+ */
+
+#include <sys/wait.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <linux/input.h>
+#include <cairo.h>
+
+#include "compositor.h"
+#include "weston-layout.h"
+
+enum weston_layout_surface_orientation {
+ WESTON_LAYOUT_SURFACE_ORIENTATION_0_DEGREES = 0,
+ WESTON_LAYOUT_SURFACE_ORIENTATION_90_DEGREES = 1,
+ WESTON_LAYOUT_SURFACE_ORIENTATION_180_DEGREES = 2,
+ WESTON_LAYOUT_SURFACE_ORIENTATION_270_DEGREES = 3,
+};
+
+enum weston_layout_surface_pixelformat {
+ WESTON_LAYOUT_SURFACE_PIXELFORMAT_R_8 = 0,
+ WESTON_LAYOUT_SURFACE_PIXELFORMAT_RGB_888 = 1,
+ WESTON_LAYOUT_SURFACE_PIXELFORMAT_RGBA_8888 = 2,
+ WESTON_LAYOUT_SURFACE_PIXELFORMAT_RGB_565 = 3,
+ WESTON_LAYOUT_SURFACE_PIXELFORMAT_RGBA_5551 = 4,
+ WESTON_LAYOUT_SURFACE_PIXELFORMAT_RGBA_6661 = 5,
+ WESTON_LAYOUT_SURFACE_PIXELFORMAT_RGBA_4444 = 6,
+ WESTON_LAYOUT_SURFACE_PIXELFORMAT_UNKNOWN = 7,
+};
+
+struct link_layer {
+ struct weston_layout_layer *ivilayer;
+ struct wl_list link;
+};
+
+struct link_screen {
+ struct weston_layout_screen *iviscrn;
+ struct wl_list link;
+};
+
+struct link_layerPropertyNotification {
+ layerPropertyNotificationFunc callback;
+ void *userdata;
+ struct wl_list link;
+};
+
+struct link_surfacePropertyNotification {
+ surfacePropertyNotificationFunc callback;
+ void *userdata;
+ struct wl_list link;
+};
+
+struct link_layerCreateNotification {
+ layerCreateNotificationFunc callback;
+ void *userdata;
+ struct wl_list link;
+};
+
+struct link_layerRemoveNotification {
+ layerRemoveNotificationFunc callback;
+ void *userdata;
+ struct wl_list link;
+};
+
+struct link_surfaceCreateNotification {
+ surfaceCreateNotificationFunc callback;
+ void *userdata;
+ struct wl_list link;
+};
+
+struct link_surfaceRemoveNotification {
+ surfaceRemoveNotificationFunc callback;
+ void *userdata;
+ struct wl_list link;
+};
+
+struct link_surfaceConfigureNotification {
+ surfaceConfigureNotificationFunc callback;
+ void *userdata;
+ struct wl_list link;
+};
+
+struct weston_layout;
+
+struct weston_layout_surface {
+ struct wl_list link;
+ struct wl_list list_notification;
+ struct wl_list list_layer;
+ uint32_t update_count;
+ uint32_t id_surface;
+
+ struct weston_layout *layout;
+ struct weston_surface *surface;
+ struct weston_view *view;
+
+ uint32_t buffer_width;
+ uint32_t buffer_height;
+
+ struct wl_listener surface_destroy_listener;
+ struct weston_transform surface_rotation;
+ struct weston_transform layer_rotation;
+ struct weston_transform surface_pos;
+ struct weston_transform layer_pos;
+ struct weston_transform scaling;
+ struct weston_layout_SurfaceProperties prop;
+ int32_t pixelformat;
+ uint32_t event_mask;
+
+ struct {
+ struct weston_layout_SurfaceProperties prop;
+ struct wl_list link;
+ } pending;
+
+ struct {
+ struct wl_list link;
+ struct wl_list list_layer;
+ } order;
+};
+
+struct weston_layout_layer {
+ struct wl_list link;
+ struct wl_list list_notification;
+ struct wl_list list_screen;
+ uint32_t id_layer;
+
+ struct weston_layout *layout;
+ struct weston_layer el;
+
+ struct weston_layout_LayerProperties prop;
+ uint32_t event_mask;
+
+ struct {
+ struct weston_layout_LayerProperties prop;
+ struct wl_list list_surface;
+ struct wl_list link;
+ } pending;
+
+ struct {
+ struct wl_list list_surface;
+ struct wl_list link;
+ } order;
+};
+
+struct weston_layout_screen {
+ struct wl_list link;
+ uint32_t id_screen;
+
+ struct weston_layout *layout;
+ struct weston_output *output;
+
+ uint32_t event_mask;
+
+ struct {
+ struct wl_list list_layer;
+ struct wl_list link;
+ } pending;
+
+ struct {
+ struct wl_list list_layer;
+ struct wl_list link;
+ } order;
+};
+
+struct weston_layout {
+ struct weston_compositor *compositor;
+
+ struct wl_list list_surface;
+ struct wl_list list_layer;
+ struct wl_list list_screen;
+
+ struct {
+ struct wl_list list_create;
+ struct wl_list list_remove;
+ } layer_notification;
+
+ struct {
+ struct wl_list list_create;
+ struct wl_list list_remove;
+ struct wl_list list_configure;
+ } surface_notification;
+
+ /* to enalbe displaying cursor*/
+ int32_t is_cursor_enabled;
+};
+
+struct weston_layout ivilayout = {0};
+
+static struct weston_layout *
+get_instance(void)
+{
+ return &ivilayout;
+}
+
+/**
+ * Internal API to add/remove a surface from layer.
+ */
+static void
+add_ordersurface_to_layer(struct weston_layout_surface *ivisurf,
+ struct weston_layout_layer *ivilayer)
+{
+ struct link_layer *link_layer = NULL;
+
+ link_layer = malloc(sizeof *link_layer);
+ if (link_layer == NULL) {
+ weston_log("fails to allocate memory\n");
+ return;
+ }
+
+ link_layer->ivilayer = ivilayer;
+ wl_list_init(&link_layer->link);
+ wl_list_insert(&ivisurf->list_layer, &link_layer->link);
+}
+
+static void
+remove_ordersurface_from_layer(struct weston_layout_surface *ivisurf)
+{
+ struct link_layer *link_layer = NULL;
+ struct link_layer *next = NULL;
+
+ wl_list_for_each_safe(link_layer, next, &ivisurf->list_layer, link) {
+ if (!wl_list_empty(&link_layer->link)) {
+ wl_list_remove(&link_layer->link);
+ }
+ free(link_layer);
+ link_layer = NULL;
+ }
+ wl_list_init(&ivisurf->list_layer);
+}
+
+/**
+ * Internal API to add/remove a layer from screen.
+ */
+static void
+add_orderlayer_to_screen(struct weston_layout_layer *ivilayer,
+ struct weston_layout_screen *iviscrn)
+{
+ struct link_screen *link_scrn = NULL;
+
+ link_scrn = malloc(sizeof *link_scrn);
+ if (link_scrn == NULL) {
+ weston_log("fails to allocate memory\n");
+ return;
+ }
+
+ link_scrn->iviscrn = iviscrn;
+ wl_list_init(&link_scrn->link);
+ wl_list_insert(&ivilayer->list_screen, &link_scrn->link);
+}
+
+static void
+remove_orderlayer_from_screen(struct weston_layout_layer *ivilayer)
+{
+ struct link_screen *link_scrn = NULL;
+ struct link_screen *next = NULL;
+
+ wl_list_for_each_safe(link_scrn, next, &ivilayer->list_screen, link) {
+ if (!wl_list_empty(&link_scrn->link)) {
+ wl_list_remove(&link_scrn->link);
+ }
+ free(link_scrn);
+ link_scrn = NULL;
+ }
+ wl_list_init(&ivilayer->list_screen);
+}
+
+/**
+ * Internal API to add/remove a layer from screen.
+ */
+static struct weston_layout_surface *
+get_surface(struct wl_list *list_surf, uint32_t id_surface)
+{
+ struct weston_layout_surface *ivisurf;
+
+ wl_list_for_each(ivisurf, list_surf, link) {
+ if (ivisurf->id_surface == id_surface) {
+ return ivisurf;
+ }
+ }
+
+ return NULL;
+}
+
+static struct weston_layout_layer *
+get_layer(struct wl_list *list_layer, uint32_t id_layer)
+{
+ struct weston_layout_layer *ivilayer;
+
+ wl_list_for_each(ivilayer, list_layer, link) {
+ if (ivilayer->id_layer == id_layer) {
+ return ivilayer;
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * Called at destruction of ivi_surface
+ */
+static void
+westonsurface_destroy_from_ivisurface(struct wl_listener *listener, void *data)
+{
+ struct weston_layout_surface *ivisurf = NULL;
+
+ ivisurf = container_of(listener, struct weston_layout_surface,
+ surface_destroy_listener);
+ ivisurf->surface = NULL;
+}
+
+/**
+ * Internal API to check layer/surface already added in layer/screen.
+ * Called by weston_layout_layerAddSurface/weston_layout_screenAddLayer
+ */
+static int
+is_surface_in_layer(struct weston_layout_surface *ivisurf,
+ struct weston_layout_layer *ivilayer)
+{
+ struct weston_layout_surface *surf = NULL;
+
+ wl_list_for_each(surf, &ivilayer->pending.list_surface, pending.link) {
+ if (surf->id_surface == ivisurf->id_surface) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static int
+is_layer_in_screen(struct weston_layout_layer *ivilayer,
+ struct weston_layout_screen *iviscrn)
+{
+ struct weston_layout_layer *layer = NULL;
+
+ wl_list_for_each(layer, &iviscrn->pending.list_layer, pending.link) {
+ if (layer->id_layer == ivilayer->id_layer) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * Internal API to initialize screens found from output_list of weston_compositor.
+ * Called by weston_layout_initWithCompositor.
+ */
+static void
+create_screen(struct weston_compositor *ec)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_layout_screen *iviscrn = NULL;
+ struct weston_output *output = NULL;
+ int32_t count = 0;
+
+ wl_list_for_each(output, &ec->output_list, link) {
+ iviscrn = calloc(1, sizeof *iviscrn);
+ if (iviscrn == NULL) {
+ weston_log("fails to allocate memory\n");
+ continue;
+ }
+
+ wl_list_init(&iviscrn->link);
+ iviscrn->layout = layout;
+
+ iviscrn->id_screen = count;
+ count++;
+
+ iviscrn->output = output;
+ iviscrn->event_mask = 0;
+
+ wl_list_init(&iviscrn->pending.list_layer);
+ wl_list_init(&iviscrn->pending.link);
+
+ wl_list_init(&iviscrn->order.list_layer);
+ wl_list_init(&iviscrn->order.link);
+
+ wl_list_insert(&layout->list_screen, &iviscrn->link);
+ }
+}
+
+/**
+ * Internal APIs to initialize properties of surface/layer when they are created.
+ */
+static void
+init_layerProperties(struct weston_layout_LayerProperties *prop,
+ int32_t width, int32_t height)
+{
+ memset(prop, 0, sizeof *prop);
+ prop->opacity = wl_fixed_from_double(1.0);
+ prop->sourceWidth = width;
+ prop->sourceHeight = height;
+ prop->destWidth = width;
+ prop->destHeight = height;
+}
+
+static void
+init_surfaceProperties(struct weston_layout_SurfaceProperties *prop)
+{
+ memset(prop, 0, sizeof *prop);
+ prop->opacity = wl_fixed_from_double(1.0);
+}
+
+/**
+ * Internal APIs to be called from weston_layout_commitChanges.
+ */
+static void
+update_opacity(struct weston_layout_layer *ivilayer,
+ struct weston_layout_surface *ivisurf)
+{
+ double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity);
+ double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity);
+
+ if ((ivilayer->event_mask & IVI_NOTIFICATION_OPACITY) ||
+ (ivisurf->event_mask & IVI_NOTIFICATION_OPACITY)) {
+ if (ivisurf->view == NULL) {
+ return;
+ }
+ ivisurf->view->alpha = layer_alpha * surf_alpha;
+ }
+}
+
+static void
+update_surface_orientation(struct weston_layout_layer *ivilayer,
+ struct weston_layout_surface *ivisurf)
+{
+ struct weston_view *view = ivisurf->view;
+ struct weston_matrix *matrix = &ivisurf->surface_rotation.matrix;
+ float width = 0.0f;
+ float height = 0.0f;
+ float v_sin = 0.0f;
+ float v_cos = 0.0f;
+ float cx = 0.0f;
+ float cy = 0.0f;
+ float sx = 1.0f;
+ float sy = 1.0f;
+
+ if (view == NULL) {
+ return;
+ }
+
+ if ((ivilayer->prop.destWidth == 0) ||
+ (ivilayer->prop.destHeight == 0)) {
+ return;
+ }
+ width = (float)ivilayer->prop.destWidth;
+ height = (float)ivilayer->prop.destHeight;
+
+ switch (ivisurf->prop.orientation) {
+ case WESTON_LAYOUT_SURFACE_ORIENTATION_0_DEGREES:
+ v_sin = 0.0f;
+ v_cos = 1.0f;
+ break;
+ case WESTON_LAYOUT_SURFACE_ORIENTATION_90_DEGREES:
+ v_sin = 1.0f;
+ v_cos = 0.0f;
+ sx = width / height;
+ sy = height / width;
+ break;
+ case WESTON_LAYOUT_SURFACE_ORIENTATION_180_DEGREES:
+ v_sin = 0.0f;
+ v_cos = -1.0f;
+ break;
+ case WESTON_LAYOUT_SURFACE_ORIENTATION_270_DEGREES:
+ default:
+ v_sin = -1.0f;
+ v_cos = 0.0f;
+ sx = width / height;
+ sy = height / width;
+ break;
+ }
+ wl_list_remove(&ivisurf->surface_rotation.link);
+ weston_view_geometry_dirty(view);
+
+ weston_matrix_init(matrix);
+ cx = 0.5f * width;
+ cy = 0.5f * height;
+ weston_matrix_translate(matrix, -cx, -cy, 0.0f);
+ weston_matrix_rotate_xy(matrix, v_cos, v_sin);
+ weston_matrix_scale(matrix, sx, sy, 1.0);
+ weston_matrix_translate(matrix, cx, cy, 0.0f);
+ wl_list_insert(&view->geometry.transformation_list,
+ &ivisurf->surface_rotation.link);
+
+ weston_view_set_transform_parent(view, NULL);
+ weston_view_update_transform(view);
+}
+
+static void
+update_layer_orientation(struct weston_layout_layer *ivilayer,
+ struct weston_layout_surface *ivisurf)
+{
+ struct weston_surface *es = ivisurf->surface;
+ struct weston_view *view = ivisurf->view;
+ struct weston_matrix *matrix = &ivisurf->layer_rotation.matrix;
+ struct weston_output *output = NULL;
+ float width = 0.0f;
+ float height = 0.0f;
+ float v_sin = 0.0f;
+ float v_cos = 0.0f;
+ float cx = 0.0f;
+ float cy = 0.0f;
+ float sx = 1.0f;
+ float sy = 1.0f;
+
+ if (es == NULL || view == NULL) {
+ return;
+ }
+
+ output = es->output;
+ if (output == NULL) {
+ return;
+ }
+ if ((output->width == 0) || (output->height == 0)) {
+ return;
+ }
+ width = (float)output->width;
+ height = (float)output->height;
+
+ switch (ivilayer->prop.orientation) {
+ case WESTON_LAYOUT_SURFACE_ORIENTATION_0_DEGREES:
+ v_sin = 0.0f;
+ v_cos = 1.0f;
+ break;
+ case WESTON_LAYOUT_SURFACE_ORIENTATION_90_DEGREES:
+ v_sin = 1.0f;
+ v_cos = 0.0f;
+ sx = width / height;
+ sy = height / width;
+ break;
+ case WESTON_LAYOUT_SURFACE_ORIENTATION_180_DEGREES:
+ v_sin = 0.0f;
+ v_cos = -1.0f;
+ break;
+ case WESTON_LAYOUT_SURFACE_ORIENTATION_270_DEGREES:
+ default:
+ v_sin = -1.0f;
+ v_cos = 0.0f;
+ sx = width / height;
+ sy = height / width;
+ break;
+ }
+ wl_list_remove(&ivisurf->layer_rotation.link);
+ weston_view_geometry_dirty(view);
+
+ weston_matrix_init(matrix);
+ cx = 0.5f * width;
+ cy = 0.5f * height;
+ weston_matrix_translate(matrix, -cx, -cy, 0.0f);
+ weston_matrix_rotate_xy(matrix, v_cos, v_sin);
+ weston_matrix_scale(matrix, sx, sy, 1.0);
+ weston_matrix_translate(matrix, cx, cy, 0.0f);
+ wl_list_insert(&view->geometry.transformation_list,
+ &ivisurf->layer_rotation.link);
+
+ weston_view_set_transform_parent(view, NULL);
+ weston_view_update_transform(view);
+}
+
+static void
+update_surface_position(struct weston_layout_surface *ivisurf)
+{
+ struct weston_view *view = ivisurf->view;
+ float tx = (float)ivisurf->prop.destX;
+ float ty = (float)ivisurf->prop.destY;
+ struct weston_matrix *matrix = &ivisurf->surface_pos.matrix;
+
+ if (view == NULL) {
+ return;
+ }
+
+ wl_list_remove(&ivisurf->surface_pos.link);
+
+ weston_matrix_init(matrix);
+ weston_matrix_translate(matrix, tx, ty, 0.0f);
+ wl_list_insert(&view->geometry.transformation_list,
+ &ivisurf->surface_pos.link);
+
+ weston_view_set_transform_parent(view, NULL);
+ weston_view_update_transform(view);
+
+#if 0
+ /* disable zoom animation */
+ weston_zoom_run(es, 0.0, 1.0, NULL, NULL);
+#endif
+
+}
+
+static void
+update_layer_position(struct weston_layout_layer *ivilayer,
+ struct weston_layout_surface *ivisurf)
+{
+ struct weston_view *view = ivisurf->view;
+ struct weston_matrix *matrix = &ivisurf->layer_pos.matrix;
+ float tx = (float)ivilayer->prop.destX;
+ float ty = (float)ivilayer->prop.destY;
+
+ if (view == NULL) {
+ return;
+ }
+
+ wl_list_remove(&ivisurf->layer_pos.link);
+
+ weston_matrix_init(matrix);
+ weston_matrix_translate(matrix, tx, ty, 0.0f);
+ wl_list_insert(
+ &view->geometry.transformation_list,
+ &ivisurf->layer_pos.link);
+
+ weston_view_set_transform_parent(view, NULL);
+ weston_view_update_transform(view);
+}
+
+static void
+update_scale(struct weston_layout_layer *ivilayer,
+ struct weston_layout_surface *ivisurf)
+{
+ struct weston_view *view = ivisurf->view;
+ struct weston_matrix *matrix = &ivisurf->scaling.matrix;
+ float sx = 0.0f;
+ float sy = 0.0f;
+ float lw = 0.0f;
+ float sw = 0.0f;
+ float lh = 0.0f;
+ float sh = 0.0f;
+
+ if (view == NULL) {
+ return;
+ }
+
+ if (ivisurf->prop.sourceWidth == 0 && ivisurf->prop.sourceHeight == 0) {
+ ivisurf->prop.sourceWidth = ivisurf->buffer_width;
+ ivisurf->prop.sourceHeight = ivisurf->buffer_height;
+
+ if (ivisurf->prop.destWidth == 0 && ivisurf->prop.destHeight == 0) {
+ ivisurf->prop.destWidth = ivisurf->buffer_width;
+ ivisurf->prop.destHeight = ivisurf->buffer_height;
+ }
+ }
+
+ lw = ((float)ivilayer->prop.destWidth / ivilayer->prop.sourceWidth );
+ sw = ((float)ivisurf->prop.destWidth / ivisurf->prop.sourceWidth );
+ lh = ((float)ivilayer->prop.destHeight / ivilayer->prop.sourceHeight);
+ sh = ((float)ivisurf->prop.destHeight / ivisurf->prop.sourceHeight );
+ sx = sw * lw;
+ sy = sh * lh;
+
+ wl_list_remove(&ivisurf->scaling.link);
+ weston_matrix_init(matrix);
+ weston_matrix_scale(matrix, sx, sy, 1.0f);
+
+ wl_list_insert(&view->geometry.transformation_list,
+ &ivisurf->scaling.link);
+
+ weston_view_set_transform_parent(view, NULL);
+ weston_view_update_transform(view);
+}
+
+static void
+update_prop(struct weston_layout_layer *ivilayer,
+ struct weston_layout_surface *ivisurf)
+{
+ if (ivilayer->event_mask | ivisurf->event_mask) {
+ update_opacity(ivilayer, ivisurf);
+ update_layer_orientation(ivilayer, ivisurf);
+ update_layer_position(ivilayer, ivisurf);
+ update_surface_position(ivisurf);
+ update_surface_orientation(ivilayer, ivisurf);
+ update_scale(ivilayer, ivisurf);
+
+ ivisurf->update_count++;
+
+ if (ivisurf->view != NULL) {
+ weston_view_geometry_dirty(ivisurf->view);
+ }
+
+ if (ivisurf->surface != NULL) {
+ weston_surface_damage(ivisurf->surface);
+ }
+ }
+}
+
+static void
+commit_changes(struct weston_layout *layout)
+{
+ struct weston_layout_screen *iviscrn = NULL;
+ struct weston_layout_layer *ivilayer = NULL;
+ struct weston_layout_surface *ivisurf = NULL;
+
+ wl_list_for_each(iviscrn, &layout->list_screen, link) {
+ wl_list_for_each(ivilayer, &iviscrn->order.list_layer, order.link) {
+ wl_list_for_each(ivisurf, &ivilayer->order.list_surface, order.link) {
+ update_prop(ivilayer, ivisurf);
+ }
+ }
+ }
+}
+
+static void
+commit_list_surface(struct weston_layout *layout)
+{
+ struct weston_layout_surface *ivisurf = NULL;
+
+ wl_list_for_each(ivisurf, &layout->list_surface, link) {
+ ivisurf->prop = ivisurf->pending.prop;
+ }
+}
+
+static void
+commit_list_layer(struct weston_layout *layout)
+{
+ struct weston_layout_layer *ivilayer = NULL;
+ struct weston_layout_surface *ivisurf = NULL;
+ struct weston_layout_surface *next = NULL;
+
+ wl_list_for_each(ivilayer, &layout->list_layer, link) {
+ ivilayer->prop = ivilayer->pending.prop;
+
+ if (!(ivilayer->event_mask & IVI_NOTIFICATION_ADD)) {
+ continue;
+ }
+
+ wl_list_for_each_safe(ivisurf, next,
+ &ivilayer->order.list_surface, order.link) {
+ remove_ordersurface_from_layer(ivisurf);
+
+ if (!wl_list_empty(&ivisurf->order.link)) {
+ wl_list_remove(&ivisurf->order.link);
+ }
+
+ wl_list_init(&ivisurf->order.link);
+ }
+
+ wl_list_init(&ivilayer->order.list_surface);
+ wl_list_for_each(ivisurf, &ivilayer->pending.list_surface,
+ pending.link) {
+ wl_list_insert(&ivilayer->order.list_surface,
+ &ivisurf->order.link);
+ add_ordersurface_to_layer(ivisurf, ivilayer);
+ }
+ }
+}
+
+static void
+commit_list_screen(struct weston_layout *layout)
+{
+ struct weston_compositor *ec = layout->compositor;
+ struct weston_layout_screen *iviscrn = NULL;
+ struct weston_layout_layer *ivilayer = NULL;
+ struct weston_layout_layer *next = NULL;
+ struct weston_layout_surface *ivisurf = NULL;
+
+ wl_list_for_each(iviscrn, &layout->list_screen, link) {
+ if (iviscrn->event_mask & IVI_NOTIFICATION_ADD) {
+ wl_list_for_each_safe(ivilayer, next,
+ &iviscrn->order.list_layer, order.link) {
+ remove_orderlayer_from_screen(ivilayer);
+
+ if (!wl_list_empty(&ivilayer->order.link)) {
+ wl_list_remove(&ivilayer->order.link);
+ }
+
+ wl_list_init(&ivilayer->order.link);
+ }
+
+ wl_list_init(&iviscrn->order.list_layer);
+ wl_list_for_each(ivilayer, &iviscrn->pending.list_layer,
+ pending.link) {
+ wl_list_insert(&iviscrn->order.list_layer,
+ &ivilayer->order.link);
+ add_orderlayer_to_screen(ivilayer, iviscrn);
+ }
+ iviscrn->event_mask = 0;
+ }
+
+ /* For rendering */
+ wl_list_init(&ec->layer_list);
+ wl_list_for_each(ivilayer, &iviscrn->order.list_layer, order.link) {
+ if (ivilayer->prop.visibility == 0) {
+ continue;
+ }
+
+ wl_list_insert(&ec->layer_list, &ivilayer->el.link);
+ wl_list_init(&ivilayer->el.view_list);
+
+ wl_list_for_each(ivisurf, &ivilayer->order.list_surface, order.link) {
+ if (ivisurf->prop.visibility == 0) {
+ continue;
+ }
+
+ if (ivisurf->surface == NULL || ivisurf->view == NULL) {
+ continue;
+ }
+
+ wl_list_insert(&ivilayer->el.view_list,
+ &ivisurf->view->layer_link);
+ ivisurf->surface->output = iviscrn->output;
+ }
+ }
+
+ /*Add cursor layer if cursor is configured.*/
+ if (layout->is_cursor_enabled) {
+ wl_list_insert(&ec->layer_list, &ec->cursor_layer.link);
+ }
+
+ break;
+ }
+}
+
+static void
+send_surface_prop(struct weston_layout_surface *ivisurf)
+{
+ struct link_surfacePropertyNotification *notification = NULL;
+
+ wl_list_for_each(notification, &ivisurf->list_notification, link) {
+ notification->callback(ivisurf, &ivisurf->prop,
+ ivisurf->event_mask,
+ notification->userdata);
+ }
+
+ ivisurf->event_mask = 0;
+}
+
+static void
+send_layer_prop(struct weston_layout_layer *ivilayer)
+{
+ struct link_layerPropertyNotification *notification = NULL;
+
+ wl_list_for_each(notification, &ivilayer->list_notification, link) {
+ notification->callback(ivilayer, &ivilayer->prop,
+ ivilayer->event_mask,
+ notification->userdata);
+ }
+
+ ivilayer->event_mask = 0;
+}
+
+static void
+send_prop(struct weston_layout *layout)
+{
+ struct weston_layout_layer *ivilayer = NULL;
+ struct weston_layout_surface *ivisurf = NULL;
+
+ wl_list_for_each(ivilayer, &layout->list_layer, link) {
+ send_layer_prop(ivilayer);
+ }
+
+ wl_list_for_each(ivisurf, &layout->list_surface, link) {
+ send_surface_prop(ivisurf);
+ }
+}
+
+/**
+ * Exported APIs of weston-layout library are implemented from here.
+ * Brief of APIs is described in weston-layout.h.
+ */
+WL_EXPORT struct weston_view *
+weston_layout_get_weston_view(struct weston_layout_surface *surface)
+{
+ return (surface != NULL) ? surface->view : NULL;
+}
+
+WL_EXPORT void
+weston_layout_initWithCompositor(struct weston_compositor *ec)
+{
+ struct weston_layout *layout = get_instance();
+
+ layout->compositor = ec;
+
+ wl_list_init(&layout->list_surface);
+ wl_list_init(&layout->list_layer);
+ wl_list_init(&layout->list_screen);
+
+ wl_list_init(&layout->layer_notification.list_create);
+ wl_list_init(&layout->layer_notification.list_remove);
+
+ wl_list_init(&layout->surface_notification.list_create);
+ wl_list_init(&layout->surface_notification.list_remove);
+ wl_list_init(&layout->surface_notification.list_configure);
+
+ create_screen(ec);
+
+ struct weston_config *config = weston_config_parse("weston.ini");
+ struct weston_config_section *s =
+ weston_config_get_section(config, "ivi-shell", NULL, NULL);
+
+ /*A cursor is configured if weston.ini has keys.*/
+ char* cursor_theme = NULL;
+ weston_config_section_get_string(s, "cursor-theme", &cursor_theme, NULL);
+ layout->is_cursor_enabled = (NULL != cursor_theme);
+ free(cursor_theme);
+ weston_config_destroy(config);
+}
+
+WL_EXPORT int32_t
+weston_layout_setNotificationCreateLayer(layerCreateNotificationFunc callback,
+ void *userdata)
+{
+ struct weston_layout *layout = get_instance();
+ struct link_layerCreateNotification *notification = NULL;
+
+ if (callback == NULL) {
+ weston_log("weston_layout_setNotificationCreateLayer: invalid argument\n");
+ return -1;
+ }
+
+ notification = malloc(sizeof *notification);
+ if (notification == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ notification->callback = callback;
+ notification->userdata = userdata;
+ wl_list_init(¬ification->link);
+ wl_list_insert(&layout->layer_notification.list_create, ¬ification->link);
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_setNotificationRemoveLayer(layerRemoveNotificationFunc callback,
+ void *userdata)
+{
+ struct weston_layout *layout = get_instance();
+ struct link_layerRemoveNotification *notification = NULL;
+
+ if (callback == NULL) {
+ weston_log("weston_layout_setNotificationRemoveLayer: invalid argument\n");
+ return -1;
+ }
+
+ notification = malloc(sizeof *notification);
+ if (notification == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ notification->callback = callback;
+ notification->userdata = userdata;
+ wl_list_init(¬ification->link);
+ wl_list_insert(&layout->layer_notification.list_remove, ¬ification->link);
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_setNotificationCreateSurface(surfaceCreateNotificationFunc callback,
+ void *userdata)
+{
+ struct weston_layout *layout = get_instance();
+ struct link_surfaceCreateNotification *notification = NULL;
+
+ if (callback == NULL) {
+ weston_log("weston_layout_setNotificationCreateSurface: invalid argument\n");
+ return -1;
+ }
+
+ notification = malloc(sizeof *notification);
+ if (notification == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ notification->callback = callback;
+ notification->userdata = userdata;
+ wl_list_init(¬ification->link);
+ wl_list_insert(&layout->surface_notification.list_create, ¬ification->link);
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_setNotificationRemoveSurface(surfaceRemoveNotificationFunc callback,
+ void *userdata)
+{
+ struct weston_layout *layout = get_instance();
+ struct link_surfaceRemoveNotification *notification = NULL;
+
+ if (callback == NULL) {
+ weston_log("weston_layout_setNotificationRemoveSurface: invalid argument\n");
+ return -1;
+ }
+
+ notification = malloc(sizeof *notification);
+ if (notification == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ notification->callback = callback;
+ notification->userdata = userdata;
+ wl_list_init(¬ification->link);
+ wl_list_insert(&layout->surface_notification.list_remove, ¬ification->link);
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_setNotificationConfigureSurface(surfaceConfigureNotificationFunc callback,
+ void *userdata)
+{
+ struct weston_layout *layout = get_instance();
+ struct link_surfaceConfigureNotification *notification = NULL;
+
+ if (callback == NULL) {
+ weston_log("weston_layout_setNotificationConfigureSurface: invalid argument\n");
+ return -1;
+ }
+
+ notification = malloc(sizeof *notification);
+ if (notification == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ notification->callback = callback;
+ notification->userdata = userdata;
+ wl_list_init(¬ification->link);
+ wl_list_insert(&layout->surface_notification.list_configure, ¬ification->link);
+
+ return 0;
+}
+
+WL_EXPORT uint32_t
+weston_layout_getIdOfSurface(struct weston_layout_surface *ivisurf)
+{
+ return ivisurf->id_surface;
+}
+
+WL_EXPORT uint32_t
+weston_layout_getIdOfLayer(struct weston_layout_layer *ivilayer)
+{
+ return ivilayer->id_layer;
+}
+
+WL_EXPORT struct weston_layout_layer *
+weston_layout_getLayerFromId(uint32_t id_layer)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_layout_layer *ivilayer = NULL;
+
+ wl_list_for_each(ivilayer, &layout->list_layer, link) {
+ if (ivilayer->id_layer == id_layer) {
+ return ivilayer;
+ }
+ }
+
+ return NULL;
+}
+
+WL_EXPORT struct weston_layout_surface *
+weston_layout_getSurfaceFromId(uint32_t id_surface)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_layout_surface *ivisurf = NULL;
+
+ wl_list_for_each(ivisurf, &layout->list_surface, link) {
+ if (ivisurf->id_surface == id_surface) {
+ return ivisurf;
+ }
+ }
+
+ return NULL;
+}
+
+WL_EXPORT struct weston_layout_screen *
+weston_layout_getScreenFromId(uint32_t id_screen)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_layout_screen *iviscrn = NULL;
+ (void)id_screen;
+
+ wl_list_for_each(iviscrn, &layout->list_screen, link) {
+//FIXME : select iviscrn from list_screen by id_screen
+ return iviscrn;
+ break;
+ }
+
+ return NULL;
+}
+
+WL_EXPORT int32_t
+weston_layout_getScreenResolution(struct weston_layout_screen *iviscrn,
+ uint32_t *pWidth, uint32_t *pHeight)
+{
+ struct weston_output *output = NULL;
+
+ if (pWidth == NULL || pHeight == NULL) {
+ weston_log("weston_layout_getScreenResolution: invalid argument\n");
+ return -1;
+ }
+
+ output = iviscrn->output;
+ *pWidth = output->current_mode->width;
+ *pHeight = output->current_mode->height;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceAddNotification(struct weston_layout_surface *ivisurf,
+ surfacePropertyNotificationFunc callback,
+ void *userdata)
+{
+ struct link_surfacePropertyNotification *notification = NULL;
+
+ if (ivisurf == NULL || callback == NULL) {
+ weston_log("weston_layout_surfaceAddNotification: invalid argument\n");
+ return -1;
+ }
+
+ notification = malloc(sizeof *notification);
+ if (notification == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ notification->callback = callback;
+ notification->userdata = userdata;
+ wl_list_init(¬ification->link);
+ wl_list_insert(&ivisurf->list_notification, ¬ification->link);
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceRemoveNotification(struct weston_layout_surface *ivisurf)
+{
+ struct link_surfacePropertyNotification *notification = NULL;
+ struct link_surfacePropertyNotification *next = NULL;
+
+ if (ivisurf == NULL) {
+ weston_log("weston_layout_surfaceRemoveNotification: invalid argument\n");
+ return -1;
+ }
+
+ wl_list_for_each_safe(notification, next,
+ &ivisurf->list_notification, link) {
+ if (!wl_list_empty(¬ification->link)) {
+ wl_list_remove(¬ification->link);
+ }
+ free(notification);
+ notification = NULL;
+ }
+ wl_list_init(&ivisurf->list_notification);
+
+ return 0;
+}
+
+WL_EXPORT struct weston_layout_surface*
+weston_layout_surfaceCreate(struct weston_surface *wl_surface,
+ uint32_t id_surface)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_layout_surface *ivisurf = NULL;
+ struct link_surfaceCreateNotification *notification = NULL;
+
+ if (wl_surface == NULL) {
+ weston_log("weston_layout_surfaceCreate: invalid argument\n");
+ return NULL;
+ }
+
+ ivisurf = get_surface(&layout->list_surface, id_surface);
+ if (ivisurf != NULL) {
+//FIXME
+ weston_log("id_surface is already created\n");
+ ivisurf->surface = wl_surface;
+ if (wl_surface != NULL) {
+ ivisurf->surface_destroy_listener.notify =
+ westonsurface_destroy_from_ivisurface;
+ wl_resource_add_destroy_listener(wl_surface->resource,
+ &ivisurf->surface_destroy_listener);
+
+ }
+
+ if (ivisurf->view != NULL) {
+ weston_view_destroy(ivisurf->view);
+ }
+ ivisurf->view = NULL;
+
+ if (wl_surface != NULL) {
+ ivisurf->view = weston_view_create(wl_surface);
+ if (ivisurf->view == NULL) {
+ weston_log("fails to allocate memory\n");
+ }
+ }
+
+ ivisurf->buffer_width = 0;
+ ivisurf->buffer_height = 0;
+
+ wl_list_for_each(notification,
+ &layout->surface_notification.list_create, link) {
+ if (notification->callback != NULL) {
+ notification->callback(ivisurf, notification->userdata);
+ }
+ }
+
+ return NULL;
+ }
+
+ ivisurf = calloc(1, sizeof *ivisurf);
+ if (ivisurf == NULL) {
+ weston_log("fails to allocate memory\n");
+ return NULL;
+ }
+
+ wl_list_init(&ivisurf->link);
+ wl_list_init(&ivisurf->list_notification);
+ wl_list_init(&ivisurf->list_layer);
+ ivisurf->id_surface = id_surface;
+ ivisurf->layout = layout;
+
+ ivisurf->surface = wl_surface;
+ if (wl_surface != NULL) {
+ ivisurf->surface_destroy_listener.notify =
+ westonsurface_destroy_from_ivisurface;
+ wl_resource_add_destroy_listener(wl_surface->resource,
+ &ivisurf->surface_destroy_listener);
+
+ ivisurf->view = weston_view_create(wl_surface);
+ if (ivisurf->view == NULL) {
+ weston_log("fails to allocate memory\n");
+ }
+ }
+
+ ivisurf->buffer_width = 0;
+ ivisurf->buffer_height = 0;
+
+ wl_list_init(&ivisurf->surface_rotation.link);
+ wl_list_init(&ivisurf->layer_rotation.link);
+ wl_list_init(&ivisurf->surface_pos.link);
+ wl_list_init(&ivisurf->layer_pos.link);
+ wl_list_init(&ivisurf->scaling.link);
+
+ init_surfaceProperties(&ivisurf->prop);
+ ivisurf->pixelformat = WESTON_LAYOUT_SURFACE_PIXELFORMAT_RGBA_8888;
+ ivisurf->event_mask = 0;
+
+ ivisurf->pending.prop = ivisurf->prop;
+ wl_list_init(&ivisurf->pending.link);
+
+ wl_list_init(&ivisurf->order.link);
+ wl_list_init(&ivisurf->order.list_layer);
+
+ wl_list_insert(&layout->list_surface, &ivisurf->link);
+
+ wl_list_for_each(notification,
+ &layout->surface_notification.list_create, link) {
+ if (notification->callback != NULL) {
+ notification->callback(ivisurf, notification->userdata);
+ }
+ }
+
+ return ivisurf;
+}
+
+WL_EXPORT void
+weston_layout_surfaceConfigure(struct weston_layout_surface *ivisurf,
+ uint32_t width, uint32_t height)
+{
+ struct weston_layout *layout = get_instance();
+ struct link_surfaceCreateNotification *notification = NULL;
+
+ ivisurf->buffer_width = width;
+ ivisurf->buffer_height = height;
+
+ wl_list_for_each(notification,
+ &layout->surface_notification.list_configure, link) {
+ if (notification->callback != NULL) {
+ notification->callback(ivisurf, notification->userdata);
+ }
+ }
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceRemove(struct weston_layout_surface *ivisurf)
+{
+ struct weston_layout *layout = get_instance();
+ struct link_surfaceRemoveNotification *notification = NULL;
+
+ if (ivisurf == NULL) {
+ weston_log("weston_layout_surfaceRemove: invalid argument\n");
+ return -1;
+ }
+
+ if (!wl_list_empty(&ivisurf->pending.link)) {
+ wl_list_remove(&ivisurf->pending.link);
+ }
+ if (!wl_list_empty(&ivisurf->order.link)) {
+ wl_list_remove(&ivisurf->order.link);
+ }
+ if (!wl_list_empty(&ivisurf->link)) {
+ wl_list_remove(&ivisurf->link);
+ }
+ remove_ordersurface_from_layer(ivisurf);
+
+ wl_list_for_each(notification,
+ &layout->surface_notification.list_remove, link) {
+ if (notification->callback != NULL) {
+ notification->callback(ivisurf, notification->userdata);
+ }
+ }
+
+ if (ivisurf->view != NULL) {
+ weston_view_destroy(ivisurf->view);
+ }
+
+ free(ivisurf);
+ ivisurf = NULL;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_UpdateInputEventAcceptanceOn(struct weston_layout_surface *ivisurf,
+ uint32_t devices, uint32_t acceptance)
+{
+ /* not supported */
+ (void)ivisurf;
+ (void)devices;
+ (void)acceptance;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceInitialize(struct weston_layout_surface **pSurfaceId)
+{
+ /* not supported */
+ (void)pSurfaceId;
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_getPropertiesOfLayer(struct weston_layout_layer *ivilayer,
+ struct weston_layout_LayerProperties *pLayerProperties)
+{
+ if (ivilayer == NULL || pLayerProperties == NULL) {
+ weston_log("weston_layout_getPropertiesOfLayer: invalid argument\n");
+ return -1;
+ }
+
+ *pLayerProperties = ivilayer->prop;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_getNumberOfHardwareLayers(uint32_t id_screen,
+ uint32_t *pNumberOfHardwareLayers)
+{
+ /* not supported */
+ (void)id_screen;
+ (void)pNumberOfHardwareLayers;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_getScreens(uint32_t *pLength, weston_layout_screen_ptr **ppArray)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_layout_screen *iviscrn = NULL;
+ uint32_t length = 0;
+ uint32_t n = 0;
+
+ if (pLength == NULL || ppArray == NULL) {
+ weston_log("weston_layout_getScreens: invalid argument\n");
+ return -1;
+ }
+
+ length = wl_list_length(&layout->list_screen);
+
+ if (length != 0){
+ /* the Array must be free by module which called this function */
+ *ppArray = calloc(length, sizeof(weston_layout_screen_ptr));
+ if (*ppArray == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ wl_list_for_each(iviscrn, &layout->list_screen, link) {
+ (*ppArray)[n++] = iviscrn;
+ }
+ }
+
+ *pLength = length;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_getScreensUnderLayer(struct weston_layout_layer *ivilayer,
+ uint32_t *pLength,
+ weston_layout_screen_ptr **ppArray)
+{
+ struct link_screen *link_scrn = NULL;
+ uint32_t length = 0;
+ uint32_t n = 0;
+
+ if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
+ weston_log("weston_layout_getScreensUnderLayer: invalid argument\n");
+ return -1;
+ }
+
+ length = wl_list_length(&ivilayer->list_screen);
+
+ if (length != 0){
+ /* the Array must be free by module which called this function */
+ *ppArray = calloc(length, sizeof(weston_layout_screen_ptr));
+ if (*ppArray == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ wl_list_for_each(link_scrn, &ivilayer->list_screen, link) {
+ (*ppArray)[n++] = link_scrn->iviscrn;
+ }
+ }
+
+ *pLength = length;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_getLayers(uint32_t *pLength, weston_layout_layer_ptr **ppArray)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_layout_layer *ivilayer = NULL;
+ uint32_t length = 0;
+ uint32_t n = 0;
+
+ if (pLength == NULL || ppArray == NULL) {
+ weston_log("weston_layout_getLayers: invalid argument\n");
+ return -1;
+ }
+
+ length = wl_list_length(&layout->list_layer);
+
+ if (length != 0){
+ /* the Array must be free by module which called this function */
+ *ppArray = calloc(length, sizeof(weston_layout_layer_ptr));
+ if (*ppArray == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ wl_list_for_each(ivilayer, &layout->list_layer, link) {
+ (*ppArray)[n++] = ivilayer;
+ }
+ }
+
+ *pLength = length;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_getLayersOnScreen(struct weston_layout_screen *iviscrn,
+ uint32_t *pLength,
+ weston_layout_layer_ptr **ppArray)
+{
+ struct weston_layout_layer *ivilayer = NULL;
+ uint32_t length = 0;
+ uint32_t n = 0;
+
+ if (iviscrn == NULL || pLength == NULL || ppArray == NULL) {
+ weston_log("weston_layout_getLayersOnScreen: invalid argument\n");
+ return -1;
+ }
+
+ length = wl_list_length(&iviscrn->order.list_layer);
+
+ if (length != 0){
+ /* the Array must be free by module which called this function */
+ *ppArray = calloc(length, sizeof(weston_layout_layer_ptr));
+ if (*ppArray == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ wl_list_for_each(ivilayer, &iviscrn->order.list_layer, link) {
+ (*ppArray)[n++] = ivilayer;
+ }
+ }
+
+ *pLength = length;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_getLayersUnderSurface(struct weston_layout_surface *ivisurf,
+ uint32_t *pLength,
+ weston_layout_layer_ptr **ppArray)
+{
+ struct link_layer *link_layer = NULL;
+ uint32_t length = 0;
+ uint32_t n = 0;
+
+ if (ivisurf == NULL || pLength == NULL || ppArray == NULL) {
+ weston_log("weston_layout_getLayers: invalid argument\n");
+ return -1;
+ }
+
+ length = wl_list_length(&ivisurf->list_layer);
+
+ if (length != 0){
+ /* the Array must be free by module which called this function */
+ *ppArray = calloc(length, sizeof(weston_layout_layer_ptr));
+ if (*ppArray == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ wl_list_for_each(link_layer, &ivisurf->list_layer, link) {
+ (*ppArray)[n++] = link_layer->ivilayer;
+ }
+ }
+
+ *pLength = length;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_getSurfaces(uint32_t *pLength, weston_layout_surface_ptr **ppArray)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_layout_surface *ivisurf = NULL;
+ uint32_t length = 0;
+ uint32_t n = 0;
+
+ if (pLength == NULL || ppArray == NULL) {
+ weston_log("weston_layout_getSurfaces: invalid argument\n");
+ return -1;
+ }
+
+ length = wl_list_length(&layout->list_surface);
+
+ if (length != 0){
+ /* the Array must be free by module which called this function */
+ *ppArray = calloc(length, sizeof(weston_layout_surface_ptr));
+ if (*ppArray == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ wl_list_for_each(ivisurf, &layout->list_surface, link) {
+ (*ppArray)[n++] = ivisurf;
+ }
+ }
+
+ *pLength = length;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_getSurfacesOnLayer(struct weston_layout_layer *ivilayer,
+ uint32_t *pLength,
+ weston_layout_surface_ptr **ppArray)
+{
+ struct weston_layout_surface *ivisurf = NULL;
+ uint32_t length = 0;
+ uint32_t n = 0;
+
+ if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
+ weston_log("weston_layout_getSurfaceIDsOnLayer: invalid argument\n");
+ return -1;
+ }
+
+ length = wl_list_length(&ivilayer->order.list_surface);
+
+ if (length != 0) {
+ /* the Array must be free by module which called this function */
+ *ppArray = calloc(length, sizeof(weston_layout_surface_ptr));
+ if (*ppArray == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ wl_list_for_each(ivisurf, &ivilayer->order.list_surface, link) {
+ (*ppArray)[n++] = ivisurf;
+ }
+ }
+
+ *pLength = length;
+
+ return 0;
+}
+
+WL_EXPORT struct weston_layout_layer *
+weston_layout_layerCreateWithDimension(uint32_t id_layer,
+ uint32_t width, uint32_t height)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_layout_layer *ivilayer = NULL;
+ struct link_layerCreateNotification *notification = NULL;
+
+ ivilayer = get_layer(&layout->list_layer, id_layer);
+ if (ivilayer != NULL) {
+ weston_log("id_layer is already created\n");
+ return ivilayer;
+ }
+
+ ivilayer = calloc(1, sizeof *ivilayer);
+ if (ivilayer == NULL) {
+ weston_log("fails to allocate memory\n");
+ return NULL;
+ }
+
+ wl_list_init(&ivilayer->link);
+ wl_list_init(&ivilayer->list_notification);
+ wl_list_init(&ivilayer->list_screen);
+ ivilayer->layout = layout;
+ ivilayer->id_layer = id_layer;
+
+ init_layerProperties(&ivilayer->prop, width, height);
+ ivilayer->event_mask = 0;
+
+ wl_list_init(&ivilayer->pending.list_surface);
+ wl_list_init(&ivilayer->pending.link);
+ ivilayer->pending.prop = ivilayer->prop;
+
+ wl_list_init(&ivilayer->order.list_surface);
+ wl_list_init(&ivilayer->order.link);
+
+ wl_list_insert(&layout->list_layer, &ivilayer->link);
+
+ wl_list_for_each(notification,
+ &layout->layer_notification.list_create, link) {
+ if (notification->callback != NULL) {
+ notification->callback(ivilayer, notification->userdata);
+ }
+ }
+
+ return ivilayer;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerRemove(struct weston_layout_layer *ivilayer)
+{
+ struct weston_layout *layout = get_instance();
+ struct link_layerRemoveNotification *notification = NULL;
+
+ if (ivilayer == NULL) {
+ weston_log("weston_layout_layerRemove: invalid argument\n");
+ return -1;
+ }
+
+ wl_list_for_each(notification,
+ &layout->layer_notification.list_remove, link) {
+ if (notification->callback != NULL) {
+ notification->callback(ivilayer, notification->userdata);
+ }
+ }
+
+ if (!wl_list_empty(&ivilayer->pending.link)) {
+ wl_list_remove(&ivilayer->pending.link);
+ }
+ if (!wl_list_empty(&ivilayer->order.link)) {
+ wl_list_remove(&ivilayer->order.link);
+ }
+ if (!wl_list_empty(&ivilayer->link)) {
+ wl_list_remove(&ivilayer->link);
+ }
+ remove_orderlayer_from_screen(ivilayer);
+
+ free(ivilayer);
+ ivilayer = NULL;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerGetType(struct weston_layout_layer *ivilayer,
+ uint32_t *pLayerType)
+{
+ /* not supported */
+ (void)ivilayer;
+ (void)pLayerType;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerSetVisibility(struct weston_layout_layer *ivilayer,
+ uint32_t newVisibility)
+{
+ struct weston_layout_LayerProperties *prop = NULL;
+
+ if (ivilayer == NULL) {
+ weston_log("weston_layout_layerSetVisibility: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivilayer->pending.prop;
+ prop->visibility = newVisibility;
+
+ ivilayer->event_mask |= IVI_NOTIFICATION_VISIBILITY;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerGetVisibility(struct weston_layout_layer *ivilayer, uint32_t *pVisibility)
+{
+ if (ivilayer == NULL || pVisibility == NULL) {
+ weston_log("weston_layout_layerGetVisibility: invalid argument\n");
+ return -1;
+ }
+
+ *pVisibility = ivilayer->prop.visibility;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerSetOpacity(struct weston_layout_layer *ivilayer,
+ float opacity)
+{
+ struct weston_layout_LayerProperties *prop = NULL;
+
+ if (ivilayer == NULL) {
+ weston_log("weston_layout_layerSetOpacity: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivilayer->pending.prop;
+ prop->opacity = opacity;
+
+ ivilayer->event_mask |= IVI_NOTIFICATION_OPACITY;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerGetOpacity(struct weston_layout_layer *ivilayer,
+ float *pOpacity)
+{
+ if (ivilayer == NULL || pOpacity == NULL) {
+ weston_log("weston_layout_layerGetOpacity: invalid argument\n");
+ return -1;
+ }
+
+ *pOpacity = ivilayer->prop.opacity;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerSetSourceRectangle(struct weston_layout_layer *ivilayer,
+ uint32_t x, uint32_t y,
+ uint32_t width, uint32_t height)
+{
+ struct weston_layout_LayerProperties *prop = NULL;
+
+ if (ivilayer == NULL) {
+ weston_log("weston_layout_layerSetSourceRectangle: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivilayer->pending.prop;
+ prop->sourceX = x;
+ prop->sourceY = y;
+ prop->sourceWidth = width;
+ prop->sourceHeight = height;
+
+ ivilayer->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerSetDestinationRectangle(struct weston_layout_layer *ivilayer,
+ int32_t x, int32_t y,
+ uint32_t width, uint32_t height)
+{
+ struct weston_layout_LayerProperties *prop = NULL;
+
+ if (ivilayer == NULL) {
+ weston_log("weston_layout_layerSetDestinationRectangle: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivilayer->pending.prop;
+ prop->destX = x;
+ prop->destY = y;
+ prop->destWidth = width;
+ prop->destHeight = height;
+
+ ivilayer->event_mask |= IVI_NOTIFICATION_DEST_RECT;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerGetDimension(struct weston_layout_layer *ivilayer,
+ uint32_t *pDimension)
+{
+ if (ivilayer == NULL || &pDimension[0] == NULL || &pDimension[1] == NULL) {
+ weston_log("weston_layout_layerGetDimension: invalid argument\n");
+ return -1;
+ }
+
+ pDimension[0] = ivilayer->prop.destX;
+ pDimension[1] = ivilayer->prop.destY;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerSetDimension(struct weston_layout_layer *ivilayer,
+ uint32_t *pDimension)
+{
+ struct weston_layout_LayerProperties *prop = NULL;
+
+ if (ivilayer == NULL || &pDimension[0] == NULL || &pDimension[1] == NULL) {
+ weston_log("weston_layout_layerSetDimension: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivilayer->pending.prop;
+
+ prop->destWidth = pDimension[0];
+ prop->destHeight = pDimension[1];
+
+ ivilayer->event_mask |= IVI_NOTIFICATION_DIMENSION;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerGetPosition(struct weston_layout_layer *ivilayer, int32_t *pPosition)
+{
+ if (ivilayer == NULL || pPosition == NULL) {
+ weston_log("weston_layout_layerGetPosition: invalid argument\n");
+ return -1;
+ }
+
+ pPosition[0] = ivilayer->prop.destX;
+ pPosition[1] = ivilayer->prop.destY;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerSetPosition(struct weston_layout_layer *ivilayer, int32_t *pPosition)
+{
+ struct weston_layout_LayerProperties *prop = NULL;
+
+ if (ivilayer == NULL || pPosition == NULL) {
+ weston_log("weston_layout_layerSetPosition: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivilayer->pending.prop;
+ prop->destX = pPosition[0];
+ prop->destY = pPosition[1];
+
+ ivilayer->event_mask |= IVI_NOTIFICATION_POSITION;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerSetOrientation(struct weston_layout_layer *ivilayer,
+ uint32_t orientation)
+{
+ struct weston_layout_LayerProperties *prop = NULL;
+
+ if (ivilayer == NULL) {
+ weston_log("weston_layout_layerSetOrientation: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivilayer->pending.prop;
+ prop->orientation = orientation;
+
+ ivilayer->event_mask |= IVI_NOTIFICATION_ORIENTATION;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerGetOrientation(struct weston_layout_layer *ivilayer,
+ uint32_t *pOrientation)
+{
+ if (ivilayer == NULL || pOrientation == NULL) {
+ weston_log("weston_layout_layerGetOrientation: invalid argument\n");
+ return -1;
+ }
+
+ *pOrientation = ivilayer->prop.orientation;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerSetChromaKey(struct weston_layout_layer *ivilayer, uint32_t* pColor)
+{
+ /* not supported */
+ (void)ivilayer;
+ (void)pColor;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerSetRenderOrder(struct weston_layout_layer *ivilayer,
+ struct weston_layout_surface **pSurface,
+ uint32_t number)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_layout_surface *ivisurf = NULL;
+ uint32_t *id_surface = NULL;
+ uint32_t i = 0;
+
+ if (ivilayer == NULL) {
+ weston_log("weston_layout_layerSetRenderOrder: invalid argument\n");
+ return -1;
+ }
+
+ wl_list_init(&ivilayer->pending.list_surface);
+
+ if (pSurface == NULL) {
+ return 0;
+ }
+
+ for (i = 0; i < number; i++) {
+ id_surface = &pSurface[i]->id_surface;
+
+ wl_list_for_each(ivisurf, &layout->list_surface, link) {
+ if (*id_surface != ivisurf->id_surface) {
+ continue;
+ }
+
+ if (!wl_list_empty(&ivisurf->pending.link)) {
+ wl_list_remove(&ivisurf->pending.link);
+ }
+ wl_list_init(&ivisurf->pending.link);
+ wl_list_insert(&ivilayer->pending.list_surface,
+ &ivisurf->pending.link);
+ break;
+ }
+ }
+
+ ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerGetCapabilities(struct weston_layout_layer *ivilayer,
+ uint32_t *pCapabilities)
+{
+ /* not supported */
+ (void)ivilayer;
+ (void)pCapabilities;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerTypeGetCapabilities(uint32_t layerType,
+ uint32_t *pCapabilities)
+{
+ /* not supported */
+ (void)layerType;
+ (void)pCapabilities;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceSetVisibility(struct weston_layout_surface *ivisurf,
+ uint32_t newVisibility)
+{
+ struct weston_layout_SurfaceProperties *prop = NULL;
+
+ if (ivisurf == NULL) {
+ weston_log("weston_layout_surfaceSetVisibility: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivisurf->pending.prop;
+ prop->visibility = newVisibility;
+
+ ivisurf->event_mask |= IVI_NOTIFICATION_VISIBILITY;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceGetVisibility(struct weston_layout_surface *ivisurf,
+ uint32_t *pVisibility)
+{
+ if (ivisurf == NULL || pVisibility == NULL) {
+ weston_log("weston_layout_surfaceGetVisibility: invalid argument\n");
+ return -1;
+ }
+
+ *pVisibility = ivisurf->prop.visibility;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceSetOpacity(struct weston_layout_surface *ivisurf,
+ float opacity)
+{
+ struct weston_layout_SurfaceProperties *prop = NULL;
+
+ if (ivisurf == NULL) {
+ weston_log("weston_layout_surfaceSetOpacity: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivisurf->pending.prop;
+ prop->opacity = opacity;
+
+ ivisurf->event_mask |= IVI_NOTIFICATION_OPACITY;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceGetOpacity(struct weston_layout_surface *ivisurf,
+ float *pOpacity)
+{
+ if (ivisurf == NULL || pOpacity == NULL) {
+ weston_log("weston_layout_surfaceGetOpacity: invalid argument\n");
+ return -1;
+ }
+
+ *pOpacity = ivisurf->prop.opacity;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_SetKeyboardFocusOn(struct weston_layout_surface *ivisurf)
+{
+ /* not supported */
+ (void)ivisurf;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_GetKeyboardFocusSurfaceId(struct weston_layout_surface **pSurfaceId)
+{
+ /* not supported */
+ (void)pSurfaceId;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceSetDestinationRectangle(struct weston_layout_surface *ivisurf,
+ int32_t x, int32_t y,
+ uint32_t width, uint32_t height)
+{
+ struct weston_layout_SurfaceProperties *prop = NULL;
+
+ if (ivisurf == NULL) {
+ weston_log("weston_layout_surfaceSetDestinationRectangle: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivisurf->pending.prop;
+ prop->destX = x;
+ prop->destY = y;
+ prop->destWidth = width;
+ prop->destHeight = height;
+
+ ivisurf->event_mask |= IVI_NOTIFICATION_DEST_RECT;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceSetDimension(struct weston_layout_surface *ivisurf, uint32_t *pDimension)
+{
+ struct weston_layout_SurfaceProperties *prop = NULL;
+
+ if (ivisurf == NULL || &pDimension[0] == NULL || &pDimension[1] == NULL) {
+ weston_log("weston_layout_surfaceSetDimension: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivisurf->pending.prop;
+ prop->destWidth = pDimension[0];
+ prop->destHeight = pDimension[1];
+
+ ivisurf->event_mask |= IVI_NOTIFICATION_DIMENSION;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceGetDimension(struct weston_layout_surface *ivisurf,
+ uint32_t *pDimension)
+{
+ if (ivisurf == NULL || &pDimension[0] == NULL || &pDimension[1] == NULL) {
+ weston_log("weston_layout_surfaceGetDimension: invalid argument\n");
+ return -1;
+ }
+
+ pDimension[0] = ivisurf->prop.destWidth;
+ pDimension[1] = ivisurf->prop.destHeight;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceSetPosition(struct weston_layout_surface *ivisurf,
+ int32_t *pPosition)
+{
+ struct weston_layout_SurfaceProperties *prop = NULL;
+
+ if (ivisurf == NULL || pPosition == NULL) {
+ weston_log("weston_layout_surfaceSetPosition: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivisurf->pending.prop;
+ prop->destX = pPosition[0];
+ prop->destY = pPosition[1];
+
+ ivisurf->event_mask |= IVI_NOTIFICATION_POSITION;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceGetPosition(struct weston_layout_surface *ivisurf,
+ int32_t *pPosition)
+{
+ if (ivisurf == NULL || pPosition == NULL) {
+ weston_log("weston_layout_surfaceGetPosition: invalid argument\n");
+ return -1;
+ }
+
+ pPosition[0] = ivisurf->prop.destX;
+ pPosition[1] = ivisurf->prop.destY;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceSetOrientation(struct weston_layout_surface *ivisurf,
+ uint32_t orientation)
+{
+ struct weston_layout_SurfaceProperties *prop = NULL;
+
+ if (ivisurf == NULL) {
+ weston_log("weston_layout_surfaceSetOrientation: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivisurf->pending.prop;
+ prop->orientation = orientation;
+
+ ivisurf->event_mask |= IVI_NOTIFICATION_ORIENTATION;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceGetOrientation(struct weston_layout_surface *ivisurf,
+ uint32_t *pOrientation)
+{
+ if (ivisurf == NULL || pOrientation == NULL) {
+ weston_log("weston_layout_surfaceGetOrientation: invalid argument\n");
+ return -1;
+ }
+
+ *pOrientation = ivisurf->prop.orientation;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceGetPixelformat(struct weston_layout_layer *ivisurf, uint32_t *pPixelformat)
+{
+ /* not supported */
+ (void)ivisurf;
+ (void)pPixelformat;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceSetChromaKey(struct weston_layout_surface *ivisurf, uint32_t* pColor)
+{
+ /* not supported */
+ (void)ivisurf;
+ (void)pColor;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_screenAddLayer(struct weston_layout_screen *iviscrn,
+ struct weston_layout_layer *addlayer)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_layout_layer *ivilayer = NULL;
+ struct weston_layout_layer *next = NULL;
+ int is_layer_in_scrn = 0;
+
+ if (iviscrn == NULL || addlayer == NULL) {
+ weston_log("weston_layout_screenAddLayer: invalid argument\n");
+ return -1;
+ }
+
+ is_layer_in_scrn = is_layer_in_screen(addlayer, iviscrn);
+ if (is_layer_in_scrn == 1) {
+ weston_log("weston_layout_screenAddLayer: addlayer is already available\n");
+ return 0;
+ }
+
+ wl_list_for_each_safe(ivilayer, next, &layout->list_layer, link) {
+ if (ivilayer->id_layer == addlayer->id_layer) {
+ if (!wl_list_empty(&ivilayer->pending.link)) {
+ wl_list_remove(&ivilayer->pending.link);
+ }
+ wl_list_init(&ivilayer->pending.link);
+ wl_list_insert(&iviscrn->pending.list_layer,
+ &ivilayer->pending.link);
+ break;
+ }
+ }
+
+ iviscrn->event_mask |= IVI_NOTIFICATION_ADD;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_screenSetRenderOrder(struct weston_layout_screen *iviscrn,
+ struct weston_layout_layer **pLayer,
+ const uint32_t number)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_layout_layer *ivilayer = NULL;
+ uint32_t *id_layer = NULL;
+ uint32_t i = 0;
+
+ if (iviscrn == NULL) {
+ weston_log("weston_layout_screenSetRenderOrder: invalid argument\n");
+ return -1;
+ }
+
+ wl_list_init(&iviscrn->pending.list_layer);
+
+ if (pLayer == NULL) {
+ return 0;
+ }
+
+ for (i = 0; i < number; i++) {
+ id_layer = &pLayer[i]->id_layer;
+ wl_list_for_each(ivilayer, &layout->list_layer, link) {
+ if (*id_layer == ivilayer->id_layer) {
+ continue;
+ }
+
+ if (!wl_list_empty(&ivilayer->pending.link)) {
+ wl_list_remove(&ivilayer->pending.link);
+ }
+ wl_list_init(&ivilayer->pending.link);
+ wl_list_insert(&iviscrn->pending.list_layer,
+ &ivilayer->pending.link);
+ break;
+ }
+ }
+
+ iviscrn->event_mask |= IVI_NOTIFICATION_ADD;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_takeScreenshot(struct weston_layout_screen *iviscrn,
+ const char *filename)
+{
+ struct weston_output *output = NULL;
+ cairo_surface_t *cairo_surf = NULL;
+ int32_t i = 0;
+ int32_t width = 0;
+ int32_t height = 0;
+ int32_t stride = 0;
+ uint8_t *readpixs = NULL;
+ uint8_t *writepixs = NULL;
+ uint8_t *d = NULL;
+ uint8_t *s = NULL;
+
+ if (iviscrn == NULL || filename == NULL) {
+ weston_log("weston_layout_takeScreenshot: invalid argument\n");
+ return -1;
+ }
+
+ output = iviscrn->output;
+ output->disable_planes--;
+
+ width = output->current_mode->width;
+ height = output->current_mode->height;
+ stride = width * (PIXMAN_FORMAT_BPP(output->compositor->read_format) / 8);
+
+ readpixs = malloc(stride * height);
+ if (readpixs == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+ writepixs = malloc(stride * height);
+ if (writepixs == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ output->compositor->renderer->read_pixels(output,
+ output->compositor->read_format, readpixs,
+ 0, 0, width, height);
+
+ s = readpixs;
+ d = writepixs + stride * (height - 1);
+
+ for (i = 0; i < height; i++) {
+ memcpy(d, s, stride);
+ d -= stride;
+ s += stride;
+ }
+
+ cairo_surf = cairo_image_surface_create_for_data(writepixs,
+ CAIRO_FORMAT_ARGB32,
+ width, height, stride);
+ cairo_surface_write_to_png(cairo_surf, filename);
+ cairo_surface_destroy(cairo_surf);
+ free(writepixs);
+ free(readpixs);
+ writepixs = NULL;
+ readpixs = NULL;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_takeLayerScreenshot(const char *filename, struct weston_layout_layer *ivilayer)
+{
+ /* not supported */
+ (void)filename;
+ (void)ivilayer;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_takeSurfaceScreenshot(const char *filename,
+ struct weston_layout_surface *ivisurf)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_compositor *ec = layout->compositor;
+ cairo_surface_t *cairo_surf;
+ int32_t width;
+ int32_t height;
+ int32_t stride;
+ uint8_t *pixels;
+
+ if (filename == NULL || ivisurf == NULL) {
+ weston_log("weston_layout_takeSurfaceScreenshot: invalid argument\n");
+ return -1;
+ }
+
+ width = ivisurf->prop.destWidth;
+ height = ivisurf->prop.destHeight;
+ stride = width * (PIXMAN_FORMAT_BPP(ec->read_format) / 8);
+
+ pixels = malloc(stride * height);
+ if (pixels == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ ec->renderer->read_surface_pixels(ivisurf->surface,
+ ec->read_format, pixels,
+ 0, 0, width, height);
+
+ cairo_surf = cairo_image_surface_create_for_data(pixels,
+ CAIRO_FORMAT_ARGB32,
+ width, height, stride);
+ cairo_surface_write_to_png(cairo_surf, filename);
+ cairo_surface_destroy(cairo_surf);
+
+ free(pixels);
+ pixels = NULL;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_SetOptimizationMode(uint32_t id, uint32_t mode)
+{
+ /* not supported */
+ (void)id;
+ (void)mode;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_GetOptimizationMode(uint32_t id, uint32_t *pMode)
+{
+ /* not supported */
+ (void)id;
+ (void)pMode;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerAddNotification(struct weston_layout_layer *ivilayer,
+ layerPropertyNotificationFunc callback,
+ void *userdata)
+{
+ struct link_layerPropertyNotification *notification = NULL;
+
+ if (ivilayer == NULL || callback == NULL) {
+ weston_log("weston_layout_layerAddNotification: invalid argument\n");
+ return -1;
+ }
+
+ notification = malloc(sizeof *notification);
+ if (notification == NULL) {
+ weston_log("fails to allocate memory\n");
+ return -1;
+ }
+
+ notification->callback = callback;
+ notification->userdata = userdata;
+ wl_list_init(¬ification->link);
+ wl_list_insert(&ivilayer->list_notification, ¬ification->link);
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerRemoveNotification(struct weston_layout_layer *ivilayer)
+{
+ struct link_layerPropertyNotification *notification = NULL;
+ struct link_layerPropertyNotification *next = NULL;
+
+ if (ivilayer == NULL) {
+ weston_log("weston_layout_layerRemoveNotification: invalid argument\n");
+ return -1;
+ }
+
+ wl_list_for_each_safe(notification, next,
+ &ivilayer->list_notification, link) {
+ if (!wl_list_empty(¬ification->link)) {
+ wl_list_remove(¬ification->link);
+ }
+ free(notification);
+ notification = NULL;
+ }
+ wl_list_init(&ivilayer->list_notification);
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_getPropertiesOfSurface(struct weston_layout_surface *ivisurf,
+ struct weston_layout_SurfaceProperties *pSurfaceProperties)
+{
+ if (ivisurf == NULL || pSurfaceProperties == NULL) {
+ weston_log("weston_layout_getPropertiesOfSurface: invalid argument\n");
+ return -1;
+ }
+
+ *pSurfaceProperties = ivisurf->prop;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerAddSurface(struct weston_layout_layer *ivilayer,
+ struct weston_layout_surface *addsurf)
+{
+ struct weston_layout *layout = get_instance();
+ struct weston_layout_surface *ivisurf = NULL;
+ struct weston_layout_surface *next = NULL;
+ int is_surf_in_layer = 0;
+
+ if (ivilayer == NULL || addsurf == NULL) {
+ weston_log("weston_layout_layerAddSurface: invalid argument\n");
+ return -1;
+ }
+
+ is_surf_in_layer = is_surface_in_layer(addsurf, ivilayer);
+ if (is_surf_in_layer == 1) {
+ weston_log("weston_layout_layerAddSurface: addsurf is already available\n");
+ return 0;
+ }
+
+ wl_list_for_each_safe(ivisurf, next, &layout->list_surface, link) {
+ if (ivisurf->id_surface == addsurf->id_surface) {
+ if (!wl_list_empty(&ivisurf->pending.link)) {
+ wl_list_remove(&ivisurf->pending.link);
+ }
+ wl_list_init(&ivisurf->pending.link);
+ wl_list_insert(&ivilayer->pending.list_surface,
+ &ivisurf->pending.link);
+ break;
+ }
+ }
+
+ ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_layerRemoveSurface(struct weston_layout_layer *ivilayer,
+ struct weston_layout_surface *remsurf)
+{
+ struct weston_layout_surface *ivisurf = NULL;
+ struct weston_layout_surface *next = NULL;
+
+ if (ivilayer == NULL || remsurf == NULL) {
+ weston_log("weston_layout_layerRemoveSurface: invalid argument\n");
+ return -1;
+ }
+
+ wl_list_for_each_safe(ivisurf, next,
+ &ivilayer->pending.list_surface, pending.link) {
+ if (ivisurf->id_surface == remsurf->id_surface) {
+ if (!wl_list_empty(&ivisurf->pending.link)) {
+ wl_list_remove(&ivisurf->pending.link);
+ }
+ wl_list_init(&ivisurf->pending.link);
+ break;
+ }
+ }
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_surfaceSetSourceRectangle(struct weston_layout_surface *ivisurf,
+ uint32_t x, uint32_t y,
+ uint32_t width, uint32_t height)
+{
+ struct weston_layout_SurfaceProperties *prop = NULL;
+
+ if (ivisurf == NULL) {
+ weston_log("weston_layout_surfaceSetSourceRectangle: invalid argument\n");
+ return -1;
+ }
+
+ prop = &ivisurf->pending.prop;
+ prop->sourceX = x;
+ prop->sourceY = y;
+ prop->sourceWidth = width;
+ prop->sourceHeight = height;
+
+ ivisurf->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+weston_layout_commitChanges(void)
+{
+ struct weston_layout *layout = get_instance();
+
+ commit_list_surface(layout);
+ commit_list_layer(layout);
+ commit_list_screen(layout);
+
+ commit_changes(layout);
+ send_prop(layout);
+ weston_compositor_schedule_repaint(layout->compositor);
+
+ return 0;
+}
diff --git a/ivi-shell/weston-layout.h b/ivi-shell/weston-layout.h
new file mode 100644
index 0000000..871fea1
--- /dev/null
+++ b/ivi-shell/weston-layout.h
@@ -0,0 +1,920 @@
+/*
+ * Copyright (C) 2013 DENSO CORPORATION
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * The weston-layout library supports API set of controlling properties of
+ * surface and layer which groups surfaces. An unique ID whose type is integer
+ * is required to create surface and layer. With the unique ID, surface and
+ * layer are identified to control them. The API set consists of APIs to control
+ * properties of surface and layers about followings,
+ * - visibility.
+ * - opacity.
+ * - clipping (x,y,width,height).
+ * - position and size of it to be displayed.
+ * - orientation per 90 degree.
+ * - add or remove surfaces to a layer.
+ * - order of surfaces/layers in layer/screen to be displayed.
+ * - commit to apply property changes.
+ * - notifications of property change.
+ *
+ * Management of surfaces and layers grouping these surfaces are common way in
+ * In-Vehicle Infotainment system, which integrate several domains in one system.
+ * A layer is allocated to a domain in order to control application surfaces
+ * grouped to the layer all together.
+ */
+
+#ifndef _WESTON_LAYOUT_H_
+#define _WESTON_LAYOUT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "compositor.h"
+
+struct weston_layout_SurfaceProperties
+{
+ float opacity;
+ uint32_t sourceX;
+ uint32_t sourceY;
+ uint32_t sourceWidth;
+ uint32_t sourceHeight;
+ uint32_t origSourceWidth;
+ uint32_t origSourceHeight;
+ int32_t destX;
+ int32_t destY;
+ uint32_t destWidth;
+ uint32_t destHeight;
+ uint32_t orientation;
+ uint32_t visibility;
+ uint32_t frameCounter;
+ uint32_t drawCounter;
+ uint32_t updateCounter;
+ uint32_t pixelformat;
+ uint32_t nativeSurface;
+ uint32_t inputDevicesAcceptance;
+ uint32_t chromaKeyEnabled;
+ uint32_t chromaKeyRed;
+ uint32_t chromaKeyGreen;
+ uint32_t chromaKeyBlue;
+ int32_t creatorPid;
+};
+
+struct weston_layout_LayerProperties
+{
+ float opacity;
+ uint32_t sourceX;
+ uint32_t sourceY;
+ uint32_t sourceWidth;
+ uint32_t sourceHeight;
+ uint32_t origSourceWidth;
+ uint32_t origSourceHeight;
+ int32_t destX;
+ int32_t destY;
+ uint32_t destWidth;
+ uint32_t destHeight;
+ uint32_t orientation;
+ uint32_t visibility;
+ uint32_t type;
+ uint32_t chromaKeyEnabled;
+ uint32_t chromaKeyRed;
+ uint32_t chromaKeyGreen;
+ uint32_t chromaKeyBlue;
+ int32_t creatorPid;
+};
+
+struct weston_layout_layer;
+struct weston_layout_surface;
+struct weston_layout_screen;
+
+typedef struct weston_layout_surface* weston_layout_surface_ptr;
+typedef struct weston_layout_layer* weston_layout_layer_ptr;
+typedef struct weston_layout_screen* weston_layout_screen_ptr;
+
+#define IVI_BIT(x) (1 << (x))
+enum weston_layout_notification_mask {
+ IVI_NOTIFICATION_OPACITY = IVI_BIT(1),
+ IVI_NOTIFICATION_SOURCE_RECT = IVI_BIT(2),
+ IVI_NOTIFICATION_DEST_RECT = IVI_BIT(3),
+ IVI_NOTIFICATION_DIMENSION = IVI_BIT(4),
+ IVI_NOTIFICATION_POSITION = IVI_BIT(5),
+ IVI_NOTIFICATION_ORIENTATION = IVI_BIT(6),
+ IVI_NOTIFICATION_VISIBILITY = IVI_BIT(7),
+ IVI_NOTIFICATION_PIXELFORMAT = IVI_BIT(8),
+ IVI_NOTIFICATION_ADD = IVI_BIT(9),
+ IVI_NOTIFICATION_ALL = 0xFFFF
+};
+
+typedef void(*layerPropertyNotificationFunc)(struct weston_layout_layer *ivilayer,
+ struct weston_layout_LayerProperties*,
+ enum weston_layout_notification_mask mask,
+ void *userdata);
+
+typedef void(*surfacePropertyNotificationFunc)(struct weston_layout_surface *ivisurf,
+ struct weston_layout_SurfaceProperties*,
+ enum weston_layout_notification_mask mask,
+ void *userdata);
+
+typedef void(*layerCreateNotificationFunc)(struct weston_layout_layer *ivilayer,
+ void *userdata);
+
+typedef void(*layerRemoveNotificationFunc)(struct weston_layout_layer *ivilayer,
+ void *userdata);
+
+typedef void(*surfaceCreateNotificationFunc)(struct weston_layout_surface *ivisurf,
+ void *userdata);
+
+typedef void(*surfaceRemoveNotificationFunc)(struct weston_layout_surface *ivisurf,
+ void *userdata);
+
+typedef void(*surfaceConfigureNotificationFunc)(struct weston_layout_surface *ivisurf,
+ void *userdata);
+
+/**
+ * \brief to be called by ivi-shell in order to set initail view of
+ * weston_surface.
+ */
+struct weston_view *
+weston_layout_get_weston_view(struct weston_layout_surface *surface);
+
+/**
+ * \brief initialize weston-layout
+ */
+void
+weston_layout_initWithCompositor(struct weston_compositor *ec);
+
+/**
+ * \brief register for notification when layer is created
+ */
+int32_t
+weston_layout_setNotificationCreateLayer(layerCreateNotificationFunc callback,
+ void *userdata);
+
+/**
+ * \brief register for notification when layer is removed
+ */
+int32_t
+weston_layout_setNotificationRemoveLayer(layerRemoveNotificationFunc callback,
+ void *userdata);
+
+/**
+ * \brief register for notification when surface is created
+ */
+int32_t
+weston_layout_setNotificationCreateSurface(surfaceCreateNotificationFunc callback,
+ void *userdata);
+
+/**
+ * \brief register for notification when surface is removed
+ */
+int32_t
+weston_layout_setNotificationRemoveSurface(surfaceRemoveNotificationFunc callback,
+ void *userdata);
+
+/**
+ * \brief register for notification when surface is configured
+ */
+int32_t
+weston_layout_setNotificationConfigureSurface(surfaceConfigureNotificationFunc callback,
+ void *userdata);
+
+/**
+ * \brief get id of surface from weston_layout_surface
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+uint32_t
+weston_layout_getIdOfSurface(struct weston_layout_surface *ivisurf);
+
+/**
+ * \brief get id of layer from weston_layout_layer
+ *
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+uint32_t
+weston_layout_getIdOfLayer(struct weston_layout_layer *ivilayer);
+
+/**
+ * \brief get weston_layout_layer from id of layer
+ *
+ * \return (struct weston_layout_layer *)
+ * if the method call was successful
+ * \return NULL if the client can not call the method on the service.
+ */
+struct weston_layout_layer *
+weston_layout_getLayerFromId(uint32_t id_layer);
+
+/**
+ * \brief get weston_layout_surface from id of surface
+ *
+ * \return (struct weston_layout_surface *)
+ * if the method call was successful
+ * \return NULL if the client can not call the method on the service.
+ */
+struct weston_layout_surface *
+weston_layout_getSurfaceFromId(uint32_t id_surface);
+
+/**
+ * \brief get weston_layout_screen from id of screen
+ *
+ * \return (struct weston_layout_screen *)
+ * if the method call was successful
+ * \return NULL if the client can not call the method on the service.
+ */
+struct weston_layout_screen *
+weston_layout_getScreenFromId(uint32_t id_screen);
+
+/**
+ * \brief Get the screen resolution of a specific screen
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_getScreenResolution(struct weston_layout_screen *iviscrn,
+ uint32_t *pWidth,
+ uint32_t *pHeight);
+
+/**
+ * \brief register for notification on property changes of surface
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceAddNotification(struct weston_layout_surface *ivisurf,
+ surfacePropertyNotificationFunc callback,
+ void *userdata);
+
+/**
+ * \brief remove notification on property changes of surface
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceRemoveNotification(struct weston_layout_surface *ivisurf);
+
+/**
+ * \brief Create a surface
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+struct weston_layout_surface *
+weston_layout_surfaceCreate(struct weston_surface *wl_surface,
+ uint32_t id_surface);
+
+/**
+ * \brief initialize weston_layout_surface dest/source width and height
+ */
+void
+weston_layout_surfaceConfigure(struct weston_layout_surface *ivisurf,
+ uint32_t width, uint32_t height);
+
+/**
+ * \brief Remove a surface
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceRemove(struct weston_layout_surface *ivisurf);
+
+/**
+ * \brief Set from which kind of devices the surface can accept input events.
+ * By default, a surface accept input events from all kind of devices (keyboards, pointer, ...)
+ * By calling this function, you can adjust surface preferences. Note that this function only
+ * adjust the acceptance for the specified devices. Non specified are keept untouched.
+ *
+ * Typicall use case for this function is when dealing with pointer or touch events.
+ * Those are normally dispatched to the first visible surface below the coordinate.
+ * If you want a different behavior (i.e. forward events to an other surface below the coordinate,
+ * you can set all above surfaces to refuse input events)
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_UpdateInputEventAcceptanceOn(struct weston_layout_surface *ivisurf,
+ uint32_t devices,
+ uint32_t acceptance);
+
+/**
+ * \brief Get the layer properties
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_getPropertiesOfLayer(struct weston_layout_layer *ivilayer,
+ struct weston_layout_LayerProperties *pLayerProperties);
+
+/**
+ * \brief Get the number of hardware layers of a screen
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_getNumberOfHardwareLayers(uint32_t id_screen,
+ uint32_t *pNumberOfHardwareLayers);
+
+/**
+ * \brief Get the screens
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_getScreens(uint32_t *pLength, weston_layout_screen_ptr **ppArray);
+
+/**
+ * \brief Get the screens under the given layer
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_getScreensUnderLayer(struct weston_layout_layer *ivilayer,
+ uint32_t *pLength,
+ weston_layout_screen_ptr **ppArray);
+
+/**
+ * \brief Get all Layers which are currently registered and managed by the services
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_getLayers(uint32_t *pLength, weston_layout_layer_ptr **ppArray);
+
+/**
+ * \brief Get all Layers of the given screen
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_getLayersOnScreen(struct weston_layout_screen *iviscrn,
+ uint32_t *pLength,
+ weston_layout_layer_ptr **ppArray);
+
+/**
+ * \brief Get all Layers under the given surface
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_getLayersUnderSurface(struct weston_layout_surface *ivisurf,
+ uint32_t *pLength,
+ weston_layout_layer_ptr **ppArray);
+
+/**
+ * \brief Get all Surfaces which are currently registered and managed by the services
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_getSurfaces(uint32_t *pLength, weston_layout_surface_ptr **ppArray);
+
+/**
+ * \brief Get all Surfaces which are currently registered to a given layer and are managed by the services
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_getSurfacesOnLayer(struct weston_layout_layer *ivilayer,
+ uint32_t *pLength,
+ weston_layout_surface_ptr **ppArray);
+
+/**
+ * \brief Create a layer which should be managed by the service
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+struct weston_layout_layer *
+weston_layout_layerCreateWithDimension(uint32_t id_layer,
+ uint32_t width, uint32_t height);
+
+/**
+ * \brief Removes a layer which is currently managed by the service
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerRemove(struct weston_layout_layer *ivilayer);
+
+/**
+ * \brief Get the current type of the layer.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerGetType(struct weston_layout_layer *ivilayer,
+ uint32_t *pLayerType);
+
+/**
+ * \brief Set the visibility of a layer. If a layer is not visible, the layer and its
+ * surfaces will not be rendered.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerSetVisibility(struct weston_layout_layer *ivilayer,
+ uint32_t newVisibility);
+
+/**
+ * \brief Get the visibility of a layer. If a layer is not visible, the layer and its
+ * surfaces will not be rendered.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerGetVisibility(struct weston_layout_layer *ivilayer,
+ uint32_t *pVisibility);
+
+/**
+ * \brief Set the opacity of a layer.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerSetOpacity(struct weston_layout_layer *ivilayer, float opacity);
+
+/**
+ * \brief Get the opacity of a layer.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerGetOpacity(struct weston_layout_layer *ivilayer, float *pOpacity);
+
+/**
+ * \brief Set the area of a layer which should be used for the rendering.
+ * Only this part will be visible.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerSetSourceRectangle(struct weston_layout_layer *ivilayer,
+ uint32_t x, uint32_t y,
+ uint32_t width, uint32_t height);
+
+/**
+ * \brief Set the destination area on the display for a layer.
+ * The layer will be scaled and positioned to this rectangle for rendering
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerSetDestinationRectangle(struct weston_layout_layer *ivilayer,
+ int32_t x, int32_t y,
+ uint32_t width, uint32_t height);
+
+/**
+ * \brief Get the horizontal and vertical dimension of the layer.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerGetDimension(struct weston_layout_layer *ivilayer,
+ uint32_t *pDimension);
+
+/**
+ * \brief Set the horizontal and vertical dimension of the layer.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerSetDimension(struct weston_layout_layer *ivilayer,
+ uint32_t *pDimension);
+
+/**
+ * \brief Get the horizontal and vertical position of the layer.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerGetPosition(struct weston_layout_layer *ivilayer,
+ int32_t *pPosition);
+
+/**
+ * \brief Sets the horizontal and vertical position of the layer.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerSetPosition(struct weston_layout_layer *ivilayer,
+ int32_t *pPosition);
+
+/**
+ * \brief Sets the orientation of a layer.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerSetOrientation(struct weston_layout_layer *ivilayer,
+ uint32_t orientation);
+
+/**
+ * \brief Gets the orientation of a layer.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerGetOrientation(struct weston_layout_layer *ivilayer,
+ uint32_t *pOrientation);
+
+/**
+ * \brief Sets the color value which defines the transparency value.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerSetChromaKey(struct weston_layout_layer *ivilayer,
+ uint32_t* pColor);
+
+/**
+ * \brief Sets render order of surfaces within one layer
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerSetRenderOrder(struct weston_layout_layer *ivilayer,
+ struct weston_layout_surface **pSurface,
+ uint32_t number);
+
+/**
+ * \brief Get the capabilities of a layer
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerGetCapabilities(struct weston_layout_layer *ivilayer,
+ uint32_t *pCapabilities);
+
+/**
+ * \brief Get the possible capabilities of a layertype
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerTypeGetCapabilities(uint32_t layerType,
+ uint32_t *pCapabilities);
+
+/**
+ * \brief Create the logical surface, which has no native buffer associated
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceInitialize(struct weston_layout_surface **pSurface);
+
+/**
+ * \brief Set the visibility of a surface.
+ * If a surface is not visible it will not be rendered.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceSetVisibility(struct weston_layout_surface *ivisurf,
+ uint32_t newVisibility);
+
+/**
+ * \brief Get the visibility of a surface.
+ * If a surface is not visible it will not be rendered.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceGetVisibility(struct weston_layout_surface *ivisurf,
+ uint32_t *pVisibility);
+
+/**
+ * \brief Set the opacity of a surface.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceSetOpacity(struct weston_layout_surface *ivisurf,
+ float opacity);
+
+/**
+ * \brief Get the opacity of a surface.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceGetOpacity(struct weston_layout_surface *ivisurf,
+ float *pOpacity);
+
+/**
+ * \brief Set the keyboard focus on a certain surface
+ * To receive keyboard events, 2 conditions must be fulfilled:
+ * 1- The surface must accept events from keyboard. See ilm_UpdateInputEventAcceptanceOn
+ * 2- The keyboard focus must be set on that surface
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_SetKeyboardFocusOn(struct weston_layout_surface *ivisurf);
+
+/**
+ * \brief Get the indentifier of the surface which hold the keyboard focus
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_GetKeyboardFocusSurfaceId(struct weston_layout_surface **pSurfaceId);
+
+/**
+ * \brief Set the destination area of a surface within a layer for rendering.
+ * The surface will be scaled to this rectangle for rendering.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceSetDestinationRectangle(struct weston_layout_surface *ivisurf,
+ int32_t x, int32_t y,
+ uint32_t width, uint32_t height);
+
+/**
+ * \brief Set the horizontal and vertical dimension of the surface.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceSetDimension(struct weston_layout_surface *ivisurf,
+ uint32_t *pDimension);
+
+/**
+ * \brief Get the horizontal and vertical dimension of the surface.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceGetDimension(struct weston_layout_surface *ivisurf,
+ uint32_t *pDimension);
+
+/**
+ * \brief Sets the horizontal and vertical position of the surface.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceSetPosition(struct weston_layout_surface *ivisurf,
+ int32_t *pPosition);
+
+/**
+ * \brief Get the horizontal and vertical position of the surface.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceGetPosition(struct weston_layout_surface *ivisurf,
+ int32_t *pPosition);
+
+/**
+ * \brief Sets the orientation of a surface.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceSetOrientation(struct weston_layout_surface *ivisurf,
+ uint32_t orientation);
+
+/**
+ * \brief Gets the orientation of a surface.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceGetOrientation(struct weston_layout_surface *ivisurf,
+ uint32_t *pOrientation);
+
+/**
+ * \brief Gets the pixelformat of a surface.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceGetPixelformat(struct weston_layout_layer *ivisurf,
+ uint32_t *pPixelformat);
+
+/**
+ * \brief Sets the color value which defines the transparency value of a surface.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceSetChromaKey(struct weston_layout_surface *ivisurf,
+ uint32_t* pColor);
+
+/**
+ * \brief Add a layer to a screen which is currently managed by the service
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_screenAddLayer(struct weston_layout_screen *iviscrn,
+ struct weston_layout_layer *addlayer);
+
+/**
+ * \brief Sets render order of layers on a display
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_screenSetRenderOrder(struct weston_layout_screen *iviscrn,
+ struct weston_layout_layer **pLayer,
+ const uint32_t number);
+
+/**
+ * \brief Take a screenshot from the current displayed layer scene.
+ * The screenshot is saved as bmp file with the corresponding filename.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_takeScreenshot(struct weston_layout_screen *iviscrn,
+ const char *filename);
+
+/**
+ * \brief Take a screenshot of a certain layer
+ * The screenshot is saved as bmp file with the corresponding filename.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_takeLayerScreenshot(const char *filename,
+ struct weston_layout_layer *ivilayer);
+
+/**
+ * \brief Take a screenshot of a certain surface
+ * The screenshot is saved as bmp file with the corresponding filename.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_takeSurfaceScreenshot(const char *filename,
+ struct weston_layout_surface *ivisurf);
+
+/**
+ * \brief Enable or disable a rendering optimization
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_SetOptimizationMode(uint32_t id, uint32_t mode);
+
+/**
+ * \brief Get the current enablement for an optimization
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_GetOptimizationMode(uint32_t id, uint32_t *pMode);
+
+/**
+ * \brief register for notification on property changes of layer
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerAddNotification(struct weston_layout_layer *ivilayer,
+ layerPropertyNotificationFunc callback,
+ void *userdata);
+
+/**
+ * \brief remove notification on property changes of layer
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerRemoveNotification(struct weston_layout_layer *ivilayer);
+
+/**
+ * \brief Get the surface properties
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_getPropertiesOfSurface(struct weston_layout_surface *ivisurf,
+ struct weston_layout_SurfaceProperties *pSurfaceProperties);
+
+/**
+ * \brief Add a surface to a layer which is currently managed by the service
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerAddSurface(struct weston_layout_layer *ivilayer,
+ struct weston_layout_surface *addsurf);
+
+/**
+ * \brief Removes a surface from a layer which is currently managed by the service
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_layerRemoveSurface(struct weston_layout_layer *ivilayer,
+ struct weston_layout_surface *remsurf);
+
+/**
+ * \brief Set the area of a surface which should be used for the rendering.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_surfaceSetSourceRectangle(struct weston_layout_surface *ivisurf,
+ uint32_t x, uint32_t y,
+ uint32_t width, uint32_t height);
+
+/**
+ * \brief Commit all changes and execute all enqueued commands since last commit.
+ *
+ * \return 0 if the method call was successful
+ * \return -1 if the client can not call the method on the service.
+ */
+int32_t
+weston_layout_commitChanges(void);
+
+#ifdef __cplusplus
+} /**/
+#endif /* __cplusplus */
+
+#endif /* _WESTON_LAYOUT_H_ */
--
1.8.3.1
More information about the wayland-devel
mailing list