summaryrefslogtreecommitdiff
path: root/ivi-layermanagement-examples/multi-touch-viewer/include/window.h
blob: d81dda632b88eb8c193862c719689d028657df71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/***************************************************************************
 *
 * Copyright (c) 2015 Advanced Driver Information Technology.
 * This code is developed by Advanced Driver Information Technology.
 * Copyright of Advanced Driver Information Technology, Bosch, and DENSO.
 * All rights reserved.
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ****************************************************************************/
#ifndef WINDOW_H
#define WINDOW_H

#include <wayland-client.h>
#include <wayland-egl.h>
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include "ivi-application-client-protocol.h"

#define _UNUSED_(arg) (void)arg;

struct WaylandDisplay;
struct WaylandEglWindow;

typedef void (*window_redraw_handler_t)
    (struct WaylandEglWindow *p_window, void *p_data);

typedef void (*display_global_handler_t)
    (struct WaylandDisplay *p_display, uint32_t name, const char *p_interface,
     uint32_t version, void *p_data);

struct Task
{
    void (*run)(struct Task *p_task, uint32_t events);
    struct wl_list link;
};

enum TypeOfShell
{
    WL_SHELL  = 1,
    IVI_SHELL = 2
};

struct WaylandDisplay
{
    struct Task           display_task;
    struct wl_display    *p_display;
    struct wl_registry   *p_registry;
    struct wl_compositor *p_compositor;
    struct wl_shell      *p_shell;
    struct ivi_application *p_ivi_application;
    EGLDisplay            egldisplay;
    EGLConfig             eglconfig;
    EGLContext            eglcontext;
    enum TypeOfShell      shell_type;

    int                   running;
    int                   epoll_fd;
    int                   display_fd;
    uint32_t              display_fd_events;

    display_global_handler_t global_handler;

    struct wl_list        global_list;
    struct wl_list        surface_list;
    struct wl_list        deferred_list;

    void                 *p_user_data;
};

struct WaylandEglWindow
{
    struct Task              redraw_task;
    struct wl_list           link;
    struct WaylandDisplay   *p_display;
    struct wl_surface       *p_surface;
    struct wl_shell_surface *p_shell_surface;
    struct ivi_surface      *p_ivi_surface;
    struct wl_egl_window    *p_egl_window;
    struct wl_callback      *p_frame_cb;
    EGLSurface               eglsurface;
    struct {
        GLuint rotation_uniform;
        GLuint pos;
        GLuint col;
    } gl;
    struct {
        int width;
        int height;
    } geometry;
    int configured;
    int redraw_scheduled;
    int redraw_needed;
    window_redraw_handler_t redraw_handler;
    uint32_t time;
    int type;
    void *p_user_data;
};

struct WaylandDisplay*
CreateDisplay(int argc, char **argv, enum TypeOfShell shell_type);

void
DestroyDisplay(struct WaylandDisplay *p_display);

struct WaylandEglWindow*
CreateEglWindow(struct WaylandDisplay *p_display, const char *p_window_title,
                uint32_t surface_id);

void
WindowScheduleRedraw(struct WaylandEglWindow *p_window);

void
WindowScheduleResize(struct WaylandEglWindow *p_window, int width, int height);

void
DisplayRun(struct WaylandDisplay *p_display);

void
DisplayExit(struct WaylandDisplay *p_display);

int
DisplayAcquireWindowSurface(struct WaylandDisplay *p_display,
    struct WaylandEglWindow *p_window);

void
DisplaySetGlobalHandler(struct WaylandDisplay *p_display,
    display_global_handler_t handler);

void
DisplaySetUserData(struct WaylandDisplay *p_display, void *p_data);

void
WindowCreateSurface(struct WaylandEglWindow *p_window);

#endif