diff options
Diffstat (limited to 'src/opengl/qgl_p.h')
-rw-r--r-- | src/opengl/qgl_p.h | 229 |
1 files changed, 11 insertions, 218 deletions
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 4c22f0f3d7..d132b97260 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -60,24 +60,17 @@ #include "QtCore/qthreadstorage.h" #include "QtCore/qhash.h" #include "QtCore/qatomic.h" -#include "private/qwidget_p.h" +#include "QtWidgets/private/qwidget_p.h" #include "qcache.h" #include "qglpaintdevice_p.h" -#ifndef QT_NO_EGL -#include <QtGui/private/qegl_p.h> -#endif - -#if defined(Q_WS_QPA) -#include <QtGui/QPlatformGLContext> -#endif +#include <QtGui/QGuiGLContext> QT_BEGIN_NAMESPACE class QGLContext; class QGLOverlayWidget; class QPixmap; -class QPixmapFilter; #ifdef Q_WS_MAC # ifdef qDebug # define old_qDebug qDebug @@ -96,14 +89,6 @@ QT_END_INCLUDE_NAMESPACE class QMacWindowChangeEvent; #endif -#ifdef Q_WS_QWS -class QWSGLWindowSurface; -#endif - -#ifndef QT_NO_EGL -class QEglContext; -#endif - QT_BEGIN_INCLUDE_NAMESPACE #include <QtOpenGL/private/qglextensions_p.h> QT_END_INCLUDE_NAMESPACE @@ -165,15 +150,6 @@ class Q_OPENGL_EXPORT QGLWidgetPrivate : public QWidgetPrivate public: QGLWidgetPrivate() : QWidgetPrivate() , disable_clear_on_painter_begin(false) -#if defined(Q_WS_QWS) - , wsurf(0) -#endif -#if defined(Q_WS_X11) && !defined(QT_NO_EGL) - , eglSurfaceWindowId(0) -#endif -#if defined(Q_OS_SYMBIAN) - , eglSurfaceWindowId(0) -#endif { isGLWidget = 1; } @@ -199,26 +175,6 @@ public: #endif bool disable_clear_on_painter_begin; - -#if defined(Q_WS_WIN) - void updateColormap(); - QGLContext *olcx; -#elif defined(Q_WS_X11) - QGLOverlayWidget *olw; -#ifndef QT_NO_EGL - void recreateEglSurface(); - WId eglSurfaceWindowId; -#endif -#elif defined(Q_WS_MAC) - QGLContext *olcx; - void updatePaintDevice(); -#elif defined(Q_WS_QWS) - QWSGLWindowSurface *wsurf; -#endif -#ifdef Q_OS_SYMBIAN - void recreateEglSurface(); - WId eglSurfaceWindowId; -#endif }; class QGLContextGroupResourceBase; @@ -351,54 +307,9 @@ public: void syncGlState(); // Makes sure the GL context's state is what we think it is void swapRegion(const QRegion ®ion); -#if defined(Q_WS_WIN) - void updateFormatVersion(); -#endif - -#if defined(Q_WS_WIN) - HGLRC rc; - HDC dc; - WId win; - int pixelFormatId; - QGLCmap* cmap; - HBITMAP hbitmap; - HDC hbitmap_hdc; - Qt::HANDLE threadId; -#endif -#ifndef QT_NO_EGL - QEglContext *eglContext; - EGLSurface eglSurface; - void destroyEglSurfaceForDevice(); - EGLSurface eglSurfaceForDevice() const; - static QEglProperties *extraWindowSurfaceCreationProps; - static void setExtraWindowSurfaceCreationProps(QEglProperties *props); -#endif - -#if defined(Q_WS_QPA) - QPlatformGLContext *platformContext; + QGuiGLContext *guiGlContext; void setupSharing(); -#elif defined(Q_WS_X11) || defined(Q_WS_MAC) - void* cx; -#endif -#if defined(Q_WS_X11) || defined(Q_WS_MAC) - void* vi; -#endif -#if defined(Q_WS_X11) - void* pbuf; - quint32 gpm; - int screen; - QHash<QPixmapData*, QPixmap> boundPixmaps; - QGLTexture *bindTextureFromNativePixmap(QPixmap*, const qint64 key, - QGLContext::BindOptions options); - static void destroyGlSurfaceForPixmap(QPixmapData*); - static void unbindPixmapFromTexture(QPixmapData*); -#endif -#if defined(Q_WS_MAC) - bool update; - void *tryFormat(const QGLFormat &format); - void clearDrawable(); -#endif QGLFormat glFormat; QGLFormat reqFormat; GLuint fbo; @@ -423,10 +334,6 @@ public: uint workaround_brokenAlphaTexSubImage : 1; uint workaround_brokenAlphaTexSubImage_init : 1; -#ifndef QT_NO_EGL - uint ownsEglContext : 1; -#endif - QPaintDevice *paintDevice; QColor transpColor; QGLContext *q_ptr; @@ -439,7 +346,6 @@ public: GLuint current_fbo; GLuint default_fbo; QPaintEngine *active_engine; - QHash<QGLContextResourceBase *, void *> m_resources; QGLTextureDestroyer *texture_destroyer; QGLFunctions *functions; @@ -448,14 +354,8 @@ public: static inline QGLContextGroup *contextGroup(const QGLContext *ctx) { return ctx->d_ptr->group; } -#ifdef Q_WS_WIN - static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *ctx) { return ctx->d_ptr->group->extensionFuncs(); } -#endif - -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) static Q_OPENGL_EXPORT QGLExtensionFuncs qt_extensionFuncs; static Q_OPENGL_EXPORT QGLExtensionFuncs& extensionFuncs(const QGLContext *); -#endif static void setCurrentContext(QGLContext *context); }; @@ -508,34 +408,19 @@ class Q_OPENGL_EXPORT QGLTextureDestroyer : public QObject public: QGLTextureDestroyer() : QObject() { qRegisterMetaType<GLuint>("GLuint"); - connect(this, SIGNAL(freeTexture(QGLContext *, QPixmapData *, GLuint)), - this, SLOT(freeTexture_slot(QGLContext *, QPixmapData *, GLuint))); + connect(this, SIGNAL(freeTexture(QGLContext *, QPlatformPixmap *, GLuint)), + this, SLOT(freeTexture_slot(QGLContext *, QPlatformPixmap *, GLuint))); } - void emitFreeTexture(QGLContext *context, QPixmapData *boundPixmap, GLuint id) { + void emitFreeTexture(QGLContext *context, QPlatformPixmap *boundPixmap, GLuint id) { emit freeTexture(context, boundPixmap, id); } Q_SIGNALS: - void freeTexture(QGLContext *context, QPixmapData *boundPixmap, GLuint id); + void freeTexture(QGLContext *context, QPlatformPixmap *boundPixmap, GLuint id); private slots: - void freeTexture_slot(QGLContext *context, QPixmapData *boundPixmap, GLuint id) { + void freeTexture_slot(QGLContext *context, QPlatformPixmap *boundPixmap, GLuint id) { Q_UNUSED(boundPixmap); -#if defined(Q_WS_X11) - if (boundPixmap) { - QGLContext *oldContext = const_cast<QGLContext *>(QGLContext::currentContext()); - context->makeCurrent(); - // Although glXReleaseTexImage is a glX call, it must be called while there - // is a current context - the context the pixmap was bound to a texture in. - // Otherwise the release doesn't do anything and you get BadDrawable errors - // when you come to delete the context. - QGLContextPrivate::unbindPixmapFromTexture(boundPixmap); - glDeleteTextures(1, &id); - if (oldContext) - oldContext->makeCurrent(); - return; - } -#endif QGLShareContextScope scope(context); glDeleteTextures(1, &id); } @@ -562,17 +447,12 @@ public: id(tx_id), target(tx_target), options(opt) -#if defined(Q_WS_X11) - , boundPixmap(0) -#endif {} ~QGLTexture() { if (options & QGLContext::MemoryManagedBindOption) { Q_ASSERT(context); -#if !defined(Q_WS_X11) - QPixmapData *boundPixmap = 0; -#endif + QPlatformPixmap *boundPixmap = 0; context->d_ptr->texture_destroyer->emitFreeTexture(context, boundPixmap, id); } } @@ -583,10 +463,6 @@ public: QGLContext::BindOptions options; -#if defined(Q_WS_X11) - QPixmapData* boundPixmap; -#endif - bool canBindCompressedTexture (const char *buf, int len, const char *format, bool *hasAlpha); QSize bindCompressedTexture @@ -629,8 +505,8 @@ public: void removeContextTextures(QGLContext *ctx); static QGLTextureCache *instance(); static void cleanupTexturesForCacheKey(qint64 cacheKey); - static void cleanupTexturesForPixampData(QPixmapData* pixmap); - static void cleanupBeforePixmapDestruction(QPixmapData* pixmap); + static void cleanupTexturesForPixampData(QPlatformPixmap* pixmap); + static void cleanupBeforePixmapDestruction(QPlatformPixmap* pixmap); private: QCache<QGLTextureCacheKey, QGLTexture> m_cache; @@ -663,26 +539,6 @@ QGLTexture* QGLTextureCache::getTexture(QGLContext *ctx, qint64 key) extern Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine(); -bool qt_gl_preferGL2Engine(); - -inline GLenum qt_gl_preferredTextureFormat() -{ - return (QGLExtensions::glExtensions() & QGLExtensions::BGRATextureFormat) && QSysInfo::ByteOrder == QSysInfo::LittleEndian - ? GL_BGRA : GL_RGBA; -} - -inline GLenum qt_gl_preferredTextureTarget() -{ -#if defined(QT_OPENGL_ES_2) - return GL_TEXTURE_2D; -#else - return (QGLExtensions::glExtensions() & QGLExtensions::TextureRectangle) - && !qt_gl_preferGL2Engine() - ? GL_TEXTURE_RECTANGLE_NV - : GL_TEXTURE_2D; -#endif -} - /* Base for resources that are shared in a context group. */ @@ -745,69 +601,6 @@ protected: } }; -/* - Base for resources that are context specific. -*/ -class Q_OPENGL_EXPORT QGLContextResourceBase -{ -public: - virtual ~QGLContextResourceBase() { - for (int i = 0; i < m_contexts.size(); ++i) - m_contexts.at(i)->d_ptr->m_resources.remove(this); - } - - void insert(const QGLContext *context, void *value) { - context->d_ptr->m_resources.insert(this, value); - } - - void *value(const QGLContext *context) { - return context->d_ptr->m_resources.value(this, 0); - } - virtual void freeResource(void *value) = 0; - -protected: - QList<const QGLContext *> m_contexts; -}; - -/* - The QGLContextResource template is used to manage a resource for a - single GL context. Just before the context is destroyed (while it's - still the current context), or when the QGLContextResource object - itself is destroyed (implies potential context switches), the - resource will be freed. The class used as the template class type - needs to have a constructor with the following signature: T(const - QGLContext *); -*/ -template <class T> -class QGLContextResource : public QGLContextResourceBase -{ -public: - ~QGLContextResource() { - for (int i = 0; i < m_contexts.size(); ++i) { - const QGLContext *context = m_contexts.at(i); - T *resource = reinterpret_cast<T *>(QGLContextResourceBase::value(context)); - if (resource) { - QGLShareContextScope scope(context); - delete resource; - } - } - } - - T *value(const QGLContext *context) { - T *resource = reinterpret_cast<T *>(QGLContextResourceBase::value(context)); - if (!resource) { - resource = new T(context); - insert(context, resource); - } - return resource; - } - -protected: - void freeResource(void *resource) { - delete reinterpret_cast<T *>(resource); - } -}; - // Put a guard around a GL object identifier and its context. // When the context goes away, a shared context will be used // in its place. If there are no more shared contexts, then |