blob: 8e4280ba78def32b703523481cbf546a6d0f6220 [file] [log] [blame]
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001/*
2 * Copyright (C) 2013 DENSO CORPORATION
3 *
Bryce Harringtonaf637c22015-06-11 12:55:55 -07004 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090011 *
Bryce Harringtonaf637c22015-06-11 12:55:55 -070012 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090024 */
25
26/**
27 * Implementation of ivi-layout library. The actual view on ivi_screen is
Bryce Harringtone6da35d2016-05-19 17:35:02 -070028 * not updated until ivi_layout_commit_changes is called. An overview from
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090029 * calling API for updating properties of ivi_surface/ivi_layer to asking
30 * compositor to compose them by using weston_compositor_schedule_repaint,
31 * 0/ initialize this library by ivi_layout_init_with_compositor
32 * with (struct weston_compositor *ec) from ivi-shell.
Bryce Harringtone6da35d2016-05-19 17:35:02 -070033 * 1/ When an API for updating properties of ivi_surface/ivi_layer, it updates
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090034 * pending prop of ivi_surface/ivi_layer/ivi_screen which are structure to
35 * store properties.
Bryce Harringtone6da35d2016-05-19 17:35:02 -070036 * 2/ Before calling commitChanges, in case of calling an API to get a property,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090037 * return current property, not pending property.
38 * 3/ At the timing of calling ivi_layout_commitChanges, pending properties
39 * are applied to properties.
40 *
41 * *) ivi_layout_commitChanges is also called by transition animation
42 * per each frame. See ivi-layout-transition.c in details. Transition
43 * animation interpolates frames between previous properties of ivi_surface
44 * and new ones.
Bryce Harringtone6da35d2016-05-19 17:35:02 -070045 * For example, when a property of ivi_surface is changed from invisibile
46 * to visibile, it behaves like fade-in. When ivi_layout_commitChange is
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090047 * called during transition animation, it cancels the transition and
48 * re-start transition to new properties from current properties of final
Bryce Harringtone6da35d2016-05-19 17:35:02 -070049 * frame just before the cancellation.
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090050 *
51 * 4/ According properties, set transformation by using weston_matrix and
52 * weston_view per ivi_surfaces and ivi_layers in while loop.
53 * 5/ Set damage and trigger transform by using weston_view_geometry_dirty.
54 * 6/ Notify update of properties.
55 * 7/ Trigger composition by weston_compositor_schedule_repaint.
56 *
57 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +090058#include "config.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090059
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090060#include <string.h>
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +000061#include <assert.h>
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030062#include <stdint.h>
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090063
Pekka Paalanen58f98c92016-06-03 16:45:21 +030064#include "compositor/weston.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090065#include "compositor.h"
Pekka Paalanen1f821932016-03-15 16:57:51 +020066#include "ivi-shell.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090067#include "ivi-layout-export.h"
68#include "ivi-layout-private.h"
Pekka Paalanen32ca7912016-03-15 17:21:00 +020069#include "ivi-layout-shell.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090070
Jon Cruz867d50e2015-06-15 15:37:10 -070071#include "shared/helpers.h"
Jon Cruz4678bab2015-06-15 15:37:07 -070072#include "shared/os-compatibility.h"
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +090073
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +090074#define max(a, b) ((a) > (b) ? (a) : (b))
75
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090076struct ivi_layout;
77
78struct ivi_layout_screen {
Ucan, Emre (ADITG/SW1)7da38232016-07-01 09:34:50 +000079 struct wl_list link; /* ivi_layout::screen_list */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090080
81 struct ivi_layout *layout;
82 struct weston_output *output;
83
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090084 struct {
Ucan, Emre (ADITG/SW1)7da38232016-07-01 09:34:50 +000085 struct wl_list layer_list; /* ivi_layout_layer::pending.link */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090086 } pending;
87
88 struct {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +000089 int dirty;
Ucan, Emre (ADITG/SW1)7da38232016-07-01 09:34:50 +000090 struct wl_list layer_list; /* ivi_layout_layer::order.link */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090091 } order;
92};
93
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +090094struct ivi_rectangle
95{
96 int32_t x;
97 int32_t y;
98 int32_t width;
99 int32_t height;
100};
101
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900102static struct ivi_layout ivilayout = {0};
103
104struct ivi_layout *
105get_instance(void)
106{
107 return &ivilayout;
108}
109
110/**
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700111 * Internal API to add/remove an ivi_layer to/from ivi_screen.
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900112 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900113static struct ivi_layout_surface *
114get_surface(struct wl_list *surf_list, uint32_t id_surface)
115{
116 struct ivi_layout_surface *ivisurf;
117
118 wl_list_for_each(ivisurf, surf_list, link) {
119 if (ivisurf->id_surface == id_surface) {
120 return ivisurf;
121 }
122 }
123
124 return NULL;
125}
126
127static struct ivi_layout_layer *
128get_layer(struct wl_list *layer_list, uint32_t id_layer)
129{
130 struct ivi_layout_layer *ivilayer;
131
132 wl_list_for_each(ivilayer, layer_list, link) {
133 if (ivilayer->id_layer == id_layer) {
134 return ivilayer;
135 }
136 }
137
138 return NULL;
139}
140
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000141static bool
142ivi_view_is_rendered(struct ivi_layout_view *view)
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000143{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000144 return !wl_list_empty(&view->order_link);
145}
146
147static void
148ivi_view_destroy(struct ivi_layout_view *ivi_view)
149{
150 wl_list_remove(&ivi_view->transform.link);
151 wl_list_remove(&ivi_view->link);
152 wl_list_remove(&ivi_view->surf_link);
153 wl_list_remove(&ivi_view->pending_link);
154 wl_list_remove(&ivi_view->order_link);
155
156 weston_view_destroy(ivi_view->view);
157
158 free(ivi_view);
159}
160
161static struct ivi_layout_view*
162ivi_view_create(struct ivi_layout_layer *ivilayer,
163 struct ivi_layout_surface *ivisurf)
164{
165 struct ivi_layout_view *ivi_view;
166
167 ivi_view = calloc(1, sizeof *ivi_view);
168 if (ivi_view == NULL) {
169 weston_log("fails to allocate memory\n");
170 return NULL;
171 }
172
173 ivi_view->view = weston_view_create(ivisurf->surface);
174 if (ivi_view->view == NULL) {
175 weston_log("fails to allocate memory\n");
Raúl Peñacobabd8dc0a2017-03-29 18:13:36 +0200176 free(ivi_view);
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000177 return NULL;
178 }
179
180 weston_matrix_init(&ivi_view->transform.matrix);
181 wl_list_init(&ivi_view->transform.link);
182
183 ivi_view->ivisurf = ivisurf;
184 ivi_view->on_layer = ivilayer;
185 wl_list_insert(&ivilayer->layout->view_list,
186 &ivi_view->link);
187 wl_list_insert(&ivisurf->view_list,
188 &ivi_view->surf_link);
189
190 wl_list_init(&ivi_view->pending_link);
191 wl_list_init(&ivi_view->order_link);
192
193 return ivi_view;
194}
195
196static struct ivi_layout_view *
197get_ivi_view(struct ivi_layout_layer *ivilayer,
198 struct ivi_layout_surface *ivisurf)
199{
200 struct ivi_layout_view *ivi_view;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000201
202 assert(ivisurf->surface != NULL);
203
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000204 wl_list_for_each(ivi_view, &ivisurf->view_list, surf_link) {
205 if (ivi_view->on_layer == ivilayer)
206 return ivi_view;
207 }
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000208
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000209 return NULL;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000210}
211
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +0000212static struct ivi_layout_screen *
213get_screen_from_output(struct weston_output *output)
214{
215 struct ivi_layout *layout = get_instance();
216 struct ivi_layout_screen *iviscrn = NULL;
217
218 wl_list_for_each(iviscrn, &layout->screen_list, link) {
219 if (iviscrn->output == output)
220 return iviscrn;
221 }
222
223 return NULL;
224}
225
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900226/**
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900227 * Called at destruction of wl_surface/ivi_surface
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900228 */
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900229void
230ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf)
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900231{
232 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000233 struct ivi_layout_view *ivi_view ,*next;
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900234
235 if (ivisurf == NULL) {
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900236 weston_log("%s: invalid argument\n", __func__);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900237 return;
238 }
239
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900240 wl_list_remove(&ivisurf->link);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900241
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000242 wl_list_for_each_safe(ivi_view, next, &ivisurf->view_list, surf_link) {
243 ivi_view_destroy(ivi_view);
244 }
245
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900246 wl_signal_emit(&layout->surface_notification.removed, ivisurf);
247
Mateusz Polroladada6e32016-03-09 09:13:26 +0000248 ivi_layout_remove_all_surface_transitions(ivisurf);
249
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900250 free(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900251}
252
253/**
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900254 * Internal API to initialize ivi_screens found from output_list of weston_compositor.
255 * Called by ivi_layout_init_with_compositor.
256 */
257static void
258create_screen(struct weston_compositor *ec)
259{
260 struct ivi_layout *layout = get_instance();
261 struct ivi_layout_screen *iviscrn = NULL;
262 struct weston_output *output = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900263
264 wl_list_for_each(output, &ec->output_list, link) {
265 iviscrn = calloc(1, sizeof *iviscrn);
266 if (iviscrn == NULL) {
267 weston_log("fails to allocate memory\n");
268 continue;
269 }
270
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900271 iviscrn->layout = layout;
272
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900273 iviscrn->output = output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900274
275 wl_list_init(&iviscrn->pending.layer_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900276
277 wl_list_init(&iviscrn->order.layer_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900278
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900279 wl_list_insert(&layout->screen_list, &iviscrn->link);
280 }
281}
282
283/**
284 * Internal APIs to initialize properties of ivi_surface/ivi_layer when they are created.
285 */
286static void
287init_layer_properties(struct ivi_layout_layer_properties *prop,
288 int32_t width, int32_t height)
289{
290 memset(prop, 0, sizeof *prop);
291 prop->opacity = wl_fixed_from_double(1.0);
292 prop->source_width = width;
293 prop->source_height = height;
294 prop->dest_width = width;
295 prop->dest_height = height;
296}
297
298static void
299init_surface_properties(struct ivi_layout_surface_properties *prop)
300{
301 memset(prop, 0, sizeof *prop);
302 prop->opacity = wl_fixed_from_double(1.0);
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900303 /*
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700304 * FIXME: this shall be fixed by ivi-layout-transition.
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900305 */
306 prop->dest_width = 1;
307 prop->dest_height = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900308}
309
310/**
311 * Internal APIs to be called from ivi_layout_commit_changes.
312 */
313static void
314update_opacity(struct ivi_layout_layer *ivilayer,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000315 struct ivi_layout_surface *ivisurf,
316 struct weston_view *view)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900317{
318 double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity);
319 double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity);
320
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000321 view->alpha = layer_alpha * surf_alpha;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900322}
323
324static void
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900325get_rotate_values(enum wl_output_transform orientation,
326 float *v_sin,
327 float *v_cos)
328{
329 switch (orientation) {
330 case WL_OUTPUT_TRANSFORM_90:
331 *v_sin = 1.0f;
332 *v_cos = 0.0f;
333 break;
334 case WL_OUTPUT_TRANSFORM_180:
335 *v_sin = 0.0f;
336 *v_cos = -1.0f;
337 break;
338 case WL_OUTPUT_TRANSFORM_270:
339 *v_sin = -1.0f;
340 *v_cos = 0.0f;
341 break;
342 case WL_OUTPUT_TRANSFORM_NORMAL:
343 default:
344 *v_sin = 0.0f;
345 *v_cos = 1.0f;
346 break;
347 }
348}
349
350static void
351get_scale(enum wl_output_transform orientation,
352 float dest_width,
353 float dest_height,
354 float source_width,
355 float source_height,
356 float *scale_x,
357 float *scale_y)
358{
359 switch (orientation) {
360 case WL_OUTPUT_TRANSFORM_90:
361 *scale_x = dest_width / source_height;
362 *scale_y = dest_height / source_width;
363 break;
364 case WL_OUTPUT_TRANSFORM_180:
365 *scale_x = dest_width / source_width;
366 *scale_y = dest_height / source_height;
367 break;
368 case WL_OUTPUT_TRANSFORM_270:
369 *scale_x = dest_width / source_height;
370 *scale_y = dest_height / source_width;
371 break;
372 case WL_OUTPUT_TRANSFORM_NORMAL:
373 default:
374 *scale_x = dest_width / source_width;
375 *scale_y = dest_height / source_height;
376 break;
377 }
378}
379
380static void
381calc_transformation_matrix(struct ivi_rectangle *source_rect,
382 struct ivi_rectangle *dest_rect,
383 enum wl_output_transform orientation,
384 struct weston_matrix *m)
385{
386 float source_center_x;
387 float source_center_y;
388 float vsin;
389 float vcos;
390 float scale_x;
391 float scale_y;
392 float translate_x;
393 float translate_y;
394
395 source_center_x = source_rect->x + source_rect->width * 0.5f;
396 source_center_y = source_rect->y + source_rect->height * 0.5f;
397 weston_matrix_translate(m, -source_center_x, -source_center_y, 0.0f);
398
399 get_rotate_values(orientation, &vsin, &vcos);
400 weston_matrix_rotate_xy(m, vcos, vsin);
401
402 get_scale(orientation,
403 dest_rect->width,
404 dest_rect->height,
405 source_rect->width,
406 source_rect->height,
407 &scale_x,
408 &scale_y);
409 weston_matrix_scale(m, scale_x, scale_y, 1.0f);
410
411 translate_x = dest_rect->width * 0.5f + dest_rect->x;
412 translate_y = dest_rect->height * 0.5f + dest_rect->y;
413 weston_matrix_translate(m, translate_x, translate_y, 0.0f);
414}
415
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900416/*
417 * This computes intersected rect_output from two ivi_rectangles
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900418 */
419static void
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900420ivi_rectangle_intersect(const struct ivi_rectangle *rect1,
421 const struct ivi_rectangle *rect2,
422 struct ivi_rectangle *rect_output)
423{
424 int32_t rect1_right = rect1->x + rect1->width;
425 int32_t rect1_bottom = rect1->y + rect1->height;
426 int32_t rect2_right = rect2->x + rect2->width;
427 int32_t rect2_bottom = rect2->y + rect2->height;
428
429 rect_output->x = max(rect1->x, rect2->x);
430 rect_output->y = max(rect1->y, rect2->y);
431 rect_output->width = rect1_right < rect2_right ?
432 rect1_right - rect_output->x :
433 rect2_right - rect_output->x;
434 rect_output->height = rect1_bottom < rect2_bottom ?
435 rect1_bottom - rect_output->y :
436 rect2_bottom - rect_output->y;
437
438 if (rect_output->width < 0 || rect_output->height < 0) {
439 rect_output->width = 0;
440 rect_output->height = 0;
441 }
442}
443
444/*
445 * Transform rect_input by the inverse of matrix, intersect with boundingbox,
446 * and store the result in rect_output.
447 * The boundingbox must be given in the same coordinate space as rect_output.
448 * Additionally, there are the following restrictions on the matrix:
449 * - no projective transformations
450 * - no skew
451 * - only multiples of 90-degree rotations supported
452 *
453 * In failure case of weston_matrix_invert, rect_output is set to boundingbox
454 * as a fail-safe with log.
455 */
456static void
457calc_inverse_matrix_transform(const struct weston_matrix *matrix,
458 const struct ivi_rectangle *rect_input,
459 const struct ivi_rectangle *boundingbox,
460 struct ivi_rectangle *rect_output)
461{
462 struct weston_matrix m;
463 struct weston_vector top_left;
464 struct weston_vector bottom_right;
465
466 assert(boundingbox != rect_output);
467
468 if (weston_matrix_invert(&m, matrix) < 0) {
469 weston_log("ivi-shell: calc_inverse_matrix_transform fails to invert a matrix.\n");
470 weston_log("ivi-shell: boundingbox is set to the rect_output.\n");
471 rect_output->x = boundingbox->x;
472 rect_output->y = boundingbox->y;
473 rect_output->width = boundingbox->width;
474 rect_output->height = boundingbox->height;
475 }
476
477 /* The vectors and matrices involved will always produce f[3] == 1.0. */
478 top_left.f[0] = rect_input->x;
479 top_left.f[1] = rect_input->y;
480 top_left.f[2] = 0.0f;
481 top_left.f[3] = 1.0f;
482
483 bottom_right.f[0] = rect_input->x + rect_input->width;
484 bottom_right.f[1] = rect_input->y + rect_input->height;
485 bottom_right.f[2] = 0.0f;
486 bottom_right.f[3] = 1.0f;
487
488 weston_matrix_transform(&m, &top_left);
489 weston_matrix_transform(&m, &bottom_right);
490
491 if (top_left.f[0] < bottom_right.f[0]) {
492 rect_output->x = top_left.f[0];
493 rect_output->width = bottom_right.f[0] - rect_output->x;
494 } else {
495 rect_output->x = bottom_right.f[0];
496 rect_output->width = top_left.f[0] - rect_output->x;
497 }
498
499 if (top_left.f[1] < bottom_right.f[1]) {
500 rect_output->y = top_left.f[1];
501 rect_output->height = bottom_right.f[1] - rect_output->y;
502 } else {
503 rect_output->y = bottom_right.f[1];
504 rect_output->height = top_left.f[1] - rect_output->y;
505 }
506
507 ivi_rectangle_intersect(rect_output, boundingbox, rect_output);
508}
509
510/**
511 * This computes the whole transformation matrix:m from surface-local
Yong Bakose0698712016-04-28 11:59:08 -0500512 * coordinates to multi-screen coordinates, which are global coordinates.
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900513 * It is assumed that weston_view::geometry.{x,y} are zero.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900514 *
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700515 * Additionally, this computes the mask on surface-local coordinates as an
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900516 * ivi_rectangle. This can be set to weston_view_set_mask.
517 *
518 * The mask is computed by following steps
Yong Bakose0698712016-04-28 11:59:08 -0500519 * - destination rectangle of layer is transformed to multi-screen coordinates,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900520 * global coordinates. This is done by adding weston_output.{x,y} in simple
521 * because there is no scaled and rotated transformation.
Yong Bakose0698712016-04-28 11:59:08 -0500522 * - destination rectangle of layer in multi-screen coordinates needs to be
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900523 * intersected inside of a screen the layer is assigned to. This is because
524 * overlapped region of weston surface in another screen shall not be
525 * displayed according to ivi use case.
526 * - destination rectangle of layer
Yong Bakose0698712016-04-28 11:59:08 -0500527 * - in multi-screen coordinates,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900528 * - and intersected inside of an assigned screen,
Yong Bakose0698712016-04-28 11:59:08 -0500529 * is inversed to surface-local coordinates by inversed matrix:m.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900530 * - the area is intersected by intersected area between weston_surface and
531 * source rectangle of ivi_surface.
532 */
533static void
534calc_surface_to_global_matrix_and_mask_to_weston_surface(
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900535 struct ivi_layout_screen *iviscrn,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900536 struct ivi_layout_layer *ivilayer,
537 struct ivi_layout_surface *ivisurf,
538 struct weston_matrix *m,
539 struct ivi_rectangle *result)
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900540{
541 const struct ivi_layout_surface_properties *sp = &ivisurf->prop;
542 const struct ivi_layout_layer_properties *lp = &ivilayer->prop;
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900543 struct weston_output *output = iviscrn->output;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900544 struct ivi_rectangle weston_surface_rect = { 0,
545 0,
546 ivisurf->surface->width,
547 ivisurf->surface->height };
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900548 struct ivi_rectangle surface_source_rect = { sp->source_x,
549 sp->source_y,
550 sp->source_width,
551 sp->source_height };
552 struct ivi_rectangle surface_dest_rect = { sp->dest_x,
553 sp->dest_y,
554 sp->dest_width,
555 sp->dest_height };
556 struct ivi_rectangle layer_source_rect = { lp->source_x,
557 lp->source_y,
558 lp->source_width,
559 lp->source_height };
560 struct ivi_rectangle layer_dest_rect = { lp->dest_x,
561 lp->dest_y,
562 lp->dest_width,
563 lp->dest_height };
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900564 struct ivi_rectangle screen_dest_rect = { output->x,
565 output->y,
566 output->width,
567 output->height };
568 struct ivi_rectangle layer_dest_rect_in_global =
569 { lp->dest_x + output->x,
570 lp->dest_y + output->y,
571 lp->dest_width,
572 lp->dest_height };
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900573 struct ivi_rectangle surface_result;
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900574 struct ivi_rectangle layer_dest_rect_in_global_intersected;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900575
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900576 /*
577 * the whole transformation matrix:m from surface-local
578 * coordinates to global coordinates, which is computed by
579 * two steps,
580 * - surface-local coordinates to layer-local coordinates
Yong Bakose0698712016-04-28 11:59:08 -0500581 * - layer-local coordinates to single screen-local coordinates
582 * - single screen-local coordinates to multi-screen coordinates,
583 * which are global coordinates.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900584 */
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900585 calc_transformation_matrix(&surface_source_rect,
586 &surface_dest_rect,
587 sp->orientation, m);
588
589 calc_transformation_matrix(&layer_source_rect,
590 &layer_dest_rect,
591 lp->orientation, m);
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900592
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900593 weston_matrix_translate(m, output->x, output->y, 0.0f);
594
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900595 /* this intersected ivi_rectangle would be used for masking
596 * weston_surface
597 */
598 ivi_rectangle_intersect(&surface_source_rect, &weston_surface_rect,
599 &surface_result);
600
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900601 /*
602 * destination rectangle of layer in multi screens coordinate
603 * is intersected to avoid displaying outside of an assigned screen.
604 */
605 ivi_rectangle_intersect(&layer_dest_rect_in_global, &screen_dest_rect,
606 &layer_dest_rect_in_global_intersected);
607
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900608 /* calc masking area of weston_surface from m */
609 calc_inverse_matrix_transform(m,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900610 &layer_dest_rect_in_global_intersected,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900611 &surface_result,
612 result);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900613}
614
615static void
Ucan, Emre (ADITG/SW1)1b92ba22017-01-30 13:36:05 +0000616update_prop(struct ivi_layout_view *ivi_view)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900617{
Ucan, Emre (ADITG/SW1)1b92ba22017-01-30 13:36:05 +0000618 struct ivi_layout_surface *ivisurf = ivi_view->ivisurf;
619 struct ivi_layout_layer *ivilayer = ivi_view->on_layer;
620 struct ivi_layout_screen *iviscrn = ivilayer->on_screen;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900621 struct ivi_rectangle r;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900622 bool can_calc = true;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900623
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900624 /*In case of no prop change, this just returns*/
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000625 if (!ivilayer->prop.event_mask && !ivisurf->prop.event_mask)
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900626 return;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900627
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000628 update_opacity(ivilayer, ivisurf, ivi_view->view);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900629
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900630 if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) {
631 weston_log("ivi-shell: source rectangle is not yet set by ivi_layout_surface_set_source_rectangle\n");
632 can_calc = false;
633 }
634
635 if (ivisurf->prop.dest_width == 0 || ivisurf->prop.dest_height == 0) {
636 weston_log("ivi-shell: destination rectangle is not yet set by ivi_layout_surface_set_destination_rectangle\n");
637 can_calc = false;
638 }
639
640 if (can_calc) {
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000641 wl_list_remove(&ivi_view->transform.link);
642 weston_matrix_init(&ivi_view->transform.matrix);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900643
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900644 calc_surface_to_global_matrix_and_mask_to_weston_surface(
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000645 iviscrn, ivilayer, ivisurf, &ivi_view->transform.matrix, &r);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900646
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000647 weston_view_set_mask(ivi_view->view, r.x, r.y, r.width, r.height);
648 wl_list_insert(&ivi_view->view->geometry.transformation_list,
649 &ivi_view->transform.link);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900650
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000651 weston_view_set_transform_parent(ivi_view->view, NULL);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900652 }
653
654 ivisurf->update_count++;
655
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000656 weston_view_geometry_dirty(ivi_view->view);
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900657
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000658 weston_surface_damage(ivisurf->surface);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900659}
660
661static void
662commit_changes(struct ivi_layout *layout)
663{
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000664 struct ivi_layout_screen *iviscrn = NULL;
665 struct ivi_layout_layer *ivilayer = NULL;
666 struct ivi_layout_surface *ivisurf = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000667 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900668
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000669 wl_list_for_each(ivi_view, &layout->view_list, link) {
670 ivisurf = ivi_view->ivisurf;
671 ivilayer = ivi_view->on_layer;
672 iviscrn = ivilayer->on_screen;
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900673
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000674 /*
675 * If the view is not on the currently rendered scenegraph,
676 * we do not need to update its properties.
677 */
678 if (wl_list_empty(&ivi_view->order_link) || !iviscrn)
679 continue;
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900680
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000681 /*
682 * If the view's layer or surface is invisible, we do not need
683 * to update its properties.
684 */
Ucan, Emre (ADITG/SW1)7fe0bb22017-02-07 12:55:59 +0000685 if (!ivilayer->prop.visibility || !ivisurf->prop.visibility) {
686 /*
687 * If ivilayer or ivisurf of ivi_view is made invisible
688 * in this commit_changes call, we have to damage
689 * the weston_view below this ivi_view. Otherwise content
690 * of this ivi_view will stay visible.
691 */
692 if ((ivilayer->prop.event_mask | ivisurf->prop.event_mask) &&
693 IVI_NOTIFICATION_VISIBILITY)
694 weston_view_damage_below(ivi_view->view);
695
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000696 continue;
Ucan, Emre (ADITG/SW1)7fe0bb22017-02-07 12:55:59 +0000697 }
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000698
699 update_prop(ivi_view);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900700 }
701}
702
703static void
704commit_surface_list(struct ivi_layout *layout)
705{
706 struct ivi_layout_surface *ivisurf = NULL;
707 int32_t dest_x = 0;
708 int32_t dest_y = 0;
709 int32_t dest_width = 0;
710 int32_t dest_height = 0;
711 int32_t configured = 0;
712
713 wl_list_for_each(ivisurf, &layout->surface_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300714 if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEFAULT) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900715 dest_x = ivisurf->prop.dest_x;
716 dest_y = ivisurf->prop.dest_y;
717 dest_width = ivisurf->prop.dest_width;
718 dest_height = ivisurf->prop.dest_height;
719
720 ivi_layout_transition_move_resize_view(ivisurf,
721 ivisurf->pending.prop.dest_x,
722 ivisurf->pending.prop.dest_y,
723 ivisurf->pending.prop.dest_width,
724 ivisurf->pending.prop.dest_height,
725 ivisurf->pending.prop.transition_duration);
726
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300727 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900728 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
729 } else {
730 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
731 }
732
733 ivisurf->prop = ivisurf->pending.prop;
734 ivisurf->prop.dest_x = dest_x;
735 ivisurf->prop.dest_y = dest_y;
736 ivisurf->prop.dest_width = dest_width;
737 ivisurf->prop.dest_height = dest_height;
738 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
739 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
740
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300741 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900742 dest_x = ivisurf->prop.dest_x;
743 dest_y = ivisurf->prop.dest_y;
744 dest_width = ivisurf->prop.dest_width;
745 dest_height = ivisurf->prop.dest_height;
746
747 ivi_layout_transition_move_resize_view(ivisurf,
748 ivisurf->pending.prop.dest_x,
749 ivisurf->pending.prop.dest_y,
750 ivisurf->pending.prop.dest_width,
751 ivisurf->pending.prop.dest_height,
752 ivisurf->pending.prop.transition_duration);
753
754 ivisurf->prop = ivisurf->pending.prop;
755 ivisurf->prop.dest_x = dest_x;
756 ivisurf->prop.dest_y = dest_y;
757 ivisurf->prop.dest_width = dest_width;
758 ivisurf->prop.dest_height = dest_height;
759
760 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
761 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
762
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300763 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900764 configured = 0;
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300765 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900766 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
767 } else {
768 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
769 }
770
771 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
772 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
773 configured = 1;
774 }
775
776 ivisurf->prop = ivisurf->pending.prop;
777 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
778 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
779
Pekka Paalanen1f821932016-03-15 16:57:51 +0200780 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200781 shell_surface_send_configure(ivisurf->surface,
782 ivisurf->prop.dest_width,
783 ivisurf->prop.dest_height);
784 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900785 } else {
786 configured = 0;
787 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
788 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
789 configured = 1;
790 }
791
792 ivisurf->prop = ivisurf->pending.prop;
793 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
794 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
795
Pekka Paalanen1f821932016-03-15 16:57:51 +0200796 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200797 shell_surface_send_configure(ivisurf->surface,
798 ivisurf->prop.dest_width,
799 ivisurf->prop.dest_height);
800 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900801 }
802 }
803}
804
805static void
806commit_layer_list(struct ivi_layout *layout)
807{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000808 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900809 struct ivi_layout_layer *ivilayer = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000810 struct ivi_layout_view *next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900811
812 wl_list_for_each(ivilayer, &layout->layer_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300813 if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_MOVE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900814 ivi_layout_transition_move_layer(ivilayer, ivilayer->pending.prop.dest_x, ivilayer->pending.prop.dest_y, ivilayer->pending.prop.transition_duration);
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300815 } else if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_FADE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900816 ivi_layout_transition_fade_layer(ivilayer,ivilayer->pending.prop.is_fade_in,
817 ivilayer->pending.prop.start_alpha,ivilayer->pending.prop.end_alpha,
818 NULL, NULL,
819 ivilayer->pending.prop.transition_duration);
820 }
821 ivilayer->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
822
823 ivilayer->prop = ivilayer->pending.prop;
824
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000825 if (!ivilayer->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900826 continue;
827 }
828
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000829 wl_list_for_each_safe(ivi_view, next, &ivilayer->order.view_list,
830 order_link) {
831 wl_list_remove(&ivi_view->order_link);
832 wl_list_init(&ivi_view->order_link);
833 ivi_view->ivisurf->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900834 }
835
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000836 assert(wl_list_empty(&ivilayer->order.view_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900837
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000838 wl_list_for_each(ivi_view, &ivilayer->pending.view_list,
839 pending_link) {
840 wl_list_remove(&ivi_view->order_link);
841 wl_list_insert(&ivilayer->order.view_list, &ivi_view->order_link);
842 ivi_view->ivisurf->prop.event_mask |= IVI_NOTIFICATION_ADD;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900843 }
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000844
845 ivilayer->order.dirty = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900846 }
847}
848
849static void
850commit_screen_list(struct ivi_layout *layout)
851{
852 struct ivi_layout_screen *iviscrn = NULL;
853 struct ivi_layout_layer *ivilayer = NULL;
854 struct ivi_layout_layer *next = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000855 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900856
Nobuhiko Tanibatafbfa8f22015-11-25 23:36:57 +0900857 /* Clear view list of layout ivi_layer */
858 wl_list_init(&layout->layout_layer.view_list.link);
859
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900860 wl_list_for_each(iviscrn, &layout->screen_list, link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000861 if (iviscrn->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900862 wl_list_for_each_safe(ivilayer, next,
863 &iviscrn->order.layer_list, order.link) {
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000864 ivilayer->on_screen = NULL;
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000865 wl_list_remove(&ivilayer->order.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900866 wl_list_init(&ivilayer->order.link);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000867 ivilayer->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900868 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900869
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000870 assert(wl_list_empty(&iviscrn->order.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900871
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900872 wl_list_for_each(ivilayer, &iviscrn->pending.layer_list,
873 pending.link) {
Nobuhiko Tanibata77b0ee12015-11-25 23:36:46 +0900874 /* FIXME: avoid to insert order.link to multiple screens */
875 wl_list_remove(&ivilayer->order.link);
876
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900877 wl_list_insert(&iviscrn->order.layer_list,
878 &ivilayer->order.link);
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000879 ivilayer->on_screen = iviscrn;
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000880 ivilayer->prop.event_mask |= IVI_NOTIFICATION_ADD;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900881 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900882
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000883 iviscrn->order.dirty = 0;
884 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900885
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900886 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
887 if (ivilayer->prop.visibility == false)
888 continue;
889
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000890 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
891 if (ivi_view->ivisurf->prop.visibility == false)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900892 continue;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000893
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900894 weston_layer_entry_insert(&layout->layout_layer.view_list,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000895 &ivi_view->view->layer_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900896
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000897 ivi_view->view->output = iviscrn->output;
Armin Krezović50ff4bf2016-06-30 06:04:31 +0200898 ivi_view->ivisurf->surface->is_mapped = true;
899 ivi_view->view->is_mapped = true;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900900 }
901 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900902 }
903}
904
905static void
906commit_transition(struct ivi_layout* layout)
907{
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300908 if (wl_list_empty(&layout->pending_transition_list)) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900909 return;
910 }
911
912 wl_list_insert_list(&layout->transitions->transition_list,
913 &layout->pending_transition_list);
914
915 wl_list_init(&layout->pending_transition_list);
916
917 wl_event_source_timer_update(layout->transitions->event_source, 1);
918}
919
920static void
921send_surface_prop(struct ivi_layout_surface *ivisurf)
922{
923 wl_signal_emit(&ivisurf->property_changed, ivisurf);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000924 ivisurf->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900925}
926
927static void
928send_layer_prop(struct ivi_layout_layer *ivilayer)
929{
930 wl_signal_emit(&ivilayer->property_changed, ivilayer);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000931 ivilayer->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900932}
933
934static void
935send_prop(struct ivi_layout *layout)
936{
937 struct ivi_layout_layer *ivilayer = NULL;
938 struct ivi_layout_surface *ivisurf = NULL;
939
940 wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000941 if (ivilayer->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900942 send_layer_prop(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900943 }
944
945 wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000946 if (ivisurf->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900947 send_surface_prop(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900948 }
949}
950
951static void
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000952clear_view_pending_list(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900953{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000954 struct ivi_layout_view *view_link = NULL;
955 struct ivi_layout_view *view_next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900956
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000957 wl_list_for_each_safe(view_link, view_next,
958 &ivilayer->pending.view_list, pending_link) {
959 wl_list_remove(&view_link->pending_link);
960 wl_list_init(&view_link->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900961 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900962}
963
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900964/**
965 * Exported APIs of ivi-layout library are implemented from here.
966 * Brief of APIs is described in ivi-layout-export.h.
967 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900968static int32_t
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000969ivi_layout_add_listener_create_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900970{
971 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900972
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000973 if (listener == NULL) {
974 weston_log("ivi_layout_add_listener_create_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900975 return IVI_FAILED;
976 }
977
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000978 wl_signal_add(&layout->layer_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900979
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000980 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900981}
982
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900983static int32_t
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000984ivi_layout_add_listener_remove_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900985{
986 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900987
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000988 if (listener == NULL) {
989 weston_log("ivi_layout_add_listener_remove_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900990 return IVI_FAILED;
991 }
992
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000993 wl_signal_add(&layout->layer_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900994
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000995 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900996}
997
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900998static int32_t
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000999ivi_layout_add_listener_create_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001000{
1001 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001002
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001003 if (listener == NULL) {
1004 weston_log("ivi_layout_add_listener_create_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001005 return IVI_FAILED;
1006 }
1007
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001008 wl_signal_add(&layout->surface_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001009
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001010 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001011}
1012
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001013static int32_t
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001014ivi_layout_add_listener_remove_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001015{
1016 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001017
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001018 if (listener == NULL) {
1019 weston_log("ivi_layout_add_listener_remove_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001020 return IVI_FAILED;
1021 }
1022
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001023 wl_signal_add(&layout->surface_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001024
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001025 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001026}
1027
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001028static int32_t
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001029ivi_layout_add_listener_configure_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001030{
1031 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001032
1033 if (listener == NULL) {
1034 weston_log("ivi_layout_add_listener_configure_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001035 return IVI_FAILED;
1036 }
1037
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001038 wl_signal_add(&layout->surface_notification.configure_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001039
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001040 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001041}
1042
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001043uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001044ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf)
1045{
1046 return ivisurf->id_surface;
1047}
1048
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001049static uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001050ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer)
1051{
1052 return ivilayer->id_layer;
1053}
1054
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001055static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001056ivi_layout_get_layer_from_id(uint32_t id_layer)
1057{
1058 struct ivi_layout *layout = get_instance();
1059 struct ivi_layout_layer *ivilayer = NULL;
1060
1061 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1062 if (ivilayer->id_layer == id_layer) {
1063 return ivilayer;
1064 }
1065 }
1066
1067 return NULL;
1068}
1069
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001070struct ivi_layout_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001071ivi_layout_get_surface_from_id(uint32_t id_surface)
1072{
1073 struct ivi_layout *layout = get_instance();
1074 struct ivi_layout_surface *ivisurf = NULL;
1075
1076 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1077 if (ivisurf->id_surface == id_surface) {
1078 return ivisurf;
1079 }
1080 }
1081
1082 return NULL;
1083}
1084
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001085static int32_t
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001086ivi_layout_surface_add_listener(struct ivi_layout_surface *ivisurf,
1087 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001088{
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001089 if (ivisurf == NULL || listener == NULL) {
1090 weston_log("ivi_layout_surface_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001091 return IVI_FAILED;
1092 }
1093
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001094 wl_signal_add(&ivisurf->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001095
1096 return IVI_SUCCEEDED;
1097}
1098
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001099static const struct ivi_layout_layer_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001100ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer)
1101{
1102 if (ivilayer == NULL) {
1103 weston_log("ivi_layout_get_properties_of_layer: invalid argument\n");
1104 return NULL;
1105 }
1106
1107 return &ivilayer->prop;
1108}
1109
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001110static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001111ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer,
1112 int32_t *pLength,
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001113 struct weston_output ***ppArray)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001114{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001115 int32_t length = 0;
1116 int32_t n = 0;
1117
1118 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1119 weston_log("ivi_layout_get_screens_under_layer: invalid argument\n");
1120 return IVI_FAILED;
1121 }
1122
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +00001123 if (ivilayer->on_screen != NULL)
1124 length = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001125
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001126 if (length != 0) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001127 /* the Array must be free by module which called this function */
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001128 *ppArray = calloc(length, sizeof(struct weston_output *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001129 if (*ppArray == NULL) {
1130 weston_log("fails to allocate memory\n");
1131 return IVI_FAILED;
1132 }
1133
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001134 (*ppArray)[n++] = ivilayer->on_screen->output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001135 }
1136
1137 *pLength = length;
1138
1139 return IVI_SUCCEEDED;
1140}
1141
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001142static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001143ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray)
1144{
1145 struct ivi_layout *layout = get_instance();
1146 struct ivi_layout_layer *ivilayer = NULL;
1147 int32_t length = 0;
1148 int32_t n = 0;
1149
1150 if (pLength == NULL || ppArray == NULL) {
1151 weston_log("ivi_layout_get_layers: invalid argument\n");
1152 return IVI_FAILED;
1153 }
1154
1155 length = wl_list_length(&layout->layer_list);
1156
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001157 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001158 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001159 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1160 if (*ppArray == NULL) {
1161 weston_log("fails to allocate memory\n");
1162 return IVI_FAILED;
1163 }
1164
1165 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1166 (*ppArray)[n++] = ivilayer;
1167 }
1168 }
1169
1170 *pLength = length;
1171
1172 return IVI_SUCCEEDED;
1173}
1174
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001175static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001176ivi_layout_get_layers_on_screen(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001177 int32_t *pLength,
1178 struct ivi_layout_layer ***ppArray)
1179{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001180 struct ivi_layout_screen *iviscrn = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001181 struct ivi_layout_layer *ivilayer = NULL;
1182 int32_t length = 0;
1183 int32_t n = 0;
1184
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001185 if (output == NULL || pLength == NULL || ppArray == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001186 weston_log("ivi_layout_get_layers_on_screen: invalid argument\n");
1187 return IVI_FAILED;
1188 }
1189
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001190 iviscrn = get_screen_from_output(output);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001191 length = wl_list_length(&iviscrn->order.layer_list);
1192
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001193 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001194 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001195 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1196 if (*ppArray == NULL) {
1197 weston_log("fails to allocate memory\n");
1198 return IVI_FAILED;
1199 }
1200
Nobuhiko Tanibatae2b82142015-06-22 15:30:19 +09001201 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001202 (*ppArray)[n++] = ivilayer;
1203 }
1204 }
1205
1206 *pLength = length;
1207
1208 return IVI_SUCCEEDED;
1209}
1210
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001211static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001212ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
1213 int32_t *pLength,
1214 struct ivi_layout_layer ***ppArray)
1215{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001216 struct ivi_layout_view *ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001217 int32_t length = 0;
1218 int32_t n = 0;
1219
1220 if (ivisurf == NULL || pLength == NULL || ppArray == NULL) {
1221 weston_log("ivi_layout_getLayers: invalid argument\n");
1222 return IVI_FAILED;
1223 }
1224
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001225 if (!wl_list_empty(&ivisurf->view_list)) {
1226 /* the Array must be free by module which called this function */
1227 length = wl_list_length(&ivisurf->view_list);
1228 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001229 if (*ppArray == NULL) {
1230 weston_log("fails to allocate memory\n");
1231 return IVI_FAILED;
1232 }
1233
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001234 wl_list_for_each_reverse(ivi_view, &ivisurf->view_list, surf_link) {
1235 if (ivi_view_is_rendered(ivi_view))
1236 (*ppArray)[n++] = ivi_view->on_layer;
1237 else
1238 length--;
1239 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001240 }
1241
1242 *pLength = length;
1243
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001244 if (!length) {
1245 free(*ppArray);
1246 *ppArray = NULL;
1247 }
1248
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001249 return IVI_SUCCEEDED;
1250}
1251
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001252static
1253int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001254ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray)
1255{
1256 struct ivi_layout *layout = get_instance();
1257 struct ivi_layout_surface *ivisurf = NULL;
1258 int32_t length = 0;
1259 int32_t n = 0;
1260
1261 if (pLength == NULL || ppArray == NULL) {
1262 weston_log("ivi_layout_get_surfaces: invalid argument\n");
1263 return IVI_FAILED;
1264 }
1265
1266 length = wl_list_length(&layout->surface_list);
1267
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001268 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001269 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001270 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1271 if (*ppArray == NULL) {
1272 weston_log("fails to allocate memory\n");
1273 return IVI_FAILED;
1274 }
1275
1276 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1277 (*ppArray)[n++] = ivisurf;
1278 }
1279 }
1280
1281 *pLength = length;
1282
1283 return IVI_SUCCEEDED;
1284}
1285
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001286static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001287ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer,
1288 int32_t *pLength,
1289 struct ivi_layout_surface ***ppArray)
1290{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001291 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001292 int32_t length = 0;
1293 int32_t n = 0;
1294
1295 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1296 weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n");
1297 return IVI_FAILED;
1298 }
1299
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001300 length = wl_list_length(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001301
1302 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001303 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001304 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1305 if (*ppArray == NULL) {
1306 weston_log("fails to allocate memory\n");
1307 return IVI_FAILED;
1308 }
1309
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001310 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
1311 (*ppArray)[n++] = ivi_view->ivisurf;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001312 }
1313 }
1314
1315 *pLength = length;
1316
1317 return IVI_SUCCEEDED;
1318}
1319
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001320static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001321ivi_layout_layer_create_with_dimension(uint32_t id_layer,
1322 int32_t width, int32_t height)
1323{
1324 struct ivi_layout *layout = get_instance();
1325 struct ivi_layout_layer *ivilayer = NULL;
1326
1327 ivilayer = get_layer(&layout->layer_list, id_layer);
1328 if (ivilayer != NULL) {
1329 weston_log("id_layer is already created\n");
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001330 ++ivilayer->ref_count;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001331 return ivilayer;
1332 }
1333
1334 ivilayer = calloc(1, sizeof *ivilayer);
1335 if (ivilayer == NULL) {
1336 weston_log("fails to allocate memory\n");
1337 return NULL;
1338 }
1339
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001340 ivilayer->ref_count = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001341 wl_signal_init(&ivilayer->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001342 ivilayer->layout = layout;
1343 ivilayer->id_layer = id_layer;
1344
1345 init_layer_properties(&ivilayer->prop, width, height);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001346
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001347 wl_list_init(&ivilayer->pending.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001348 wl_list_init(&ivilayer->pending.link);
1349 ivilayer->pending.prop = ivilayer->prop;
1350
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001351 wl_list_init(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001352 wl_list_init(&ivilayer->order.link);
1353
1354 wl_list_insert(&layout->layer_list, &ivilayer->link);
1355
1356 wl_signal_emit(&layout->layer_notification.created, ivilayer);
1357
1358 return ivilayer;
1359}
1360
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001361static void
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09001362ivi_layout_layer_destroy(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001363{
1364 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001365 struct ivi_layout_view *ivi_view, *next;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001366
1367 if (ivilayer == NULL) {
Ucan, Emre (ADITG/SW1)66602522017-01-17 12:35:20 +00001368 weston_log("ivi_layout_layer_destroy: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001369 return;
1370 }
1371
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001372 if (--ivilayer->ref_count > 0)
1373 return;
1374
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001375 /*Destroy all ivi_views*/
1376 wl_list_for_each_safe(ivi_view, next, &layout->view_list, link) {
1377 if (ivi_view->on_layer == ivilayer)
1378 ivi_view_destroy(ivi_view);
1379 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001380
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001381 wl_signal_emit(&layout->layer_notification.removed, ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001382
Ucan, Emre (ADITG/SW1)cf34dc22015-08-20 14:13:33 +00001383 wl_list_remove(&ivilayer->pending.link);
1384 wl_list_remove(&ivilayer->order.link);
1385 wl_list_remove(&ivilayer->link);
1386
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001387 free(ivilayer);
1388}
1389
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001390int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001391ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
1392 bool newVisibility)
1393{
1394 struct ivi_layout_layer_properties *prop = NULL;
1395
1396 if (ivilayer == NULL) {
1397 weston_log("ivi_layout_layer_set_visibility: invalid argument\n");
1398 return IVI_FAILED;
1399 }
1400
1401 prop = &ivilayer->pending.prop;
1402 prop->visibility = newVisibility;
1403
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001404 if (ivilayer->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001405 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001406 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001407 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001408
1409 return IVI_SUCCEEDED;
1410}
1411
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001412int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001413ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
1414 wl_fixed_t opacity)
1415{
1416 struct ivi_layout_layer_properties *prop = NULL;
1417
Nobuhiko Tanibata7bbacc62015-06-22 15:30:09 +09001418 if (ivilayer == NULL ||
1419 opacity < wl_fixed_from_double(0.0) ||
1420 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001421 weston_log("ivi_layout_layer_set_opacity: invalid argument\n");
1422 return IVI_FAILED;
1423 }
1424
1425 prop = &ivilayer->pending.prop;
1426 prop->opacity = opacity;
1427
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001428 if (ivilayer->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001429 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001430 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001431 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001432
1433 return IVI_SUCCEEDED;
1434}
1435
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001436static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001437ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer,
1438 int32_t x, int32_t y,
1439 int32_t width, int32_t height)
1440{
1441 struct ivi_layout_layer_properties *prop = NULL;
1442
1443 if (ivilayer == NULL) {
1444 weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n");
1445 return IVI_FAILED;
1446 }
1447
1448 prop = &ivilayer->pending.prop;
1449 prop->source_x = x;
1450 prop->source_y = y;
1451 prop->source_width = width;
1452 prop->source_height = height;
1453
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001454 if (ivilayer->prop.source_x != x || ivilayer->prop.source_y != y ||
1455 ivilayer->prop.source_width != width ||
1456 ivilayer->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001457 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001458 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001459 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001460
1461 return IVI_SUCCEEDED;
1462}
1463
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +00001464int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001465ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
1466 int32_t x, int32_t y,
1467 int32_t width, int32_t height)
1468{
1469 struct ivi_layout_layer_properties *prop = NULL;
1470
1471 if (ivilayer == NULL) {
1472 weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n");
1473 return IVI_FAILED;
1474 }
1475
1476 prop = &ivilayer->pending.prop;
1477 prop->dest_x = x;
1478 prop->dest_y = y;
1479 prop->dest_width = width;
1480 prop->dest_height = height;
1481
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001482 if (ivilayer->prop.dest_x != x || ivilayer->prop.dest_y != y ||
1483 ivilayer->prop.dest_width != width ||
1484 ivilayer->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001485 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001486 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001487 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001488
1489 return IVI_SUCCEEDED;
1490}
1491
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001492static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001493ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer,
1494 enum wl_output_transform orientation)
1495{
1496 struct ivi_layout_layer_properties *prop = NULL;
1497
1498 if (ivilayer == NULL) {
1499 weston_log("ivi_layout_layer_set_orientation: invalid argument\n");
1500 return IVI_FAILED;
1501 }
1502
1503 prop = &ivilayer->pending.prop;
1504 prop->orientation = orientation;
1505
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001506 if (ivilayer->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001507 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001508 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001509 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001510
1511 return IVI_SUCCEEDED;
1512}
1513
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001514int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001515ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
1516 struct ivi_layout_surface **pSurface,
1517 int32_t number)
1518{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001519 int32_t i = 0;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001520 struct ivi_layout_view * ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001521
1522 if (ivilayer == NULL) {
1523 weston_log("ivi_layout_layer_set_render_order: invalid argument\n");
1524 return IVI_FAILED;
1525 }
1526
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001527 clear_view_pending_list(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001528
1529 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001530 ivi_view = get_ivi_view(ivilayer, pSurface[i]);
1531 if (!ivi_view)
1532 ivi_view = ivi_view_create(ivilayer, pSurface[i]);
1533
1534 assert(ivi_view != NULL);
1535
1536 wl_list_remove(&ivi_view->pending_link);
1537 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001538 }
1539
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001540 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001541
1542 return IVI_SUCCEEDED;
1543}
1544
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001545int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001546ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
1547 bool newVisibility)
1548{
1549 struct ivi_layout_surface_properties *prop = NULL;
1550
1551 if (ivisurf == NULL) {
1552 weston_log("ivi_layout_surface_set_visibility: invalid argument\n");
1553 return IVI_FAILED;
1554 }
1555
1556 prop = &ivisurf->pending.prop;
1557 prop->visibility = newVisibility;
1558
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001559 if (ivisurf->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001560 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001561 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001562 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001563
1564 return IVI_SUCCEEDED;
1565}
1566
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001567int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001568ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
1569 wl_fixed_t opacity)
1570{
1571 struct ivi_layout_surface_properties *prop = NULL;
1572
Nobuhiko Tanibataa86226c2015-06-22 15:29:20 +09001573 if (ivisurf == NULL ||
1574 opacity < wl_fixed_from_double(0.0) ||
1575 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001576 weston_log("ivi_layout_surface_set_opacity: invalid argument\n");
1577 return IVI_FAILED;
1578 }
1579
1580 prop = &ivisurf->pending.prop;
1581 prop->opacity = opacity;
1582
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001583 if (ivisurf->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001584 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001585 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001586 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001587
1588 return IVI_SUCCEEDED;
1589}
1590
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001591int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001592ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
1593 int32_t x, int32_t y,
1594 int32_t width, int32_t height)
1595{
1596 struct ivi_layout_surface_properties *prop = NULL;
1597
1598 if (ivisurf == NULL) {
1599 weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n");
1600 return IVI_FAILED;
1601 }
1602
1603 prop = &ivisurf->pending.prop;
1604 prop->start_x = prop->dest_x;
1605 prop->start_y = prop->dest_y;
1606 prop->dest_x = x;
1607 prop->dest_y = y;
1608 prop->start_width = prop->dest_width;
1609 prop->start_height = prop->dest_height;
1610 prop->dest_width = width;
1611 prop->dest_height = height;
1612
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001613 if (ivisurf->prop.dest_x != x || ivisurf->prop.dest_y != y ||
1614 ivisurf->prop.dest_width != width ||
1615 ivisurf->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001616 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001617 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001618 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001619
1620 return IVI_SUCCEEDED;
1621}
1622
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001623static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001624ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf,
1625 enum wl_output_transform orientation)
1626{
1627 struct ivi_layout_surface_properties *prop = NULL;
1628
1629 if (ivisurf == NULL) {
1630 weston_log("ivi_layout_surface_set_orientation: invalid argument\n");
1631 return IVI_FAILED;
1632 }
1633
1634 prop = &ivisurf->pending.prop;
1635 prop->orientation = orientation;
1636
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001637 if (ivisurf->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001638 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001639 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001640 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001641
1642 return IVI_SUCCEEDED;
1643}
1644
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001645static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001646ivi_layout_screen_add_layer(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001647 struct ivi_layout_layer *addlayer)
1648{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001649 struct ivi_layout_screen *iviscrn;
1650
1651 if (output == NULL || addlayer == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001652 weston_log("ivi_layout_screen_add_layer: invalid argument\n");
1653 return IVI_FAILED;
1654 }
1655
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001656 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001657
Ucan, Emre (ADITG/SW1)f46306f2016-03-16 13:37:07 +00001658 wl_list_remove(&addlayer->pending.link);
1659 wl_list_insert(&iviscrn->pending.layer_list, &addlayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001660
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001661 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001662
1663 return IVI_SUCCEEDED;
1664}
1665
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001666static int32_t
Ucan, Emre (ADITG/SW1)deee8582017-03-02 08:47:33 +00001667ivi_layout_screen_remove_layer(struct weston_output *output,
1668 struct ivi_layout_layer *removelayer)
1669{
1670 struct ivi_layout_screen *iviscrn;
1671
1672 if (output == NULL || removelayer == NULL) {
1673 weston_log("ivi_layout_screen_remove_layer: invalid argument\n");
1674 return IVI_FAILED;
1675 }
1676
1677 iviscrn = get_screen_from_output(output);
1678
1679 wl_list_remove(&removelayer->pending.link);
1680 wl_list_init(&removelayer->pending.link);
1681
1682 iviscrn->order.dirty = 1;
1683
1684 return IVI_SUCCEEDED;
1685}
1686
1687static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001688ivi_layout_screen_set_render_order(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001689 struct ivi_layout_layer **pLayer,
1690 const int32_t number)
1691{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001692 struct ivi_layout_screen *iviscrn;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001693 struct ivi_layout_layer *ivilayer = NULL;
1694 struct ivi_layout_layer *next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001695 int32_t i = 0;
1696
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001697 if (output == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001698 weston_log("ivi_layout_screen_set_render_order: invalid argument\n");
1699 return IVI_FAILED;
1700 }
1701
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001702 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001703
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001704 wl_list_for_each_safe(ivilayer, next,
1705 &iviscrn->pending.layer_list, pending.link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001706 wl_list_remove(&ivilayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001707 wl_list_init(&ivilayer->pending.link);
1708 }
1709
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001710 assert(wl_list_empty(&iviscrn->pending.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001711
1712 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)4e221f02016-03-16 13:37:08 +00001713 wl_list_remove(&pLayer[i]->pending.link);
1714 wl_list_insert(&iviscrn->pending.layer_list,
1715 &pLayer[i]->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001716 }
1717
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001718 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001719
1720 return IVI_SUCCEEDED;
1721}
1722
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001723/**
1724 * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot.
1725 * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management.
1726 * This function is used to get the result of drawing by clients.
1727 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001728static struct weston_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001729ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf)
1730{
1731 return ivisurf != NULL ? ivisurf->surface : NULL;
1732}
1733
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001734static int32_t
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001735ivi_layout_surface_get_size(struct ivi_layout_surface *ivisurf,
1736 int32_t *width, int32_t *height,
1737 int32_t *stride)
1738{
1739 int32_t w;
1740 int32_t h;
1741 const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */
1742
1743 if (ivisurf == NULL || ivisurf->surface == NULL) {
1744 weston_log("%s: invalid argument\n", __func__);
1745 return IVI_FAILED;
1746 }
1747
1748 weston_surface_get_content_size(ivisurf->surface, &w, &h);
1749
1750 if (width != NULL)
1751 *width = w;
1752
1753 if (height != NULL)
1754 *height = h;
1755
1756 if (stride != NULL)
1757 *stride = w * bytespp;
1758
1759 return IVI_SUCCEEDED;
1760}
1761
1762static int32_t
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001763ivi_layout_layer_add_listener(struct ivi_layout_layer *ivilayer,
1764 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001765{
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001766 if (ivilayer == NULL || listener == NULL) {
1767 weston_log("ivi_layout_layer_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001768 return IVI_FAILED;
1769 }
1770
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001771 wl_signal_add(&ivilayer->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001772
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001773 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001774}
1775
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001776static const struct ivi_layout_surface_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001777ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf)
1778{
1779 if (ivisurf == NULL) {
1780 weston_log("ivi_layout_get_properties_of_surface: invalid argument\n");
1781 return NULL;
1782 }
1783
1784 return &ivisurf->prop;
1785}
1786
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001787static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001788ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer,
1789 struct ivi_layout_surface *addsurf)
1790{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001791 struct ivi_layout_view *ivi_view;
1792
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001793 if (ivilayer == NULL || addsurf == NULL) {
1794 weston_log("ivi_layout_layer_add_surface: invalid argument\n");
1795 return IVI_FAILED;
1796 }
1797
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001798 ivi_view = get_ivi_view(ivilayer, addsurf);
1799 if (!ivi_view)
1800 ivi_view = ivi_view_create(ivilayer, addsurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001801
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001802 wl_list_remove(&ivi_view->pending_link);
1803 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001804
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001805 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001806
1807 return IVI_SUCCEEDED;
1808}
1809
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001810static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001811ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
1812 struct ivi_layout_surface *remsurf)
1813{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001814 struct ivi_layout_view *ivi_view;
1815
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001816 if (ivilayer == NULL || remsurf == NULL) {
1817 weston_log("ivi_layout_layer_remove_surface: invalid argument\n");
1818 return;
1819 }
1820
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001821 ivi_view = get_ivi_view(ivilayer, remsurf);
1822 if (ivi_view) {
1823 wl_list_remove(&ivi_view->pending_link);
1824 wl_list_init(&ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001825
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001826 ivilayer->order.dirty = 1;
1827 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001828}
1829
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001830static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001831ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf,
1832 int32_t x, int32_t y,
1833 int32_t width, int32_t height)
1834{
1835 struct ivi_layout_surface_properties *prop = NULL;
1836
1837 if (ivisurf == NULL) {
1838 weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n");
1839 return IVI_FAILED;
1840 }
1841
1842 prop = &ivisurf->pending.prop;
1843 prop->source_x = x;
1844 prop->source_y = y;
1845 prop->source_width = width;
1846 prop->source_height = height;
1847
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001848 if (ivisurf->prop.source_x != x || ivisurf->prop.source_y != y ||
1849 ivisurf->prop.source_width != width ||
1850 ivisurf->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001851 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001852 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001853 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001854
1855 return IVI_SUCCEEDED;
1856}
1857
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001858int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001859ivi_layout_commit_changes(void)
1860{
1861 struct ivi_layout *layout = get_instance();
1862
1863 commit_surface_list(layout);
1864 commit_layer_list(layout);
1865 commit_screen_list(layout);
1866
1867 commit_transition(layout);
1868
1869 commit_changes(layout);
1870 send_prop(layout);
1871 weston_compositor_schedule_repaint(layout->compositor);
1872
1873 return IVI_SUCCEEDED;
1874}
1875
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001876static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001877ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer,
1878 enum ivi_layout_transition_type type,
1879 uint32_t duration)
1880{
1881 if (ivilayer == NULL) {
1882 weston_log("%s: invalid argument\n", __func__);
1883 return -1;
1884 }
1885
1886 ivilayer->pending.prop.transition_type = type;
1887 ivilayer->pending.prop.transition_duration = duration;
1888
1889 return 0;
1890}
1891
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001892static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001893ivi_layout_layer_set_fade_info(struct ivi_layout_layer* ivilayer,
1894 uint32_t is_fade_in,
1895 double start_alpha, double end_alpha)
1896{
1897 if (ivilayer == NULL) {
1898 weston_log("%s: invalid argument\n", __func__);
1899 return -1;
1900 }
1901
1902 ivilayer->pending.prop.is_fade_in = is_fade_in;
1903 ivilayer->pending.prop.start_alpha = start_alpha;
1904 ivilayer->pending.prop.end_alpha = end_alpha;
1905
1906 return 0;
1907}
1908
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001909static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001910ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf,
1911 uint32_t duration)
1912{
1913 struct ivi_layout_surface_properties *prop;
1914
1915 if (ivisurf == NULL) {
1916 weston_log("%s: invalid argument\n", __func__);
1917 return -1;
1918 }
1919
1920 prop = &ivisurf->pending.prop;
1921 prop->transition_duration = duration*10;
1922 return 0;
1923}
1924
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001925static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001926ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf,
1927 enum ivi_layout_transition_type type,
1928 uint32_t duration)
1929{
1930 struct ivi_layout_surface_properties *prop;
1931
1932 if (ivisurf == NULL) {
1933 weston_log("%s: invalid argument\n", __func__);
1934 return -1;
1935 }
1936
1937 prop = &ivisurf->pending.prop;
1938 prop->transition_type = type;
1939 prop->transition_duration = duration;
1940 return 0;
1941}
1942
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001943static int32_t
1944ivi_layout_surface_dump(struct weston_surface *surface,
1945 void *target, size_t size,int32_t x, int32_t y,
1946 int32_t width, int32_t height)
1947{
1948 int result = 0;
1949
1950 if (surface == NULL) {
1951 weston_log("%s: invalid argument\n", __func__);
1952 return IVI_FAILED;
1953 }
1954
1955 result = weston_surface_copy_content(
1956 surface, target, size,
1957 x, y, width, height);
1958
1959 return result == 0 ? IVI_SUCCEEDED : IVI_FAILED;
1960}
1961
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001962/**
1963 * methods of interaction between ivi-shell with ivi-layout
1964 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001965
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001966void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001967ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf,
1968 int32_t width, int32_t height)
1969{
1970 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001971
Nobuhiko Tanibatae6cc9972015-04-27 16:54:01 +09001972 /* emit callback which is set by ivi-layout api user */
1973 wl_signal_emit(&layout->surface_notification.configure_changed,
1974 ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001975}
1976
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001977struct ivi_layout_surface*
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001978ivi_layout_surface_create(struct weston_surface *wl_surface,
1979 uint32_t id_surface)
1980{
1981 struct ivi_layout *layout = get_instance();
1982 struct ivi_layout_surface *ivisurf = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001983
1984 if (wl_surface == NULL) {
1985 weston_log("ivi_layout_surface_create: invalid argument\n");
1986 return NULL;
1987 }
1988
1989 ivisurf = get_surface(&layout->surface_list, id_surface);
1990 if (ivisurf != NULL) {
1991 if (ivisurf->surface != NULL) {
1992 weston_log("id_surface(%d) is already created\n", id_surface);
1993 return NULL;
1994 }
1995 }
1996
1997 ivisurf = calloc(1, sizeof *ivisurf);
1998 if (ivisurf == NULL) {
1999 weston_log("fails to allocate memory\n");
2000 return NULL;
2001 }
2002
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002003 wl_signal_init(&ivisurf->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002004 ivisurf->id_surface = id_surface;
2005 ivisurf->layout = layout;
2006
2007 ivisurf->surface = wl_surface;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002008
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002009 ivisurf->surface->width_from_buffer = 0;
2010 ivisurf->surface->height_from_buffer = 0;
2011
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002012 init_surface_properties(&ivisurf->prop);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002013
2014 ivisurf->pending.prop = ivisurf->prop;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002015
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00002016 wl_list_init(&ivisurf->view_list);
2017
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002018 wl_list_insert(&layout->surface_list, &ivisurf->link);
2019
2020 wl_signal_emit(&layout->surface_notification.created, ivisurf);
2021
2022 return ivisurf;
2023}
2024
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002025void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002026ivi_layout_init_with_compositor(struct weston_compositor *ec)
2027{
2028 struct ivi_layout *layout = get_instance();
2029
2030 layout->compositor = ec;
2031
2032 wl_list_init(&layout->surface_list);
2033 wl_list_init(&layout->layer_list);
2034 wl_list_init(&layout->screen_list);
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00002035 wl_list_init(&layout->view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002036
2037 wl_signal_init(&layout->layer_notification.created);
2038 wl_signal_init(&layout->layer_notification.removed);
2039
2040 wl_signal_init(&layout->surface_notification.created);
2041 wl_signal_init(&layout->surface_notification.removed);
2042 wl_signal_init(&layout->surface_notification.configure_changed);
2043
2044 /* Add layout_layer at the last of weston_compositor.layer_list */
Quentin Glidic82681572016-12-17 13:40:51 +01002045 weston_layer_init(&layout->layout_layer, ec);
2046 weston_layer_set_position(&layout->layout_layer,
2047 WESTON_LAYER_POSITION_NORMAL);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002048
2049 create_screen(ec);
2050
2051 layout->transitions = ivi_layout_transition_set_create(ec);
2052 wl_list_init(&layout->pending_transition_list);
2053}
2054
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002055static struct ivi_layout_interface ivi_layout_interface = {
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002056 /**
2057 * commit all changes
2058 */
2059 .commit_changes = ivi_layout_commit_changes,
2060
2061 /**
2062 * surface controller interfaces
2063 */
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00002064 .add_listener_create_surface = ivi_layout_add_listener_create_surface,
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00002065 .add_listener_remove_surface = ivi_layout_add_listener_remove_surface,
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00002066 .add_listener_configure_surface = ivi_layout_add_listener_configure_surface,
Pekka Paalaneneaa43fc2016-04-12 16:06:58 +03002067 .get_surface = shell_get_ivi_layout_surface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002068 .get_surfaces = ivi_layout_get_surfaces,
2069 .get_id_of_surface = ivi_layout_get_id_of_surface,
2070 .get_surface_from_id = ivi_layout_get_surface_from_id,
2071 .get_properties_of_surface = ivi_layout_get_properties_of_surface,
2072 .get_surfaces_on_layer = ivi_layout_get_surfaces_on_layer,
2073 .surface_set_visibility = ivi_layout_surface_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002074 .surface_set_opacity = ivi_layout_surface_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002075 .surface_set_source_rectangle = ivi_layout_surface_set_source_rectangle,
2076 .surface_set_destination_rectangle = ivi_layout_surface_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002077 .surface_set_orientation = ivi_layout_surface_set_orientation,
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00002078 .surface_add_listener = ivi_layout_surface_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002079 .surface_get_weston_surface = ivi_layout_surface_get_weston_surface,
2080 .surface_set_transition = ivi_layout_surface_set_transition,
2081 .surface_set_transition_duration = ivi_layout_surface_set_transition_duration,
2082
2083 /**
2084 * layer controller interfaces
2085 */
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +00002086 .add_listener_create_layer = ivi_layout_add_listener_create_layer,
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +00002087 .add_listener_remove_layer = ivi_layout_add_listener_remove_layer,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002088 .layer_create_with_dimension = ivi_layout_layer_create_with_dimension,
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09002089 .layer_destroy = ivi_layout_layer_destroy,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002090 .get_layers = ivi_layout_get_layers,
2091 .get_id_of_layer = ivi_layout_get_id_of_layer,
2092 .get_layer_from_id = ivi_layout_get_layer_from_id,
2093 .get_properties_of_layer = ivi_layout_get_properties_of_layer,
2094 .get_layers_under_surface = ivi_layout_get_layers_under_surface,
2095 .get_layers_on_screen = ivi_layout_get_layers_on_screen,
2096 .layer_set_visibility = ivi_layout_layer_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002097 .layer_set_opacity = ivi_layout_layer_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002098 .layer_set_source_rectangle = ivi_layout_layer_set_source_rectangle,
2099 .layer_set_destination_rectangle = ivi_layout_layer_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002100 .layer_set_orientation = ivi_layout_layer_set_orientation,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002101 .layer_add_surface = ivi_layout_layer_add_surface,
2102 .layer_remove_surface = ivi_layout_layer_remove_surface,
2103 .layer_set_render_order = ivi_layout_layer_set_render_order,
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00002104 .layer_add_listener = ivi_layout_layer_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002105 .layer_set_transition = ivi_layout_layer_set_transition,
2106
2107 /**
Ucan, Emre (ADITG/SW1)6d89b1c2016-03-17 15:30:49 +00002108 * screen controller interfaces
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002109 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002110 .get_screens_under_layer = ivi_layout_get_screens_under_layer,
2111 .screen_add_layer = ivi_layout_screen_add_layer,
Ucan, Emre (ADITG/SW1)deee8582017-03-02 08:47:33 +00002112 .screen_remove_layer = ivi_layout_screen_remove_layer,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002113 .screen_set_render_order = ivi_layout_screen_set_render_order,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002114
2115 /**
2116 * animation
2117 */
2118 .transition_move_layer_cancel = ivi_layout_transition_move_layer_cancel,
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002119 .layer_set_fade_info = ivi_layout_layer_set_fade_info,
2120
2121 /**
2122 * surface content dumping for debugging
2123 */
2124 .surface_get_size = ivi_layout_surface_get_size,
2125 .surface_dump = ivi_layout_surface_dump,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002126};
2127
2128int
2129load_controller_modules(struct weston_compositor *compositor, const char *modules,
2130 int *argc, char *argv[])
2131{
2132 const char *p, *end;
2133 char buffer[256];
2134 int (*controller_module_init)(struct weston_compositor *compositor,
2135 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002136 const struct ivi_layout_interface *interface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002137 size_t interface_version);
2138
2139 if (modules == NULL)
2140 return 0;
2141
2142 p = modules;
2143 while (*p) {
2144 end = strchrnul(p, ',');
2145 snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p);
2146
Quentin Glidic8af2bec2016-12-02 14:21:46 +01002147 controller_module_init =
2148 wet_load_module_entrypoint(buffer,
2149 "controller_module_init");
Pekka Paalanen97246c02015-03-26 15:47:29 +02002150 if (!controller_module_init)
2151 return -1;
2152
2153 if (controller_module_init(compositor, argc, argv,
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002154 &ivi_layout_interface,
2155 sizeof(struct ivi_layout_interface)) != 0) {
Pekka Paalanen97246c02015-03-26 15:47:29 +02002156 weston_log("ivi-shell: Initialization of controller module fails");
2157 return -1;
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002158 }
2159
2160 p = end;
2161 while (*p == ',')
2162 p++;
2163 }
2164
2165 return 0;
2166}