summaryrefslogtreecommitdiff
path: root/EGL/yagl_display.h
blob: 00855ff9f262483e951f3cb1e8bb4d5909fb9585 (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
#ifndef _YAGL_DISPLAY_H_
#define _YAGL_DISPLAY_H_

#include "yagl_export.h"
#include "yagl_types.h"
#include "yagl_list.h"
#include "EGL/egl.h"
#include "EGL/eglext.h"
#include <pthread.h>

struct yagl_surface;
struct yagl_context;
struct yagl_image;

struct yagl_display
{
    struct yagl_list list;

    EGLNativeDisplayType display_id;

    Display *x_dpy;

    yagl_host_handle host_dpy;

    int xshm_images_supported;

    int xshm_pixmaps_supported;

    pthread_mutex_t mutex;

    int prepared;

    struct yagl_list surfaces;

    struct yagl_list contexts;

    struct yagl_list images;
};

void yagl_display_init(struct yagl_display *dpy,
                       EGLNativeDisplayType display_id,
                       Display *x_dpy,
                       yagl_host_handle host_dpy);

void yagl_display_cleanup(struct yagl_display *dpy);

struct yagl_display *yagl_display_get(EGLDisplay native_dpy);

struct yagl_display *yagl_display_get_x(Display *x_dpy);

struct yagl_display *yagl_display_add(EGLNativeDisplayType display_id,
                                      yagl_host_handle host_dpy);

void yagl_display_prepare(struct yagl_display *dpy);

int yagl_display_is_prepared(struct yagl_display *dpy);

void yagl_display_terminate(struct yagl_display *dpy);

/*
 * Surfaces.
 * @{
 */

/*
 * This acquires 'sfc', so the caller should
 * release 'sfc' if he doesn't want to use it and wants it to belong to the
 * display alone.
 */
int yagl_display_surface_add(struct yagl_display *dpy,
                             struct yagl_surface *sfc);

/*
 * Acquires a surface by handle. Be sure to release the surface when
 * you're done.
 */
struct yagl_surface *yagl_display_surface_acquire(struct yagl_display *dpy,
                                                  EGLSurface handle);

int yagl_display_surface_remove(struct yagl_display *dpy,
                                EGLSurface handle);

/*
 * @}
 */

/*
 * Contexts.
 * @{
 */

/*
 * This acquires 'ctx', so the caller should
 * release 'ctx' if he doesn't want to use it and wants it to belong to the
 * display alone.
 */
void yagl_display_context_add(struct yagl_display *dpy,
                              struct yagl_context *ctx);

/*
 * Acquires a context by handle. Be sure to release the context when
 * you're done.
 */
struct yagl_context *yagl_display_context_acquire(struct yagl_display *dpy,
                                                  EGLContext handle);

void yagl_display_context_remove(struct yagl_display *dpy,
                                 EGLContext handle);

/*
 * @}
 */

/*
 * Images.
 * @{
 */

/*
 * This acquires 'image', so the caller should
 * release 'image' if he doesn't want to use it and wants it to belong to the
 * display alone.
 */
int yagl_display_image_add(struct yagl_display *dpy,
                           struct yagl_image *image);

/*
 * Acquires an image by handle. Be sure to release the image when
 * you're done.
 */
struct yagl_image *yagl_display_image_acquire(struct yagl_display *dpy,
                                              EGLImageKHR handle);

int yagl_display_image_remove(struct yagl_display *dpy,
                              EGLImageKHR handle);

/*
 * @}
 */

#endif