1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 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 QtOpenGL 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 QGL_P_H
|
---|
43 | #define QGL_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
|
---|
50 | // of the QGLWidget class. 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 "QtOpenGL/qgl.h"
|
---|
57 | #include "QtOpenGL/qglcolormap.h"
|
---|
58 | #include "QtCore/qmap.h"
|
---|
59 | #include "QtCore/qthread.h"
|
---|
60 | #include "QtCore/qthreadstorage.h"
|
---|
61 | #include "QtCore/qhash.h"
|
---|
62 | #include "QtCore/qatomic.h"
|
---|
63 | #include "private/qwidget_p.h"
|
---|
64 | #include "qcache.h"
|
---|
65 | #include "qglpaintdevice_p.h"
|
---|
66 |
|
---|
67 | #ifndef QT_NO_EGL
|
---|
68 | #include <QtGui/private/qegl_p.h>
|
---|
69 | #endif
|
---|
70 |
|
---|
71 | QT_BEGIN_NAMESPACE
|
---|
72 |
|
---|
73 | class QGLContext;
|
---|
74 | class QGLOverlayWidget;
|
---|
75 | class QPixmap;
|
---|
76 | class QPixmapFilter;
|
---|
77 | #ifdef Q_WS_MAC
|
---|
78 | # ifdef qDebug
|
---|
79 | # define old_qDebug qDebug
|
---|
80 | # undef qDebug
|
---|
81 | # endif
|
---|
82 | QT_BEGIN_INCLUDE_NAMESPACE
|
---|
83 | #ifndef QT_MAC_USE_COCOA
|
---|
84 | # include <AGL/agl.h>
|
---|
85 | #endif
|
---|
86 | QT_END_INCLUDE_NAMESPACE
|
---|
87 | # ifdef old_qDebug
|
---|
88 | # undef qDebug
|
---|
89 | # define qDebug QT_NO_QDEBUG_MACRO
|
---|
90 | # undef old_qDebug
|
---|
91 | # endif
|
---|
92 | class QMacWindowChangeEvent;
|
---|
93 | #endif
|
---|
94 |
|
---|
95 | #ifdef Q_WS_QWS
|
---|
96 | class QWSGLWindowSurface;
|
---|
97 | #endif
|
---|
98 |
|
---|
99 | #ifndef QT_NO_EGL
|
---|
100 | class QEglContext;
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | QT_BEGIN_INCLUDE_NAMESPACE
|
---|
104 | #include <QtOpenGL/private/qglextensions_p.h>
|
---|
105 | QT_END_INCLUDE_NAMESPACE
|
---|
106 |
|
---|
107 | class QGLFormatPrivate
|
---|
108 | {
|
---|
109 | public:
|
---|
110 | QGLFormatPrivate()
|
---|
111 | : ref(1)
|
---|
112 | {
|
---|
113 | opts = QGL::DoubleBuffer | QGL::DepthBuffer | QGL::Rgba | QGL::DirectRendering
|
---|
114 | | QGL::StencilBuffer | QGL::DeprecatedFunctions;
|
---|
115 | pln = 0;
|
---|
116 | depthSize = accumSize = stencilSize = redSize = greenSize = blueSize = alphaSize = -1;
|
---|
117 | numSamples = -1;
|
---|
118 | swapInterval = -1;
|
---|
119 | majorVersion = 1;
|
---|
120 | minorVersion = 0;
|
---|
121 | profile = QGLFormat::NoProfile;
|
---|
122 | }
|
---|
123 | QGLFormatPrivate(const QGLFormatPrivate *other)
|
---|
124 | : ref(1),
|
---|
125 | opts(other->opts),
|
---|
126 | pln(other->pln),
|
---|
127 | depthSize(other->depthSize),
|
---|
128 | accumSize(other->accumSize),
|
---|
129 | stencilSize(other->stencilSize),
|
---|
130 | redSize(other->redSize),
|
---|
131 | greenSize(other->greenSize),
|
---|
132 | blueSize(other->blueSize),
|
---|
133 | alphaSize(other->alphaSize),
|
---|
134 | numSamples(other->numSamples),
|
---|
135 | swapInterval(other->swapInterval),
|
---|
136 | majorVersion(other->majorVersion),
|
---|
137 | minorVersion(other->minorVersion),
|
---|
138 | profile(other->profile)
|
---|
139 | {
|
---|
140 | }
|
---|
141 | QAtomicInt ref;
|
---|
142 | QGL::FormatOptions opts;
|
---|
143 | int pln;
|
---|
144 | int depthSize;
|
---|
145 | int accumSize;
|
---|
146 | int stencilSize;
|
---|
147 | int redSize;
|
---|
148 | int greenSize;
|
---|
149 | int blueSize;
|
---|
150 | int alphaSize;
|
---|
151 | int numSamples;
|
---|
152 | int swapInterval;
|
---|
153 | int majorVersion;
|
---|
154 | int minorVersion;
|
---|
155 | QGLFormat::OpenGLContextProfile profile;
|
---|
156 | };
|
---|
157 |
|
---|
158 | class QGLWidgetPrivate : public QWidgetPrivate
|
---|
159 | {
|
---|
160 | Q_DECLARE_PUBLIC(QGLWidget)
|
---|
161 | public:
|
---|
162 | QGLWidgetPrivate() : QWidgetPrivate()
|
---|
163 | , disable_clear_on_painter_begin(false)
|
---|
164 | #ifdef Q_WS_QWS
|
---|
165 | , wsurf(0)
|
---|
166 | #endif
|
---|
167 | #if defined(Q_WS_X11) && !defined(QT_NO_EGL)
|
---|
168 | , eglSurfaceWindowId(0)
|
---|
169 | #endif
|
---|
170 | #if defined(Q_OS_SYMBIAN)
|
---|
171 | , eglSurfaceWindowId(0)
|
---|
172 | #endif
|
---|
173 | {
|
---|
174 | isGLWidget = 1;
|
---|
175 | }
|
---|
176 |
|
---|
177 | ~QGLWidgetPrivate() {}
|
---|
178 |
|
---|
179 | void init(QGLContext *context, const QGLWidget* shareWidget);
|
---|
180 | void initContext(QGLContext *context, const QGLWidget* shareWidget);
|
---|
181 | bool renderCxPm(QPixmap *pixmap);
|
---|
182 | void cleanupColormaps();
|
---|
183 | void aboutToDestroy() {
|
---|
184 | if (glcx)
|
---|
185 | glcx->reset();
|
---|
186 | }
|
---|
187 |
|
---|
188 | QGLContext *glcx;
|
---|
189 | QGLWidgetGLPaintDevice glDevice;
|
---|
190 | bool autoSwap;
|
---|
191 |
|
---|
192 | QGLColormap cmap;
|
---|
193 | #ifndef QT_OPENGL_ES
|
---|
194 | QMap<QString, int> displayListCache;
|
---|
195 | #endif
|
---|
196 |
|
---|
197 | bool disable_clear_on_painter_begin;
|
---|
198 |
|
---|
199 | #if defined(Q_WS_WIN)
|
---|
200 | void updateColormap();
|
---|
201 | QGLContext *olcx;
|
---|
202 | #elif defined(Q_WS_X11)
|
---|
203 | QGLOverlayWidget *olw;
|
---|
204 | #ifndef QT_NO_EGL
|
---|
205 | void recreateEglSurface();
|
---|
206 | WId eglSurfaceWindowId;
|
---|
207 | #endif
|
---|
208 | #elif defined(Q_WS_MAC)
|
---|
209 | QGLContext *olcx;
|
---|
210 | void updatePaintDevice();
|
---|
211 | #elif defined(Q_WS_QWS)
|
---|
212 | QWSGLWindowSurface *wsurf;
|
---|
213 | #endif
|
---|
214 | #ifdef Q_OS_SYMBIAN
|
---|
215 | void recreateEglSurface();
|
---|
216 | WId eglSurfaceWindowId;
|
---|
217 | #endif
|
---|
218 | };
|
---|
|
---|