• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /***************************************************************************
2  *
3  * Copyright (c) 2015 Advanced Driver Information Technology.
4  * This code is developed by Advanced Driver Information Technology.
5  * Copyright of Advanced Driver Information Technology, Bosch, and DENSO.
6  * All rights reserved.
7  *
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *        http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  ****************************************************************************/
22 #ifndef WINDOW_H
23 #define WINDOW_H
24 
25 #include <wayland-client.h>
26 #include <wayland-egl.h>
27 #include <EGL/egl.h>
28 #include <GLES2/gl2.h>
29 #include "ivi-application-client-protocol.h"
30 
31 #define _UNUSED_(arg) (void)arg;
32 
33 struct WaylandDisplay;
34 struct WaylandEglWindow;
35 
36 typedef void (*window_redraw_handler_t)
37     (struct WaylandEglWindow *p_window, void *p_data);
38 
39 typedef void (*display_global_handler_t)
40     (struct WaylandDisplay *p_display, uint32_t name, const char *p_interface,
41      uint32_t version, void *p_data);
42 
43 struct Task
44 {
45     void (*run)(struct Task *p_task, uint32_t events);
46     struct wl_list link;
47 };
48 
49 struct WaylandDisplay
50 {
51     struct Task           display_task;
52     struct wl_display    *p_display;
53     struct wl_registry   *p_registry;
54     struct wl_compositor *p_compositor;
55     struct wl_shell      *p_shell;
56     struct ivi_application *p_ivi_application;
57     EGLDisplay            egldisplay;
58     EGLConfig             eglconfig;
59     EGLContext            eglcontext;
60 
61     int                   running;
62     int                   epoll_fd;
63     int                   display_fd;
64     uint32_t              display_fd_events;
65 
66     display_global_handler_t global_handler;
67 
68     struct wl_list        global_list;
69     struct wl_list        surface_list;
70     struct wl_list        deferred_list;
71 
72     void                 *p_user_data;
73 };
74 
75 struct WaylandEglWindow
76 {
77     struct Task              redraw_task;
78     struct wl_list           link;
79     struct WaylandDisplay   *p_display;
80     struct wl_surface       *p_surface;
81     struct wl_shell_surface *p_shell_surface;
82     struct ivi_surface      *p_ivi_surface;
83     struct wl_egl_window    *p_egl_window;
84     struct wl_callback      *p_frame_cb;
85     EGLSurface               eglsurface;
86     struct {
87         GLuint rotation_uniform;
88         GLuint pos;
89         GLuint col;
90     } gl;
91     struct {
92         int width;
93         int height;
94     } geometry;
95     int configured;
96     int redraw_scheduled;
97     int redraw_needed;
98     window_redraw_handler_t redraw_handler;
99     uint32_t time;
100     int type;
101     void *p_user_data;
102 };
103 
104 struct WaylandDisplay*
105 CreateDisplay(int argc, char **argv);
106 
107 void
108 DestroyDisplay(struct WaylandDisplay *p_display);
109 
110 struct WaylandEglWindow*
111 CreateEglWindow(struct WaylandDisplay *p_display, const char *p_window_title,
112                 uint32_t surface_id);
113 
114 void
115 WindowScheduleRedraw(struct WaylandEglWindow *p_window);
116 
117 void
118 WindowScheduleResize(struct WaylandEglWindow *p_window, int width, int height);
119 
120 void
121 DisplayRun(struct WaylandDisplay *p_display);
122 
123 void
124 DisplayExit(struct WaylandDisplay *p_display);
125 
126 int
127 DisplayAcquireWindowSurface(struct WaylandDisplay *p_display,
128     struct WaylandEglWindow *p_window);
129 
130 void
131 DisplaySetGlobalHandler(struct WaylandDisplay *p_display,
132     display_global_handler_t handler);
133 
134 void
135 DisplaySetUserData(struct WaylandDisplay *p_display, void *p_data);
136 
137 void
138 WindowCreateSurface(struct WaylandEglWindow *p_window);
139 
140 #endif
141