"Initial commit to Gerrit"
[profile/ivi/cogl.git] / cogl / winsys / cogl-winsys-egl-private.h
1 /*
2  * Cogl
3  *
4  * An object oriented GL/GLES Abstraction/Utility Layer
5  *
6  * Copyright (C) 2011 Intel Corporation.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20  *
21  *
22  */
23
24 #ifndef __COGL_WINSYS_EGL_PRIVATE_H
25 #define __COGL_WINSYS_EGL_PRIVATE_H
26
27 #include "cogl-defines.h"
28 #include "cogl-winsys-private.h"
29 #include "cogl-context.h"
30 #include "cogl-context-private.h"
31 #include "cogl-framebuffer-private.h"
32
33 typedef struct _CoglWinsysEGLVtable
34 {
35   gboolean
36   (* display_setup) (CoglDisplay *display,
37                      GError **error);
38   void
39   (* display_destroy) (CoglDisplay *display);
40
41   gboolean
42   (* try_create_context) (CoglDisplay *display,
43                           EGLint *attribs,
44                           GError **error);
45
46   gboolean
47   (* context_created) (CoglDisplay *display,
48                        GError **error);
49
50   void
51   (* cleanup_context) (CoglDisplay *display);
52
53   gboolean
54   (* context_init) (CoglContext *context, GError **error);
55
56   void
57   (* context_deinit) (CoglContext *context);
58
59   gboolean
60   (* onscreen_init) (CoglOnscreen *onscreen,
61                      EGLConfig config,
62                      GError **error);
63   void
64   (* onscreen_deinit) (CoglOnscreen *onscreen);
65
66   int
67   (* add_config_attributes) (CoglDisplay *display,
68                              CoglFramebufferConfig *config,
69                              EGLint *attributes);
70 } CoglWinsysEGLVtable;
71
72 typedef enum _CoglEGLWinsysFeature
73 {
74   COGL_EGL_WINSYS_FEATURE_SWAP_REGION                   =1L<<0,
75   COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_X11_PIXMAP     =1L<<1,
76   COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_WAYLAND_BUFFER =1L<<2,
77   COGL_EGL_WINSYS_FEATURE_SURFACELESS_OPENGL            =1L<<3,
78   COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES1             =1L<<4,
79   COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES2             =1L<<5
80 } CoglEGLWinsysFeature;
81
82 typedef struct _CoglRendererEGL
83 {
84   CoglEGLWinsysFeature private_features;
85
86   EGLDisplay edpy;
87
88   EGLint egl_version_major;
89   EGLint egl_version_minor;
90
91   /* Data specific to the EGL platform */
92   void *platform;
93   /* vtable for platform specific parts */
94   const CoglWinsysEGLVtable *platform_vtable;
95
96   /* Function pointers for EGL specific extensions */
97 #define COGL_WINSYS_FEATURE_BEGIN(a, b, c, d)
98
99 #define COGL_WINSYS_FEATURE_FUNCTION(ret, name, args) \
100   ret (APIENTRY * pf_ ## name) args;
101
102 #define COGL_WINSYS_FEATURE_END()
103
104 #include "cogl-winsys-egl-feature-functions.h"
105
106 #undef COGL_WINSYS_FEATURE_BEGIN
107 #undef COGL_WINSYS_FEATURE_FUNCTION
108 #undef COGL_WINSYS_FEATURE_END
109 } CoglRendererEGL;
110
111 typedef struct _CoglDisplayEGL
112 {
113   EGLContext egl_context;
114   EGLSurface dummy_surface;
115   EGLSurface egl_surface;
116
117   EGLConfig egl_config;
118   gboolean found_egl_config;
119   gboolean stencil_disabled;
120
121   /* Platform specific display data */
122   void *platform;
123 } CoglDisplayEGL;
124
125 typedef struct _CoglContextEGL
126 {
127   EGLSurface current_surface;
128 } CoglContextEGL;
129
130 typedef struct _CoglOnscreenEGL
131 {
132   EGLSurface egl_surface;
133
134   /* Platform specific data */
135   void *platform;
136 } CoglOnscreenEGL;
137
138 const CoglWinsysVtable *
139 _cogl_winsys_egl_get_vtable (void);
140
141 #ifdef EGL_KHR_image_base
142 EGLImageKHR
143 _cogl_egl_create_image (CoglContext *ctx,
144                         EGLenum target,
145                         EGLClientBuffer buffer,
146                         const EGLint *attribs);
147
148 void
149 _cogl_egl_destroy_image (CoglContext *ctx,
150                          EGLImageKHR image);
151 #endif
152
153 gboolean
154 _cogl_winsys_egl_renderer_connect_common (CoglRenderer *renderer,
155                                           GError **error);
156
157 #endif /* __COGL_WINSYS_EGL_PRIVATE_H */