| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 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 [email protected].
|
|---|
| 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 |
|
|---|
| 56 | #include <QtCore/qsize.h>
|
|---|
| 57 | #include <QtGui/qimage.h>
|
|---|
| 58 |
|
|---|
| 59 | #include <private/qeglproperties_p.h>
|
|---|
| 60 |
|
|---|
| 61 | QT_BEGIN_INCLUDE_NAMESPACE
|
|---|
| 62 |
|
|---|
| 63 | #if !defined(EGL_VERSION_1_3) && !defined(QEGL_NATIVE_TYPES_DEFINED)
|
|---|
| 64 | #undef EGLNativeWindowType
|
|---|
| 65 | #undef EGLNativePixmapType
|
|---|
| 66 | #undef EGLNativeDisplayType
|
|---|
| 67 | typedef NativeWindowType EGLNativeWindowType;
|
|---|
| 68 | typedef NativePixmapType EGLNativePixmapType;
|
|---|
| 69 | typedef NativeDisplayType EGLNativeDisplayType;
|
|---|
| 70 | #define QEGL_NATIVE_TYPES_DEFINED 1
|
|---|
| 71 | #endif
|
|---|
| 72 | QT_END_INCLUDE_NAMESPACE
|
|---|
| 73 |
|
|---|
| 74 | QT_BEGIN_NAMESPACE
|
|---|
| 75 |
|
|---|
| 76 | class Q_GUI_EXPORT QEglContext
|
|---|
| 77 | {
|
|---|
| 78 | public:
|
|---|
| 79 | QEglContext();
|
|---|
| 80 | ~QEglContext();
|
|---|
| 81 |
|
|---|
| 82 | bool isValid() const;
|
|---|
| 83 | bool isCurrent() const;
|
|---|
| 84 | bool isSharing() const { return sharing; }
|
|---|
| 85 |
|
|---|
| 86 | QEgl::API api() const { return apiType; }
|
|---|
| 87 | void setApi(QEgl::API api) { apiType = api; }
|
|---|
| 88 |
|
|---|
| 89 | bool chooseConfig(const QEglProperties& properties, QEgl::PixelFormatMatch match = QEgl::ExactPixelFormat);
|
|---|
| 90 | bool createContext(QEglContext *shareContext = 0, const QEglProperties *properties = 0);
|
|---|
| 91 | void destroyContext();
|
|---|
| 92 | EGLSurface createSurface(QPaintDevice *device, const QEglProperties *properties = 0);
|
|---|
| 93 | void destroySurface(EGLSurface surface);
|
|---|
| 94 |
|
|---|
| 95 | bool makeCurrent(EGLSurface surface);
|
|---|
| 96 | bool doneCurrent();
|
|---|
| 97 | bool lazyDoneCurrent();
|
|---|
| 98 | bool swapBuffers(EGLSurface surface);
|
|---|
| 99 |
|
|---|
| 100 | void waitNative();
|
|---|
| 101 | void waitClient();
|
|---|
| 102 |
|
|---|
| 103 | bool configAttrib(int name, EGLint *value) const;
|
|---|
| 104 |
|
|---|
| 105 | static void clearError();
|
|---|
| 106 | static EGLint error();
|
|---|
| 107 | static QString errorString(EGLint code);
|
|---|
| 108 |
|
|---|
| 109 | static EGLDisplay display();
|
|---|
| 110 |
|
|---|
| 111 | EGLContext context() const { return ctx; }
|
|---|
| 112 | void setContext(EGLContext context) { ctx = context; ownsContext = false;}
|
|---|
| 113 |
|
|---|
| 114 | EGLConfig config() const { return cfg; }
|
|---|
| 115 | void setConfig(EGLConfig config) { cfg = config; }
|
|---|
| 116 |
|
|---|
| 117 | QEglProperties configProperties(EGLConfig cfg = 0) const;
|
|---|
| 118 |
|
|---|
| 119 | void dumpAllConfigs();
|
|---|
| 120 |
|
|---|
| 121 | static QString extensions();
|
|---|
| 122 | static bool hasExtension(const char* extensionName);
|
|---|
| 123 |
|
|---|
| 124 | private:
|
|---|
| 125 | QEgl::API apiType;
|
|---|
| 126 | EGLContext ctx;
|
|---|
| 127 | EGLConfig cfg;
|
|---|
| 128 | EGLSurface currentSurface;
|
|---|
| 129 | bool current;
|
|---|
| 130 | bool ownsContext;
|
|---|
| 131 | bool sharing;
|
|---|
| 132 |
|
|---|
| 133 | static EGLDisplay dpy;
|
|---|
| 134 | static EGLNativeDisplayType nativeDisplay();
|
|---|
| 135 |
|
|---|
| 136 | static QEglContext *currentContext(QEgl::API api);
|
|---|
| 137 | static void setCurrentContext(QEgl::API api, QEglContext *context);
|
|---|
| 138 | };
|
|---|
| 139 |
|
|---|
| 140 | QT_END_NAMESPACE
|
|---|
| 141 |
|
|---|
| 142 | #endif // QEGL_P_H
|
|---|