diff options
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r-- | src/opengl/qgl.cpp | 610 |
1 files changed, 7 insertions, 603 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 4f9f5a9414..25adf0bade 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -45,21 +45,6 @@ #include <qdebug.h> #include <qglfunctions.h> -#if defined(Q_WS_X11) -#include "private/qt_x11_p.h" -#include "private/qpixmap_x11_p.h" -#define INT32 dummy_INT32 -#define INT8 dummy_INT8 -#ifdef QT_NO_EGL -# include <GL/glx.h> -#endif -#undef INT32 -#undef INT8 -#include "qx11info_x11.h" -#elif defined(Q_WS_MAC) -# include <private/qt_mac_p.h> -#endif - #include <qdatetime.h> #include <stdlib.h> // malloc @@ -68,17 +53,9 @@ #include "qimage.h" #include "qgl_p.h" -#if !defined(QT_OPENGL_ES_1) #include "gl2paintengineex/qpaintengineex_opengl2_p.h" -#endif -#ifndef QT_OPENGL_ES_2 -#include <private/qpaintengine_opengl_p.h> -#endif - -#ifdef Q_WS_QPA #include <QtGui/QPlatformGLContext> -#endif #include <qglpixelbuffer.h> #include <qglframebufferobject.h> @@ -92,21 +69,11 @@ #include "qlibrary.h" #include <qmutex.h> -#if defined(QT_OPENGL_ES) && !defined(QT_NO_EGL) -#include <EGL/egl.h> -#endif - // #define QT_GL_CONTEXT_RESOURCE_DEBUG QT_BEGIN_NAMESPACE -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs; -#endif - -#ifdef Q_WS_X11 -extern const QX11Info *qt_x11Info(const QPaintDevice *pd); -#endif struct QGLThreadContext { ~QGLThreadContext() { @@ -116,10 +83,6 @@ struct QGLThreadContext { QGLContext *context; }; -#ifndef Q_WS_QPA -static QThreadStorage<QGLThreadContext *> qgl_context_storage; -#endif - Q_GLOBAL_STATIC(QGLFormat, qgl_default_format) class QGLDefaultOverlayFormat: public QGLFormat @@ -146,71 +109,6 @@ QGLSignalProxy *QGLSignalProxy::instance() } -class QGLEngineSelector -{ -public: - QGLEngineSelector() : engineType(QPaintEngine::MaxUser) - { - } - - void setPreferredPaintEngine(QPaintEngine::Type type) { - if (type == QPaintEngine::OpenGL || type == QPaintEngine::OpenGL2) - engineType = type; - } - - QPaintEngine::Type preferredPaintEngine() { -#ifdef Q_WS_MAC - // The ATI X1600 driver for Mac OS X does not support return - // values from functions in GLSL. Since working around this in - // the GL2 engine would require a big, ugly rewrite, we're - // falling back to the GL 1 engine.. - static bool mac_x1600_check_done = false; - if (!mac_x1600_check_done) { - QGLTemporaryContext *tmp = 0; - if (!QGLContext::currentContext()) - tmp = new QGLTemporaryContext(); - if (strstr((char *) glGetString(GL_RENDERER), "X1600")) - engineType = QPaintEngine::OpenGL; - if (tmp) - delete tmp; - mac_x1600_check_done = true; - } -#endif - if (engineType == QPaintEngine::MaxUser) { - // No user-set engine - use the defaults -#if defined(QT_OPENGL_ES_2) - engineType = QPaintEngine::OpenGL2; -#else - // We can't do this in the constructor for this object because it - // needs to be called *before* the QApplication constructor. - // Also check for the FragmentShader extension in conjunction with - // the 2.0 version flag, to cover the case where we export the display - // from an old GL 1.1 server to a GL 2.x client. In that case we can't - // use GL 2.0. - if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) - && (QGLExtensions::glExtensions() & QGLExtensions::FragmentShader) - && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty()) - engineType = QPaintEngine::OpenGL2; - else - engineType = QPaintEngine::OpenGL; -#endif - } - return engineType; - } - -private: - QPaintEngine::Type engineType; -}; - -Q_GLOBAL_STATIC(QGLEngineSelector, qgl_engine_selector) - - -bool qt_gl_preferGL2Engine() -{ - return qgl_engine_selector()->preferredPaintEngine() == QPaintEngine::OpenGL2; -} - - /*! \namespace QGL \inmodule QtOpenGL @@ -257,32 +155,6 @@ bool qt_gl_preferGL2Engine() \sa {Sample Buffers Example} */ -/*! - \fn void QGL::setPreferredPaintEngine(QPaintEngine::Type engineType) - - \since 4.6 - - Sets the preferred OpenGL paint engine that is used to draw onto - QGLWidget, QGLPixelBuffer and QGLFramebufferObject targets with QPainter - in Qt. - - The \a engineType parameter specifies which of the GL engines to - use. Only \c QPaintEngine::OpenGL and \c QPaintEngine::OpenGL2 are - valid parameters to this function. All other values are ignored. - - By default, the \c QPaintEngine::OpenGL2 engine is used if GL/GLES - version 2.0 is available, otherwise \c QPaintEngine::OpenGL is - used. - - \warning This function must be called before the QApplication - constructor is called. -*/ -void QGL::setPreferredPaintEngine(QPaintEngine::Type engineType) -{ - qgl_engine_selector()->setPreferredPaintEngine(engineType); -} - - /***************************************************************************** QGLFormat implementation *****************************************************************************/ @@ -1680,35 +1552,8 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) glFormat = reqFormat = format; valid = false; q->setDevice(dev); -#if defined(Q_WS_X11) - pbuf = 0; - gpm = 0; - vi = 0; - screen = QX11Info::appScreen(); -#endif -#if defined(Q_WS_WIN) - dc = 0; - win = 0; - threadId = 0; - pixelFormatId = 0; - cmap = 0; - hbitmap = 0; - hbitmap_hdc = 0; -#endif -#if defined(Q_WS_MAC) -# ifndef QT_MAC_USE_COCOA - update = false; -# endif - vi = 0; -#endif -#if defined(Q_WS_QPA) + guiGlContext = 0; -#endif -#if !defined(QT_NO_EGL) - ownsEglContext = false; - eglContext = 0; - eglSurface = EGL_NO_SURFACE; -#endif fbo = 0; crWin = false; initDone = false; @@ -1802,7 +1647,7 @@ QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alp QImage img(size, alpha_format ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); int w = size.width(); int h = size.height(); -#if !defined(QT_OPENGL_ES_2) && !defined(QT_OPENGL_ES_1) +#if !defined(QT_OPENGL_ES_2) //### glGetTexImage not in GL ES 2.0, need to do something else here! glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.bits()); #endif @@ -1912,13 +1757,6 @@ void QGLTextureCache::cleanupBeforePixmapDestruction(QPlatformPixmap* pmd) { // Remove any bound textures first: cleanupTexturesForPixampData(pmd); - -#if defined(Q_WS_X11) - if (pmd->classId() == QPlatformPixmap::X11Class) { - Q_ASSERT(pmd->ref == 0); // Make sure reference counting isn't broken - QGLContextPrivate::destroyGlSurfaceForPixmap(pmd); - } -#endif } QGLTextureCache *QGLTextureCache::instance() @@ -2139,13 +1977,11 @@ void QGLContextPrivate::syncGlState() } #undef ctx -#ifdef QT_NO_EGL void QGLContextPrivate::swapRegion(const QRegion &) { Q_Q(QGLContext); q->swapBuffers(); } -#endif /*! \overload @@ -2290,12 +2126,10 @@ static void convertToGLFormatHelper(QImage &dst, const QImage &img, GLenum textu } } -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) QGLExtensionFuncs& QGLContextPrivate::extensionFuncs(const QGLContext *) { return qt_extensionFuncs; } -#endif QImage QGLContextPrivate::convertToGLFormat(const QImage &image, bool force_premul, GLenum texture_format) @@ -2594,39 +2428,6 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, } } -#if defined(Q_WS_X11) - // Try to use texture_from_pixmap - const QX11Info *xinfo = qt_x11Info(paintDevice); - if (pd->classId() == QPlatformPixmap::X11Class && pd->pixelType() == QPlatformPixmap::PixmapType - && xinfo && xinfo->screen() == pixmap.x11Info().screen() - && target == GL_TEXTURE_2D - && QApplication::instance()->thread() == QThread::currentThread()) - { - if (!workaround_brokenTextureFromPixmap_init) { - workaround_brokenTextureFromPixmap_init = true; - - const QByteArray versionString(reinterpret_cast<const char*>(glGetString(GL_VERSION))); - const int pos = versionString.indexOf("NVIDIA "); - - if (pos >= 0) { - const QByteArray nvidiaVersionString = versionString.mid(pos + strlen("NVIDIA ")); - - if (nvidiaVersionString.startsWith("195") || nvidiaVersionString.startsWith("256")) - workaround_brokenTextureFromPixmap = true; - } - } - - if (!workaround_brokenTextureFromPixmap) { - texture = bindTextureFromNativePixmap(const_cast<QPixmap*>(&pixmap), key, options); - if (texture) { - texture->options |= QGLContext::MemoryManagedBindOption; - texture->boundPixmap = pd; - boundPixmaps.insert(pd, QPixmap(pixmap)); - } - } - } -#endif - if (!texture) { QImage image = pixmap.toImage(); // If the system depth is 16 and the pixmap doesn't have an alpha channel @@ -2745,31 +2546,6 @@ GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format, return texture->id; } -#ifdef Q_MAC_COMPAT_GL_FUNCTIONS -/*! \internal */ -GLuint QGLContext::bindTexture(const QImage &image, QMacCompatGLenum target, QMacCompatGLint format) -{ - if (image.isNull()) - return 0; - - Q_D(QGLContext); - QGLTexture *texture = d->bindTexture(image, GLenum(target), GLint(format), DefaultBindOption); - return texture->id; -} - -/*! \internal */ -GLuint QGLContext::bindTexture(const QImage &image, QMacCompatGLenum target, QMacCompatGLint format, - BindOptions options) -{ - if (image.isNull()) - return 0; - - Q_D(QGLContext); - QGLTexture *texture = d->bindTexture(image, GLenum(target), GLint(format), options); - return texture->id; -} -#endif - /*! \overload Generates and binds a 2D GL texture based on \a pixmap. @@ -2801,30 +2577,6 @@ GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint forma return texture->id; } -#ifdef Q_MAC_COMPAT_GL_FUNCTIONS -/*! \internal */ -GLuint QGLContext::bindTexture(const QPixmap &pixmap, QMacCompatGLenum target, QMacCompatGLint format) -{ - if (pixmap.isNull()) - return 0; - - Q_D(QGLContext); - QGLTexture *texture = d->bindTexture(pixmap, GLenum(target), GLint(format), DefaultBindOption); - return texture->id; -} -/*! \internal */ -GLuint QGLContext::bindTexture(const QPixmap &pixmap, QMacCompatGLenum target, QMacCompatGLint format, - BindOptions options) -{ - if (pixmap.isNull()) - return 0; - - Q_D(QGLContext); - QGLTexture *texture = d->bindTexture(pixmap, GLenum(target), GLint(format), options); - return texture->id; -} -#endif - /*! Removes the texture identified by \a id from the texture cache, and calls glDeleteTextures() to delete the texture from the @@ -2839,14 +2591,6 @@ void QGLContext::deleteTexture(GLuint id) glDeleteTextures(1, &id); } -#ifdef Q_MAC_COMPAT_GL_FUNCTIONS -/*! \internal */ -void QGLContext::deleteTexture(QMacCompatGLuint id) -{ - return deleteTexture(GLuint(id)); -} -#endif - void qt_add_rect_to_array(const QRectF &r, GLfloat *array) { qreal left = r.left(); @@ -2986,14 +2730,6 @@ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum text #endif } -#ifdef Q_MAC_COMPAT_GL_FUNCTIONS -/*! \internal */ -void QGLContext::drawTexture(const QRectF &target, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget) -{ - drawTexture(target, GLuint(textureId), GLenum(textureTarget)); -} -#endif - /*! \since 4.4 @@ -3057,15 +2793,6 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text #endif } -#ifdef Q_MAC_COMPAT_GL_FUNCTIONS -/*! \internal */ -void QGLContext::drawTexture(const QPointF &point, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget) -{ - drawTexture(point, GLuint(textureId), GLenum(textureTarget)); -} -#endif - - /*! This function sets the limit for the texture cache to \a size, expressed in kilobytes. @@ -3295,11 +3022,7 @@ bool QGLContext::areSharing(const QGLContext *context1, const QGLContext *contex bool QGLContext::create(const QGLContext* shareContext) { Q_D(QGLContext); -#ifdef Q_WS_QPA if (!d->paintDevice && !d->guiGlContext) -#else - if (!d->paintDevice) -#endif return false; reset(); @@ -3308,10 +3031,6 @@ bool QGLContext::create(const QGLContext* shareContext) QWidgetPrivate *wd = qt_widget_private(static_cast<QWidget *>(d->paintDevice)); wd->usesDoubleBufferedGLContext = d->glFormat.doubleBuffer(); } -#ifndef Q_WS_QPA //We do this in choose context->setupSharing() - if (d->sharing) // ok, we managed to share - QGLContextGroup::addShare(this, shareContext); -#endif return d->valid; } @@ -3385,37 +3104,15 @@ void QGLContext::setInitialized(bool on) const QGLContext* QGLContext::currentContext() { -#ifdef Q_WS_QPA if (const QGuiGLContext *threadContext = QGuiGLContext::currentContext()) { return QGLContext::fromGuiGLContext(const_cast<QGuiGLContext *>(threadContext)); } return 0; -#else - QGLThreadContext *threadContext = qgl_context_storage.localData(); - if (threadContext) - return threadContext->context; - return 0; -#endif //Q_WS_QPA } void QGLContextPrivate::setCurrentContext(QGLContext *context) { -#ifdef Q_WS_QPA Q_UNUSED(context); -#else - QGLThreadContext *threadContext = qgl_context_storage.localData(); - if (!threadContext) { - if (!QThread::currentThread()) { - // We don't have a current QThread, so just set the static. - QGLContext::currentCtx = context; - return; - } - threadContext = new QGLThreadContext; - qgl_context_storage.setLocalData(threadContext); - } - threadContext->context = context; - QGLContext::currentCtx = context; // XXX: backwards-compat, not thread-safe -#endif } /*! @@ -3727,11 +3424,6 @@ void QGLContextPrivate::setCurrentContext(QGLContext *context) on a QGLWidget and the widget's rendering context is current in another thread, it will fail. - Note that under X11 it is necessary to set the - Qt::AA_X11InitThreads application attribute to make the X11 - library and GLX calls thread safe, otherwise the above scenarios - will fail. - In addition to this, rendering using raw GL calls in a separate thread is supported. @@ -3872,30 +3564,9 @@ QGLWidget::QGLWidget(QGLContext *context, QWidget *parent, const QGLWidget *shar QGLWidget::~QGLWidget() { Q_D(QGLWidget); -#if defined(GLX_MESA_release_buffers) && defined(QGL_USE_MESA_EXT) - bool doRelease = (glcx && glcx->windowCreated()); -#endif delete d->glcx; d->glcx = 0; -#if defined(Q_WS_WIN) - delete d->olcx; - d->olcx = 0; -#endif -#if defined(GLX_MESA_release_buffers) && defined(QGL_USE_MESA_EXT) - if (doRelease) - glXReleaseBuffersMESA(x11Display(), winId()); -#endif d->cleanupColormaps(); - -#ifdef Q_WS_MAC - QWidget *current = parentWidget(); - while (current) { - qt_widget_private(current)->glWidgets.removeAll(QWidgetPrivate::GlWidgetInfo(this)); - if (current->isWindow()) - break; - current = current->parentWidget(); - }; -#endif } /*! @@ -4241,125 +3912,6 @@ void QGLWidget::resizeOverlayGL(int, int) { } -/*! \fn bool QGLWidget::event(QEvent *e) - \reimp -*/ -#if !defined(Q_OS_WINCE) && !defined(Q_WS_QWS) && !defined(Q_WS_QPA) -bool QGLWidget::event(QEvent *e) -{ - Q_D(QGLWidget); - - if (e->type() == QEvent::Paint) { - QPoint offset; - QPaintDevice *redirectedDevice = d->redirected(&offset); - if (redirectedDevice && redirectedDevice->devType() == QInternal::Pixmap) { - d->restoreRedirected(); - QPixmap pixmap = renderPixmap(); - d->setRedirected(redirectedDevice, offset); - QPainter p(redirectedDevice); - p.drawPixmap(-offset, pixmap); - return true; - } - } - -#if defined(Q_WS_X11) - if (e->type() == QEvent::ParentChange) { - // if we've reparented a window that has the current context - // bound, we need to rebind that context to the new window id - if (d->glcx == QGLContext::currentContext()) - makeCurrent(); - - if (d->glcx->d_func()->screen != d->xinfo.screen() || testAttribute(Qt::WA_TranslucentBackground)) { - setContext(new QGLContext(d->glcx->requestedFormat(), this)); - // ### recreating the overlay isn't supported atm - } - } - -#ifndef QT_NO_EGL - // A re-parent is likely to destroy the X11 window and re-create it. It is important - // that we free the EGL surface _before_ the winID changes - otherwise we can leak. - if (e->type() == QEvent::ParentAboutToChange) - d->glcx->d_func()->destroyEglSurfaceForDevice(); - - if ((e->type() == QEvent::ParentChange) || (e->type() == QEvent::WindowStateChange)) { - // The window may have been re-created during re-parent or state change - if so, the EGL - // surface will need to be re-created. - d->recreateEglSurface(); - } -#endif -#elif defined(Q_WS_WIN) - if (e->type() == QEvent::ParentChange) { - QGLContext *newContext = new QGLContext(d->glcx->requestedFormat(), this); - setContext(newContext, d->glcx); - - // the overlay needs to be recreated as well - delete d->olcx; - if (isValid() && context()->format().hasOverlay()) { - d->olcx = new QGLContext(QGLFormat::defaultOverlayFormat(), this); - if (!d->olcx->create(isSharing() ? d->glcx : 0)) { - delete d->olcx; - d->olcx = 0; - d->glcx->d_func()->glFormat.setOverlay(false); - } - } else { - d->olcx = 0; - } - } else if (e->type() == QEvent::Show) { - if (!format().rgba()) - d->updateColormap(); - } -#elif defined(Q_WS_MAC) - if (e->type() == QEvent::MacGLWindowChange -#if 0 //(MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) - && ((QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 && isWindow()) - || QSysInfo::MacintoshVersion <= QSysInfo::MV_10_4) -#endif - ) { - if (d->needWindowChange) { - d->needWindowChange = false; - d->glcx->updatePaintDevice(); - update(); - } - return true; -# if defined(QT_MAC_USE_COCOA) - } else if (e->type() == QEvent::MacGLClearDrawable) { - d->glcx->d_ptr->clearDrawable(); -# endif - } -#elif defined(Q_OS_SYMBIAN) - // prevents errors on some systems, where we get a flush to a - // hidden widget - if (e->type() == QEvent::Hide) { - makeCurrent(); - glFinish(); - doneCurrent(); - } else if (e->type() == QEvent::ParentChange) { - // if we've reparented a window that has the current context - // bound, we need to rebind that context to the new window id - if (d->glcx == QGLContext::currentContext()) - makeCurrent(); - - if (testAttribute(Qt::WA_TranslucentBackground)) - setContext(new QGLContext(d->glcx->requestedFormat(), this)); - } - - // A re-parent is likely to destroy the Symbian window and re-create it. It is important - // that we free the EGL surface _before_ the winID changes - otherwise we can leak. - if (e->type() == QEvent::ParentAboutToChange) - d->glcx->d_func()->destroyEglSurfaceForDevice(); - - if ((e->type() == QEvent::ParentChange) || (e->type() == QEvent::WindowStateChange)) { - // The window may have been re-created during re-parent or state change - if so, the EGL - // surface will need to be re-created. - d->recreateEglSurface(); - } - -#endif - - return QWidget::event(e); -} -#endif - /*! \fn void QGLWidget::paintEvent(QPaintEvent *event) @@ -4433,28 +3985,7 @@ QPixmap QGLWidget::renderPixmap(int w, int h, bool useContext) if ((w > 0) && (h > 0)) sz = QSize(w, h); -#if defined(Q_WS_X11) - extern int qt_x11_preferred_pixmap_depth; - int old_depth = qt_x11_preferred_pixmap_depth; - qt_x11_preferred_pixmap_depth = x11Info().depth(); - - QPlatformPixmap *data = new QX11PlatformPixmap(QPlatformPixmap::PixmapType); - data->resize(sz.width(), sz.height()); - QPixmap pm(data); - qt_x11_preferred_pixmap_depth = old_depth; - QX11Info xinfo = x11Info(); - - // make sure we use a pixmap with the same depth/visual as the widget - if (xinfo.visual() != QX11Info::appVisual()) { - QX11InfoData* xd = pm.x11Info().getX11Data(true); - xd->depth = xinfo.depth(); - xd->visual = static_cast<Visual *>(xinfo.visual()); - const_cast<QX11Info &>(pm.x11Info()).setX11Data(xd); - } - -#else QPixmap pm(sz); -#endif d->glcx->doneCurrent(); @@ -4466,9 +3997,6 @@ QPixmap QGLWidget::renderPixmap(int w, int h, bool useContext) QGLFormat fmt = d->glcx->requestedFormat(); fmt.setDirectRendering(false); // Direct is unlikely to work fmt.setDoubleBuffer(false); // We don't need dbl buf -#ifdef Q_WS_MAC // crash prevention on the Mac - it's unlikely to work anyway - fmt.setSampleBuffers(false); -#endif QGLContext* ocx = d->glcx; ocx->doneCurrent(); @@ -4486,13 +4014,6 @@ QPixmap QGLWidget::renderPixmap(int w, int h, bool useContext) ocx->makeCurrent(); if (success) { -#if defined(Q_WS_X11) - if (xinfo.visual() != QX11Info::appVisual()) { - QImage image = pm.toImage(); - QPixmap p = QPixmap::fromImage(image); - return p; - } -#endif return pm; } return QPixmap(); @@ -4512,21 +4033,8 @@ QImage QGLWidget::grabFrameBuffer(bool withAlpha) QImage res; int w = width(); int h = height(); - if (format().rgba()) { + if (format().rgba()) res = qt_gl_read_framebuffer(QSize(w, h), format().alpha(), withAlpha); - } else { -#if defined (Q_WS_WIN) && !defined(QT_OPENGL_ES) - res = QImage(w, h, QImage::Format_Indexed8); - glReadPixels(0, 0, w, h, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, res.bits()); - const QVector<QColor> pal = QColormap::instance().colormap(); - if (pal.size()) { - res.setColorCount(pal.size()); - for (int i = 0; i < pal.size(); i++) - res.setColor(i, pal.at(i).rgb()); - } - res = res.mirrored(); -#endif - } return res; } @@ -4561,11 +4069,6 @@ void QGLWidget::glDraw() Q_D(QGLWidget); if (!isValid()) return; -#ifdef Q_OS_SYMBIAN - // Crashes on Symbian if trying to render to invisible surfaces - if (!isVisible() && d->glcx->device()->devType() == QInternal::Widget) - return; -#endif makeCurrent(); #ifndef QT_OPENGL_ES if (d->glcx->deviceIsPixmap()) @@ -4884,10 +4387,8 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, int height = d->glcx->device()->height(); bool auto_swap = autoBufferSwap(); - QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); - QPaintEngine *engine = paintEngine(); - if (engine && (oldEngineType == QPaintEngine::OpenGL2) && engine->isActive()) { + if (engine && engine->isActive()) { qWarning("QGLWidget::renderText(): Calling renderText() while a GL 2 paint engine is" " active on the same device is not allowed."); return; @@ -4939,7 +4440,6 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, setAutoBufferSwap(auto_swap); d->disable_clear_on_painter_begin = false; } - qgl_engine_selector()->setPreferredPaintEngine(oldEngineType); #else // QT_OPENGL_ES Q_UNUSED(x); Q_UNUSED(y); @@ -4987,10 +4487,9 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con &win_x, &win_y, &win_z); win_y = height - win_y; // y is inverted - QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); QPaintEngine *engine = paintEngine(); - if (engine && (oldEngineType == QPaintEngine::OpenGL2) && engine->isActive()) { + if (engine && engine->isActive()) { qWarning("QGLWidget::renderText(): Calling renderText() while a GL 2 paint engine is" " active on the same device is not allowed."); return; @@ -5043,7 +4542,6 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con setAutoBufferSwap(auto_swap); d->disable_clear_on_painter_begin = false; } - qgl_engine_selector()->setPreferredPaintEngine(oldEngineType); #else // QT_OPENGL_ES Q_UNUSED(x); Q_UNUSED(y); @@ -5116,28 +4614,6 @@ GLuint QGLWidget::bindTexture(const QImage &image, GLenum target, GLint format, } -#ifdef Q_MAC_COMPAT_GL_FUNCTIONS -/*! \internal */ -GLuint QGLWidget::bindTexture(const QImage &image, QMacCompatGLenum target, QMacCompatGLint format) -{ - if (image.isNull()) - return 0; - - Q_D(QGLWidget); - return d->glcx->bindTexture(image, GLenum(target), GLint(format), QGLContext::DefaultBindOption); -} - -GLuint QGLWidget::bindTexture(const QImage &image, QMacCompatGLenum target, QMacCompatGLint format, - QGLContext::BindOptions options) -{ - if (image.isNull()) - return 0; - - Q_D(QGLWidget); - return d->glcx->bindTexture(image, GLenum(target), GLint(format), options); -} -#endif - /*! Calls QGLContext:::bindTexture(\a pixmap, \a target, \a format) on the currently set context. @@ -5170,23 +4646,6 @@ GLuint QGLWidget::bindTexture(const QPixmap &pixmap, GLenum target, GLint format return d->glcx->bindTexture(pixmap, target, format, options); } -#ifdef Q_MAC_COMPAT_GL_FUNCTIONS -/*! \internal */ -GLuint QGLWidget::bindTexture(const QPixmap &pixmap, QMacCompatGLenum target, QMacCompatGLint format) -{ - Q_D(QGLWidget); - return d->glcx->bindTexture(pixmap, target, format, QGLContext::DefaultBindOption); -} - -GLuint QGLWidget::bindTexture(const QPixmap &pixmap, QMacCompatGLenum target, QMacCompatGLint format, - QGLContext::BindOptions options) -{ - Q_D(QGLWidget); - return d->glcx->bindTexture(pixmap, target, format, options); -} -#endif - - /*! \overload Calls QGLContext::bindTexture(\a fileName) on the currently set context. @@ -5211,15 +4670,6 @@ void QGLWidget::deleteTexture(GLuint id) d->glcx->deleteTexture(id); } -#ifdef Q_MAC_COMPAT_GL_FUNCTIONS -/*! \internal */ -void QGLWidget::deleteTexture(QMacCompatGLuint id) -{ - Q_D(QGLWidget); - d->glcx->deleteTexture(GLuint(id)); -} -#endif - /*! \since 4.4 @@ -5233,15 +4683,6 @@ void QGLWidget::drawTexture(const QRectF &target, GLuint textureId, GLenum textu d->glcx->drawTexture(target, textureId, textureTarget); } -#ifdef Q_MAC_COMPAT_GL_FUNCTIONS -/*! \internal */ -void QGLWidget::drawTexture(const QRectF &target, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget) -{ - Q_D(QGLWidget); - d->glcx->drawTexture(target, GLint(textureId), GLenum(textureTarget)); -} -#endif - /*! \since 4.4 @@ -5255,42 +4696,17 @@ void QGLWidget::drawTexture(const QPointF &point, GLuint textureId, GLenum textu d->glcx->drawTexture(point, textureId, textureTarget); } -#ifdef Q_MAC_COMPAT_GL_FUNCTIONS -/*! \internal */ -void QGLWidget::drawTexture(const QPointF &point, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget) -{ - Q_D(QGLWidget); - d->glcx->drawTexture(point, GLuint(textureId), GLenum(textureTarget)); -} -#endif - -#ifndef QT_OPENGL_ES_1 Q_GLOBAL_STATIC(QGLEngineThreadStorage<QGL2PaintEngineEx>, qt_gl_2_engine) -#endif - -#ifndef QT_OPENGL_ES_2 -Q_GLOBAL_STATIC(QGLEngineThreadStorage<QOpenGLPaintEngine>, qt_gl_engine) -#endif Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine() { -#if defined(QT_OPENGL_ES_1) - return qt_gl_engine()->engine(); -#elif defined(QT_OPENGL_ES_2) return qt_gl_2_engine()->engine(); -#else - if (qt_gl_preferGL2Engine()) - return qt_gl_2_engine()->engine(); - else - return qt_gl_engine()->engine(); -#endif } /*! \internal - Returns the GL widget's paint engine. This is normally a - QOpenGLPaintEngine. + Returns the GL widget's paint engine. */ QPaintEngine *QGLWidget::paintEngine() const { @@ -5458,10 +4874,6 @@ QGLExtensions::Extensions QGLExtensions::currentContextExtensions() glExtensions |= GenerateMipmap; glExtensions |= FragmentShader; #endif -#if defined(QT_OPENGL_ES_1) - if (extensions.match("GL_OES_framebuffer_object")) - glExtensions |= FramebufferObject; -#endif #if defined(QT_OPENGL_ES) if (extensions.match("GL_OES_packed_depth_stencil")) glExtensions |= PackedDepthStencil; @@ -5554,7 +4966,6 @@ void QGLWidgetPrivate::initContext(QGLContext *context, const QGLWidget* shareWi glcx = new QGLContext(QGLFormat::defaultFormat(), q); } -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) Q_GLOBAL_STATIC(QString, qt_gl_lib_name) Q_OPENGL_EXPORT void qt_set_gl_library_name(const QString& name) @@ -5565,21 +4976,14 @@ Q_OPENGL_EXPORT void qt_set_gl_library_name(const QString& name) Q_OPENGL_EXPORT const QString qt_gl_library_name() { if (qt_gl_lib_name()->isNull()) { -#ifdef Q_WS_MAC - return QLatin1String("/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"); -#else -# if defined(QT_OPENGL_ES_1) - return QLatin1String("GLES_CM"); -# elif defined(QT_OPENGL_ES_2) +# if defined(QT_OPENGL_ES_2) return QLatin1String("GLESv2"); # else return QLatin1String("GL"); # endif -#endif // defined Q_WS_MAC } return *qt_gl_lib_name(); } -#endif void QGLContextGroup::addShare(const QGLContext *context, const QGLContext *share) { Q_ASSERT(context && share); |