Qt 4.8
qegl_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QEGL_P_H
43 #define QEGL_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists for the convenience of
50 // the QtOpenGL and QtOpenVG modules. This header file may change from
51 // version to version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
57 
58 #ifndef QT_NO_EGL
59 #if defined(QT_OPENGL_ES_2)
60 # include <GLES2/gl2.h>
61 #endif
62 
63 #if defined(QT_GLES_EGL)
64 # include <GLES/egl.h>
65 #else
66 # include <EGL/egl.h>
67 #endif
68 #if !defined(EGL_VERSION_1_2)
69 typedef unsigned int EGLenum;
70 typedef void *EGLClientBuffer;
71 #endif
72 #else
73 
74 //types from egltypes.h for compiling stub without EGL headers
75 typedef int EGLBoolean;
76 typedef int EGLint;
77 typedef int EGLenum;
78 typedef int NativeDisplayType;
79 typedef void* NativeWindowType;
80 typedef void* NativePixmapType;
81 typedef int EGLDisplay;
82 typedef int EGLConfig;
83 typedef int EGLSurface;
84 typedef int EGLContext;
85 typedef int EGLClientBuffer;
86 #define EGL_NONE 0x3038 /* Attrib list terminator */
87 
88 #endif
89 
90 #if defined(Q_WS_X11)
91 // If <EGL/egl.h> included <X11/Xlib.h>, then the global namespace
92 // may have been polluted with X #define's. The following makes sure
93 // the X11 headers were included properly and then cleans things up.
94 #include <X11/Xlib.h>
95 #include <X11/Xutil.h>
96 #undef Bool
97 #undef Status
98 #undef None
99 #undef KeyPress
100 #undef KeyRelease
101 #undef FocusIn
102 #undef FocusOut
103 #undef Type
104 #undef FontChange
105 #undef CursorShape
106 #undef Unsorted
107 #undef GrayScale
108 #endif
109 
110 // Internally we use the EGL-prefixed native types which are used in EGL >= 1.3.
111 // For older versions of EGL, we have to define these types ourselves here:
112 #if !defined(EGL_VERSION_1_3) && !defined(QEGL_NATIVE_TYPES_DEFINED)
113 #undef EGLNativeWindowType
114 #undef EGLNativePixmapType
115 #undef EGLNativeDisplayType
116 typedef NativeWindowType EGLNativeWindowType;
117 typedef NativePixmapType EGLNativePixmapType;
118 typedef NativeDisplayType EGLNativeDisplayType;
119 #define QEGL_NATIVE_TYPES_DEFINED 1
120 #endif
121 
123 
124 #include <QtGui/qpaintdevice.h>
125 #include <QFlags>
126 
128 
129 #define QEGL_NO_CONFIG ((EGLConfig)-1)
130 
131 #ifndef EGLAPIENTRY
132 #define EGLAPIENTRY
133 #endif
134 
135 // Try to get some info to debug the symbian build failues:
136 #ifdef Q_OS_SYMBIAN
137 
138 #ifdef EGL_KHR_image
139 #warning "EGL_KHR_image is defined"
140 #else
141 #warning "EGL_KHR_image is NOT defined"
142 #endif
143 
144 #ifdef EGL_KHR_image_base
145 #warning "EGL_KHR_image_base is defined"
146 #else
147 #warning "EGL_KHR_image_base is NOT defined"
148 #endif
149 
150 #ifdef EGL_EGLEXT_PROTOTYPES
151 #warning "EGL_EGLEXT_PROTOTYPES is defined"
152 #else
153 #warning "EGL_EGLEXT_PROTOTYPES NOT not defined"
154 #endif
155 
156 #endif
157 
158 
159 // Declare/define the bits of EGL_KHR_image_base we need:
160 #if !defined(EGL_KHR_image) && !defined(EGL_KHR_image_base)
161 #ifdef Q_OS_SYMBIAN
162 //symbian version of eglext.h differs from the khronos reference
163 typedef int EGLImageKHR;
164 #else
165 typedef void *EGLImageKHR;
166 #endif
167 
168 #if !defined(EGL_NO_IMAGE_KHR)
169 #define EGL_NO_IMAGE_KHR ((EGLImageKHR)0)
170 #endif
171 #if !defined(EGL_IMAGE_PRESERVED_KHR)
172 #define EGL_IMAGE_PRESERVED_KHR 0x30D2
173 #endif
174 #if !defined(EGL_KHR_image_base)
175 #define EGL_KHR_image_base
176 #endif
177 #endif
178 
179 #if !defined(EGL_KHR_image)
180 #define EGL_NATIVE_PIXMAP_KHR 0x30B0
181 #endif
182 #if !defined(EGL_KHR_image_pixmap)
183 #define EGL_KHR_image_pixmap
184 #endif
185 
186 
187 class QEglProperties;
188 
189 namespace QEgl {
190  enum API
191  {
194  };
195 
197  {
200  };
201 
203  {
205  Translucent = 0x01,
206  Renderable = 0x02 // Config will be compatable with the paint engines (VG or GL)
207  };
208  Q_DECLARE_FLAGS(ConfigOptions, ConfigOption)
209 
210  // Most of the time we use the same config for things like widgets & pixmaps, so rather than
211  // go through the eglChooseConfig loop every time, we use defaultConfig, which will return
212  // the config for a particular device/api/option combo. This function assumes that once a
213  // config is chosen for a particular combo, it's safe to always use that combo.
214  Q_GUI_EXPORT EGLConfig defaultConfig(int devType, API api, ConfigOptions options);
215 
217  Q_GUI_EXPORT EGLSurface createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *surfaceAttribs = 0);
218 
220 
221 #ifdef QT_NO_EGL
222  Q_GUI_EXPORT QString errorString(EGLint code = 0);
223 #else
224  Q_GUI_EXPORT QString errorString(EGLint code = eglGetError());
225 #endif
226 
228  Q_GUI_EXPORT bool hasExtension(const char* extensionName);
229 
230  Q_GUI_EXPORT EGLDisplay display();
231 
235 
236  // Extension functions
237  Q_GUI_EXPORT EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
238  Q_GUI_EXPORT EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img);
239  Q_GUI_EXPORT EGLBoolean eglSwapBuffersRegion2NOK(EGLDisplay dpy, EGLSurface surface, EGLint count, const EGLint *rects);
240 
241 #ifdef Q_WS_X11
242  Q_GUI_EXPORT VisualID getCompatibleVisualId(EGLConfig config);
243 #endif
244 }
245 
246 Q_DECLARE_OPERATORS_FOR_FLAGS(QEgl::ConfigOptions)
247 
249 
250 #endif //QEGL_P_H
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
NativePixmapType EGLNativePixmapType
Definition: qegl_p.h:117
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static bool match(const uchar *found, const char *target, uint len)
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
Definition: qglobal.h:92
Definition: qegl_p.h:189
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_GUI_EXPORT QString extensions()
Definition: qegl.cpp:785
NativeWindowType EGLNativeWindowType
Definition: qegl_p.h:116
Q_GUI_EXPORT EGLNativePixmapType nativePixmap(QPixmap *)
Definition: qegl_qpa.cpp:65
Q_GUI_EXPORT QString errorString(EGLint code=eglGetError())
Definition: qegl.cpp:743
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
Q_GUI_EXPORT EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img)
Definition: qegl.cpp:638
void * EGLClientBuffer
Definition: qegl_p.h:70
unsigned int EGLenum
Definition: qegl_p.h:69
ConfigOption
Definition: qegl_p.h:202
Q_GUI_EXPORT bool hasExtension(const char *extensionName)
Definition: qegl.cpp:791
Q_GUI_EXPORT EGLConfig defaultConfig(int devType, API api, ConfigOptions options)
Definition: qegl.cpp:126
void * EGLImageKHR
Definition: qegl_p.h:165
Q_GUI_EXPORT EGLSurface createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *surfaceAttribs=0)
Definition: qegl_x11.cpp:333
Q_GUI_EXPORT EGLNativeDisplayType nativeDisplay()
Definition: qegl_qpa.cpp:55
Q_GUI_EXPORT void dumpAllConfigs()
Definition: qegl.cpp:770
PixelFormatMatch
Definition: qegl_p.h:196
#define ctx
Definition: qgl.cpp:6094
Q_GUI_EXPORT EGLBoolean eglSwapBuffersRegion2NOK(EGLDisplay dpy, EGLSurface surface, EGLint count, const EGLint *rects)
Definition: qegl.cpp:651
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
Q_GUI_EXPORT VisualID getCompatibleVisualId(EGLConfig config)
Definition: qegl_x11.cpp:133
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
Definition: qglobal.h:91
NativeDisplayType EGLNativeDisplayType
Definition: qegl_p.h:118
API
Definition: qegl_p.h:190
Q_GUI_EXPORT EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
Definition: qegl.cpp:625
Q_GUI_EXPORT EGLConfig chooseConfig(const QEglProperties *configAttribs, QEgl::PixelFormatMatch match=QEgl::ExactPixelFormat)
Definition: qegl.cpp:288
Q_GUI_EXPORT EGLNativeWindowType nativeWindow(QWidget *)
Definition: qegl_qpa.cpp:60