42 #include <QtCore/qdebug.h> 43 #include <QtOpenGL/qgl.h> 44 #include <QtOpenGL/qglpixelbuffer.h> 50 #include <QtGui/private/qpixmap_x11_p.h> 53 #if defined(Q_OS_SYMBIAN) 54 #include <QtGui/private/qgraphicssystemex_symbian_p.h> 69 int sampleCount = glFormat.
samples();
71 bool prefer32Bit =
false;
74 prefer32Bit = !QSymbianGraphicsSystemEx::hasBCM2727();
78 if (glFormat.
alpha() && alphaSize <= 0)
80 if (glFormat.
depth() && depthSize <= 0)
82 if (glFormat.
stencil() && stencilSize <= 0)
87 redSize = redSize > 0 ? redSize : 8;
88 greenSize = greenSize > 0 ? greenSize : 8;
89 blueSize = blueSize > 0 ? blueSize : 8;
90 alphaSize = alphaSize > 0 ? alphaSize : 8;
91 depthSize = depthSize > 0 ? depthSize : 24;
92 stencilSize = stencilSize > 0 ? stencilSize : 8;
93 sampleCount = sampleCount >= 0 ? sampleCount : 4;
97 if (glFormat.
alpha() && alphaSize <= 0)
99 if (glFormat.
depth() && depthSize <= 0)
101 if (glFormat.
stencil() && stencilSize <= 0)
125 redSize = redSize > 0 ? redSize : 0;
126 greenSize = greenSize > 0 ? greenSize : 0;
127 blueSize = blueSize > 0 ? blueSize : 0;
128 alphaSize = alphaSize > 0 ? alphaSize : 0;
129 depthSize = depthSize > 0 ? depthSize : 0;
130 stencilSize = stencilSize > 0 ? stencilSize : 0;
131 sampleCount = sampleCount > 0 ? sampleCount : 0;
134 eglProperties.
setValue(EGL_RED_SIZE, redSize);
135 eglProperties.
setValue(EGL_GREEN_SIZE, greenSize);
136 eglProperties.
setValue(EGL_BLUE_SIZE, blueSize);
137 eglProperties.
setValue(EGL_ALPHA_SIZE, alphaSize);
138 eglProperties.
setValue(EGL_DEPTH_SIZE, depthSize);
139 eglProperties.
setValue(EGL_STENCIL_SIZE, stencilSize);
140 eglProperties.
setValue(EGL_SAMPLES, sampleCount);
141 eglProperties.
setValue(EGL_SAMPLE_BUFFERS, sampleCount ? 1 : 0);
148 EGLint greenSize = 0;
150 EGLint alphaSize = 0;
151 EGLint depthSize = 0;
152 EGLint stencilSize = 0;
153 EGLint sampleCount = 0;
157 eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize);
158 eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize);
159 eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize);
160 eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize);
161 eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize);
162 eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize);
163 eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount);
164 eglGetConfigAttrib(display, config, EGL_LEVEL, &level);
198 if (
d->eglContext &&
d->ownsEglContext) {
199 d->destroyEglSurfaceForDevice();
200 delete d->eglContext;
202 d->ownsEglContext =
false;
204 d->eglSurface = EGL_NO_SURFACE;
216 if (!
d->valid || !
d->eglContext ||
d->eglSurfaceForDevice() == EGL_NO_SURFACE) {
217 qWarning(
"QGLContext::makeCurrent(): Cannot make invalid context current");
221 if (
d->eglContext->makeCurrent(
d->eglSurfaceForDevice())) {
223 if (!
d->workaroundsCached) {
224 d->workaroundsCached =
true;
225 const char *renderer =
reinterpret_cast<const char *
>(glGetString(
GL_RENDERER));
228 if ((strstr(renderer,
"SGX") || strstr(renderer,
"MBX"))) {
232 qDebug() <<
"Found SGX/MBX driver, enabling FullClearOnEveryFrame";
233 d->workaround_needsFullClearOnEveryFrame =
true;
239 const char *egl_version = eglQueryString(
d->eglContext->display(), EGL_VERSION);
241 if (egl_version && strstr(egl_version,
"1.3")) {
242 qDebug() <<
"Found v1.3 driver, enabling brokenFBOReadBack";
243 d->workaround_brokenFBOReadBack =
true;
244 }
else if (egl_version && strstr(egl_version,
"1.4")) {
245 qDebug() <<
"Found v1.4 driver, enabling brokenTexSubImage";
246 d->workaround_brokenTexSubImage =
true;
261 qDebug() <<
"Found non-Nokia v1.4 driver, enabling brokenFBOReadBack";
262 d->workaround_brokenFBOReadBack =
true;
265 }
else if (strstr(renderer,
"VideoCore III")) {
271 d->workaround_brokenScissor =
true;
281 d->eglContext->doneCurrent();
290 if (!
d->valid || !
d->eglContext)
293 d->eglContext->swapBuffers(
d->eglSurfaceForDevice());
298 if (eglSurface != EGL_NO_SURFACE) {
299 #if defined(Q_WS_X11) || defined(Q_OS_SYMBIAN) 306 if (
QGLWidget *wgl = qobject_cast<QGLWidget *>(w)) {
307 if (wgl->d_func()->eglSurfaceWindowId != wgl->winId()) {
308 qWarning(
"WARNING: Potential EGL surface leak! Not destroying surface.");
309 eglSurface = EGL_NO_SURFACE;
315 eglDestroySurface(eglContext->display(), eglSurface);
316 eglSurface = EGL_NO_SURFACE;
338 return pbuf->d_func()->pbuf;
346 if (!valid || !eglContext)
349 eglContext->swapBuffersRegion2NOK(eglSurfaceForDevice(), ®ion);
354 extraWindowSurfaceCreationProps = props;
364 return d_func()->transpColor;
381 return (
void*)eglGetProcAddress(reinterpret_cast<const char *>(proc.
toLatin1().
data()));
void qt_glformat_from_eglconfig(QGLFormat &format, const EGLConfig config)
The QColor class provides colors based on RGB, HSV or CMYK values.
virtual void swapBuffers() const
Swaps the screen contents with an off-screen buffer.
#define QT_END_NAMESPACE
This macro expands to.
char * data()
Returns a pointer to the data stored in the byte array.
static void setCurrentContext(QGLContext *context)
void destroyEglSurfaceForDevice()
static void setExtraWindowSurfaceCreationProps(QEglProperties *props)
QColor overlayTransparentColor() const
If this context is a valid context in an overlay plane, returns the plane's transparent color...
void * getProcAddress(const QString &proc) const
Returns a function pointer to the GL extension function passed in proc.
The QString class provides a Unicode character string.
void setValue(int name, int value)
static void removeShare(const QGLContext *context)
Q_CORE_EXPORT void qDebug(const char *,...)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Q_GUI_EXPORT EGLDisplay display()
void generateFontDisplayLists(const QFont &fnt, int listBase)
Generates a set of 256 display lists for the 256 first characters in the font font.
The QGLContext class encapsulates an OpenGL rendering context.
Q_CORE_EXPORT void qWarning(const char *,...)
The QRegion class specifies a clip region for a painter.
The QGLPixelBuffer class encapsulates an OpenGL pbuffer.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Q_GUI_EXPORT bool hasExtension(const char *extensionName)
void reset()
Resets the context and makes it invalid.
The QFont class specifies a font used for drawing text.
void * data_ptr(const QTransform &t)
static QEglProperties * extraWindowSurfaceCreationProps
virtual void doneCurrent()
Makes no GL context the current context.
virtual void makeCurrent()
Makes this context the current OpenGL rendering context.
The QPixmap class is an off-screen image representation that can be used as a paint device...
uint colorIndex(const QColor &c) const
Returns a colormap index for the color c, in ColorIndex mode.
void swapRegion(const QRegion ®ion)
void qt_eglproperties_set_glformat(QEglProperties &eglProperties, const QGLFormat &glFormat)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
EGLSurface eglSurfaceForDevice() const