source: trunk/src/gui/egl/qegl_p.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 7.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
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
56QT_BEGIN_INCLUDE_NAMESPACE
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)
69typedef unsigned int EGLenum;
70typedef void *EGLClientBuffer;
71#endif
72#else
73
74//types from egltypes.h for compiling stub without EGL headers
75typedef int EGLBoolean;
76typedef int EGLint;
77typedef int EGLenum;
78typedef int NativeDisplayType;
79typedef void* NativeWindowType;
80typedef void* NativePixmapType;
81typedef int EGLDisplay;
82typedef int EGLConfig;
83typedef int EGLSurface;
84typedef int EGLContext;
85typedef 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
116typedef NativeWindowType EGLNativeWindowType;
117typedef NativePixmapType EGLNativePixmapType;
118typedef NativeDisplayType EGLNativeDisplayType;
119#define QEGL_NATIVE_TYPES_DEFINED 1
120#endif
121
122QT_END_INCLUDE_NAMESPACE
123
124#include <QtGui/qpaintdevice.h>
125#include <QFlags>
126
127QT_BEGIN_NAMESPACE
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
163typedef int EGLImageKHR;
164#else
165typedef void *EGLImageKHR;
166#endif
167
168#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0)
169#define EGL_IMAGE_PRESERVED_KHR 0x30D2
170#define EGL_KHR_image_base
171#endif
172
173#if !defined(EGL_KHR_image) && !defined(EGL_KHR_image_pixmap)
174#define EGL_NATIVE_PIXMAP_KHR 0x30B0
175#define EGL_KHR_image_pixmap
176#endif
177
178
179class QEglProperties;
180
181namespace QEgl {
182 enum API
183 {
184 OpenGL,
185 OpenVG
186 };
187
188 enum PixelFormatMatch
189 {
190 ExactPixelFormat,
191 BestPixelFormat
192 };
193
194 enum ConfigOption
195 {
196 NoOptions = 0,
197 Translucent = 0x01,
198 Renderable = 0x02 // Config will be compatable with the paint engines (VG or GL)
199 };
200 Q_DECLARE_FLAGS(ConfigOptions, ConfigOption)
201
202 // Most of the time we use the same config for things like widgets & pixmaps, so rather than
203 // go through the eglChooseConfig loop every time, we use defaultConfig, which will return
204 // the config for a particular device/api/option combo. This function assumes that once a
205 // config is chosen for a particular combo, it's safe to always use that combo.
206 Q_GUI_EXPORT EGLConfig defaultConfig(int devType, API api, ConfigOptions options);
207
208 Q_GUI_EXPORT EGLConfig chooseConfig(const QEglProperties* configAttribs, QEgl::PixelFormatMatch match = QEgl::ExactPixelFormat);
209 Q_GUI_EXPORT EGLSurface createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *surfaceAttribs = 0);
210
211 Q_GUI_EXPORT void dumpAllConfigs();
212
213#ifdef QT_NO_EGL
214 Q_GUI_EXPORT QString errorString(EGLint code = 0);
215#else
216 Q_GUI_EXPORT QString errorString(EGLint code = eglGetError());
217#endif
218
219 Q_GUI_EXPORT QString extensions();
220 Q_GUI_EXPORT bool hasExtension(const char* extensionName);
221
222 Q_GUI_EXPORT EGLDisplay display();
223
224 Q_GUI_EXPORT EGLNativeDisplayType nativeDisplay();
225 Q_GUI_EXPORT EGLNativeWindowType nativeWindow(QWidget*);
226 Q_GUI_EXPORT EGLNativePixmapType nativePixmap(QPixmap*);
227
228 // Extension functions
229 Q_GUI_EXPORT EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
230 Q_GUI_EXPORT EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img);
231 Q_GUI_EXPORT EGLBoolean eglSwapBuffersRegion2NOK(EGLDisplay dpy, EGLSurface surface, EGLint count, const EGLint *rects);
232
233#ifdef Q_WS_X11
234 Q_GUI_EXPORT VisualID getCompatibleVisualId(EGLConfig config);
235#endif
236}
237
238Q_DECLARE_OPERATORS_FOR_FLAGS(QEgl::ConfigOptions)
239
240QT_END_NAMESPACE
241
242#endif //QEGL_P_H
Note: See TracBrowser for help on using the repository browser.