summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp5
-rw-r--r--src/opengl/gl2paintengineex/qtriangulator.cpp2
-rw-r--r--src/opengl/opengl.pro65
-rw-r--r--src/opengl/qgl.cpp60
-rw-r--r--src/opengl/qgl.h27
-rw-r--r--src/opengl/qgl_egl.cpp13
-rw-r--r--src/opengl/qgl_p.h36
-rw-r--r--src/opengl/qgl_qpa.cpp216
-rw-r--r--src/opengl/qgl_qws.cpp318
-rw-r--r--src/opengl/qgl_symbian.cpp472
-rw-r--r--src/opengl/qgl_x11.cpp50
-rw-r--r--src/opengl/qgl_x11egl.cpp78
-rw-r--r--src/opengl/qglpaintdevice.cpp22
-rw-r--r--src/opengl/qglpaintdevice_p.h2
-rw-r--r--src/opengl/qglpixelbuffer.h1
-rw-r--r--src/opengl/qglpixelbuffer_p.h2
-rw-r--r--src/opengl/qglpixmapfilter.cpp12
-rw-r--r--src/opengl/qglscreen_qws.cpp242
-rw-r--r--src/opengl/qglscreen_qws.h127
-rw-r--r--src/opengl/qgltexturepool.cpp244
-rw-r--r--src/opengl/qgltexturepool_p.h147
-rw-r--r--src/opengl/qglwindowsurface_qws.cpp133
-rw-r--r--src/opengl/qglwindowsurface_qws_p.h90
-rw-r--r--src/opengl/qgraphicsshadereffect.cpp4
-rw-r--r--src/opengl/qgraphicsshadereffect_p.h2
-rw-r--r--src/opengl/qgraphicssystem_gl.cpp114
-rw-r--r--src/opengl/qgraphicssystem_gl_p.h80
-rw-r--r--src/opengl/qpaintengine_opengl.cpp4
-rw-r--r--src/opengl/qpixmapdata_gl.cpp829
-rw-r--r--src/opengl/qpixmapdata_gl_p.h247
-rw-r--r--src/opengl/qpixmapdata_poolgl.cpp934
-rw-r--r--src/opengl/qpixmapdata_x11gl_egl.cpp403
-rw-r--r--src/opengl/qpixmapdata_x11gl_p.h98
-rw-r--r--src/opengl/qwindowsurface_gl.cpp1174
-rw-r--r--src/opengl/qwindowsurface_gl_p.h129
-rw-r--r--src/opengl/qwindowsurface_x11gl.cpp213
-rw-r--r--src/opengl/qwindowsurface_x11gl_p.h83
37 files changed, 248 insertions, 6430 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index d2c63ddc10..58b9002222 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -76,7 +76,6 @@
#include <QPaintEngine>
#include <private/qpainter_p.h>
#include <private/qfontengine_p.h>
-#include <private/qpixmapdata_gl_p.h>
#include <private/qdatabuffer_p.h>
#include <private/qstatictext_p.h>
#include <private/qtriangulator_p.h>
@@ -2335,8 +2334,8 @@ void QGL2PaintEngineExPrivate::systemStateChanged()
if (systemClip.isEmpty()) {
useSystemClip = false;
} else {
- if (q->paintDevice()->devType() == QInternal::Widget && currentClipWidget) {
- QWidgetPrivate *widgetPrivate = qt_widget_private(currentClipWidget->window());
+ if (q->paintDevice()->devType() == QInternal::Widget && currentClipDevice) {
+ QWidgetPrivate *widgetPrivate = qt_widget_private(static_cast<QWidget *>(currentClipDevice)->window());
useSystemClip = widgetPrivate->extra && widgetPrivate->extra->inRenderWithPainter;
} else {
useSystemClip = true;
diff --git a/src/opengl/gl2paintengineex/qtriangulator.cpp b/src/opengl/gl2paintengineex/qtriangulator.cpp
index d4b7131794..fb57f97127 100644
--- a/src/opengl/gl2paintengineex/qtriangulator.cpp
+++ b/src/opengl/gl2paintengineex/qtriangulator.cpp
@@ -41,7 +41,7 @@
#include "qtriangulator_p.h"
-#include <QtGui/qdialog.h>
+#include <QtWidgets/qdialog.h>
#include <QtGui/qevent.h>
#include <QtGui/qpainter.h>
#include <QtGui/qpainterpath.h>
diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro
index e2dc011532..7c1c0ce5fd 100644
--- a/src/opengl/opengl.pro
+++ b/src/opengl/opengl.pro
@@ -2,7 +2,7 @@ load(qt_module)
TARGET = QtOpenGL
QPRO_PWD = $$PWD
-QT = core-private gui-private
+QT = core-private gui-private widgets-private
CONFIG += module
MODULE_PRI = ../modules/qt_opengl.pri
@@ -19,7 +19,7 @@ load(qt_module_config)
HEADERS += $$QT_SOURCE_TREE/src/opengl/qtopenglversion.h
-!win32:!embedded:!mac:!symbian:!qpa:CONFIG += x11
+!win32:!embedded:!mac:!qpa:CONFIG += x11
contains(QT_CONFIG, opengl):CONFIG += opengl
contains(QT_CONFIG, opengles1):CONFIG += opengles1
contains(QT_CONFIG, opengles2):CONFIG += opengles2
@@ -57,9 +57,6 @@ SOURCES += qgl.cpp \
HEADERS += qglshaderprogram.h \
qglpixmapfilter_p.h \
qgraphicsshadereffect_p.h \
- qgraphicssystem_gl_p.h \
- qwindowsurface_gl_p.h \
- qpixmapdata_gl_p.h \
gl2paintengineex/qglgradientcache_p.h \
gl2paintengineex/qglengineshadermanager_p.h \
gl2paintengineex/qgl2pexvertexarray_p.h \
@@ -76,9 +73,6 @@ SOURCES += qgl.cpp \
SOURCES += qglshaderprogram.cpp \
qglpixmapfilter.cpp \
qgraphicsshadereffect.cpp \
- qgraphicssystem_gl.cpp \
- qwindowsurface_gl.cpp \
- qpixmapdata_gl.cpp \
gl2paintengineex/qglgradientcache.cpp \
gl2paintengineex/qglengineshadermanager.cpp \
gl2paintengineex/qgl2pexvertexarray.cpp \
@@ -99,13 +93,9 @@ x11 {
contains(QT_CONFIG, egl) {
SOURCES += qgl_x11egl.cpp \
qglpixelbuffer_egl.cpp \
- qgl_egl.cpp \
- qpixmapdata_x11gl_egl.cpp \
- qwindowsurface_x11gl.cpp
+ qgl_egl.cpp
- HEADERS += qgl_egl_p.h \
- qpixmapdata_x11gl_p.h \
- qwindowsurface_x11gl_p.h
+ HEADERS += qgl_egl_p.h
} else {
SOURCES += qgl_x11.cpp \
@@ -114,7 +104,6 @@ x11 {
contains(QT_CONFIG, fontconfig) {
contains(QT_CONFIG, system-freetype) {
- embedded:CONFIG += opentype
# pull in the proper freetype2 include directory
include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri)
LIBS_PRIVATE += -lfreetype
@@ -136,8 +125,10 @@ mac:!qpa {
}
win32:!wince*: {
DEFINES += QT_NO_EGL
- SOURCES += qgl_win.cpp \
- qglpixelbuffer_win.cpp
+ !qpa {
+ SOURCES += qgl_win.cpp \
+ qglpixelbuffer_win.cpp
+ }
}
wince*: {
SOURCES += qgl_wince.cpp \
@@ -147,44 +138,4 @@ wince*: {
HEADERS += qgl_egl_p.h
}
-embedded {
- SOURCES += qgl_qws.cpp \
- qglpixelbuffer_egl.cpp \
- qglscreen_qws.cpp \
- qglwindowsurface_qws.cpp \
- qgl_egl.cpp
-
- HEADERS += qglscreen_qws.h \
- qglwindowsurface_qws_p.h \
- qgl_egl_p.h
-
- contains(QT_CONFIG, fontconfig) {
- include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri)
- } else {
- DEFINES *= QT_NO_FREETYPE
- }
-}
-
-symbian {
- DEFINES += QGL_USE_TEXTURE_POOL QGL_NO_PRESERVED_SWAP
- SOURCES -= qpixmapdata_gl.cpp
- SOURCES += qgl_symbian.cpp \
- qpixmapdata_poolgl.cpp \
- qglpixelbuffer_egl.cpp \
- qgl_egl.cpp \
- qgltexturepool.cpp
-
- HEADERS += qgl_egl_p.h \
- qgltexturepool_p.h
-
- contains(QT_CONFIG, freetype) {
- DEFINES += QT_NO_FONTCONFIG
- INCLUDEPATH += \
- ../3rdparty/freetype/src \
- ../3rdparty/freetype/include
- }
-
- symbian:TARGET.UID3 = 0x2002131A
-}
-
INCLUDEPATH += ../3rdparty/harfbuzz/src
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index f1fb2b4e7f..d045bf55d1 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -70,17 +70,12 @@
#if !defined(QT_OPENGL_ES_1)
#include "gl2paintengineex/qpaintengineex_opengl2_p.h"
-#include <private/qwindowsurface_gl_p.h>
#endif
#ifndef QT_OPENGL_ES_2
#include <private/qpaintengine_opengl_p.h>
#endif
-#ifdef Q_WS_QWS
-#include <private/qglwindowsurface_qws_p.h>
-#endif
-
#ifdef Q_WS_QPA
#include <QtGui/QPlatformGLContext>
#endif
@@ -89,8 +84,7 @@
#include <qglframebufferobject.h>
#include <private/qimage_p.h>
-#include <private/qpixmapdata_p.h>
-#include <private/qpixmapdata_gl_p.h>
+#include <qplatformpixmap_qpa.h>
#include <private/qglpixelbuffer_p.h>
#include <private/qimagepixmapcleanuphooks_p.h>
#include "qcolormap.h"
@@ -101,9 +95,6 @@
#if defined(QT_OPENGL_ES) && !defined(QT_NO_EGL)
#include <EGL/egl.h>
#endif
-#ifdef QGL_USE_TEXTURE_POOL
-#include <private/qgltexturepool_p.h>
-#endif
// #define QT_GL_CONTEXT_RESOURCE_DEBUG
@@ -1711,7 +1702,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
vi = 0;
#endif
#if defined(Q_WS_QPA)
- platformContext = 0;
+ guiGlContext = 0;
#endif
#if !defined(QT_NO_EGL)
ownsEglContext = false;
@@ -1845,15 +1836,15 @@ Q_GLOBAL_STATIC(QGLTextureCache, qt_gl_texture_cache)
QGLTextureCache::QGLTextureCache()
: m_cache(64*1024) // cache ~64 MB worth of textures - this is not accurate though
{
- QImagePixmapCleanupHooks::instance()->addPixmapDataModificationHook(cleanupTexturesForPixampData);
- QImagePixmapCleanupHooks::instance()->addPixmapDataDestructionHook(cleanupBeforePixmapDestruction);
+ QImagePixmapCleanupHooks::instance()->addPlatformPixmapModificationHook(cleanupTexturesForPixampData);
+ QImagePixmapCleanupHooks::instance()->addPlatformPixmapDestructionHook(cleanupBeforePixmapDestruction);
QImagePixmapCleanupHooks::instance()->addImageHook(cleanupTexturesForCacheKey);
}
QGLTextureCache::~QGLTextureCache()
{
- QImagePixmapCleanupHooks::instance()->removePixmapDataModificationHook(cleanupTexturesForPixampData);
- QImagePixmapCleanupHooks::instance()->removePixmapDataDestructionHook(cleanupBeforePixmapDestruction);
+ QImagePixmapCleanupHooks::instance()->removePlatformPixmapModificationHook(cleanupTexturesForPixampData);
+ QImagePixmapCleanupHooks::instance()->removePlatformPixmapDestructionHook(cleanupBeforePixmapDestruction);
QImagePixmapCleanupHooks::instance()->removeImageHook(cleanupTexturesForCacheKey);
}
@@ -1912,18 +1903,18 @@ void QGLTextureCache::cleanupTexturesForCacheKey(qint64 cacheKey)
}
-void QGLTextureCache::cleanupTexturesForPixampData(QPixmapData* pmd)
+void QGLTextureCache::cleanupTexturesForPixampData(QPlatformPixmap* pmd)
{
cleanupTexturesForCacheKey(pmd->cacheKey());
}
-void QGLTextureCache::cleanupBeforePixmapDestruction(QPixmapData* pmd)
+void QGLTextureCache::cleanupBeforePixmapDestruction(QPlatformPixmap* pmd)
{
// Remove any bound textures first:
cleanupTexturesForPixampData(pmd);
#if defined(Q_WS_X11)
- if (pmd->classId() == QPixmapData::X11Class) {
+ if (pmd->classId() == QPlatformPixmap::X11Class) {
Q_ASSERT(pmd->ref == 0); // Make sure reference counting isn't broken
QGLContextPrivate::destroyGlSurfaceForPixmap(pmd);
}
@@ -2547,18 +2538,8 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
#endif
const QImage &constRef = img; // to avoid detach in bits()...
-#ifdef QGL_USE_TEXTURE_POOL
- QGLTexturePool::instance()->createPermanentTexture(tx_id,
- target,
- 0, internalFormat,
- img.width(), img.height(),
- externalFormat,
- pixel_type,
- constRef.bits());
-#else
glTexImage2D(target, 0, internalFormat, img.width(), img.height(), 0, externalFormat,
pixel_type, constRef.bits());
-#endif
#if defined(QT_OPENGL_ES_2)
if (genMipmap)
glGenerateMipmap(target);
@@ -2601,19 +2582,8 @@ QGLTexture *QGLContextPrivate::textureCacheLookup(const qint64 key, GLenum targe
QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, QGLContext::BindOptions options)
{
Q_Q(QGLContext);
- QPixmapData *pd = pixmap.pixmapData();
-#if !defined(QT_OPENGL_ES_1)
- if (target == GL_TEXTURE_2D && pd->classId() == QPixmapData::OpenGLClass) {
- const QGLPixmapData *data = static_cast<const QGLPixmapData *>(pd);
-
- if (data->isValidContext(q)) {
- data->bind();
- return data->texture();
- }
- }
-#else
+ QPlatformPixmap *pd = pixmap.handle();
Q_UNUSED(pd);
-#endif
const qint64 key = pixmap.cacheKey();
QGLTexture *texture = textureCacheLookup(key, target);
@@ -2631,7 +2601,7 @@ 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() == QPixmapData::X11Class && pd->pixelType() == QPixmapData::PixmapType
+ if (pd->classId() == QPlatformPixmap::X11Class && pd->pixelType() == QPlatformPixmap::PixmapType
&& xinfo && xinfo->screen() == pixmap.x11Info().screen()
&& target == GL_TEXTURE_2D
&& QApplication::instance()->thread() == QThread::currentThread())
@@ -3330,7 +3300,7 @@ bool QGLContext::create(const QGLContext* shareContext)
{
Q_D(QGLContext);
#ifdef Q_WS_QPA
- if (!d->paintDevice && !d->platformContext)
+ if (!d->paintDevice && !d->guiGlContext)
#else
if (!d->paintDevice)
#endif
@@ -3420,8 +3390,8 @@ void QGLContext::setInitialized(bool on)
const QGLContext* QGLContext::currentContext()
{
#ifdef Q_WS_QPA
- if (const QPlatformGLContext *threadContext = QPlatformGLContext::currentContext()) {
- return QGLContext::fromPlatformGLContext(const_cast<QPlatformGLContext *>(threadContext));
+ if (const QGuiGLContext *threadContext = QGuiGLContext::currentContext()) {
+ return QGLContext::fromGuiGLContext(const_cast<QGuiGLContext *>(threadContext));
}
return 0;
#else
@@ -4472,7 +4442,7 @@ QPixmap QGLWidget::renderPixmap(int w, int h, bool useContext)
int old_depth = qt_x11_preferred_pixmap_depth;
qt_x11_preferred_pixmap_depth = x11Info().depth();
- QPixmapData *data = new QX11PixmapData(QPixmapData::PixmapType);
+ QPlatformPixmap *data = new QX11PlatformPixmap(QPlatformPixmap::PixmapType);
data->resize(sz.width(), sz.height());
QPixmap pm(data);
qt_x11_preferred_pixmap_depth = old_depth;
diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h
index 4d7b6f1978..e08e2d234f 100644
--- a/src/opengl/qgl.h
+++ b/src/opengl/qgl.h
@@ -42,23 +42,23 @@
#ifndef QGL_H
#define QGL_H
-#include <QtGui/qwidget.h>
+#include <QtWidgets/qwidget.h>
#include <QtGui/qpaintengine.h>
#include <QtOpenGL/qglcolormap.h>
#include <QtCore/qmap.h>
#include <QtCore/qscopedpointer.h>
-#ifdef Q_WS_QPA
-#include <QtGui/QPlatformWindowFormat>
-#endif
+#include <QtGui/QSurfaceFormat>
QT_BEGIN_HEADER
-#if defined(Q_WS_WIN)
+#if defined(Q_OS_WIN)
# include <QtCore/qt_windows.h>
#endif
-#if defined(QT_OPENGL_ES_1)
+#if defined(Q_OS_MAC)
+# include <OpenGL/gl.h>
+#elif defined(QT_OPENGL_ES_1)
# if defined(Q_OS_MAC)
# include <OpenGLES/ES1/gl.h>
# else
@@ -284,10 +284,8 @@ public:
static OpenGLVersionFlags openGLVersionFlags();
-#if defined(Q_WS_QPA)
- static QGLFormat fromPlatformWindowFormat(const QPlatformWindowFormat &format);
- static QPlatformWindowFormat toPlatformWindowFormat(const QGLFormat &format);
-#endif
+ static QGLFormat fromSurfaceFormat(const QSurfaceFormat &format);
+ static QSurfaceFormat toSurfaceFormat(const QGLFormat &format);
private:
QGLFormatPrivate *d;
@@ -399,8 +397,10 @@ public:
static const QGLContext* currentContext();
#ifdef Q_WS_QPA
- static QGLContext *fromPlatformGLContext(QPlatformGLContext *platformContext);
+ static QGLContext *fromGuiGLContext(QGuiGLContext *platformContext);
+ QGuiGLContext *contextHandle() const;
#endif
+
protected:
virtual bool chooseContext(const QGLContext* shareContext = 0);
@@ -431,7 +431,7 @@ protected:
private:
#ifdef Q_WS_QPA
- QGLContext(QPlatformGLContext *platformContext);
+ QGLContext(QGuiGLContext *windowContext);
#endif
QScopedPointer<QGLContextPrivate> d_ptr;
@@ -446,8 +446,6 @@ private:
friend class QGL2PaintEngineEx;
friend class QGL2PaintEngineExPrivate;
friend class QGLEngineShaderManager;
- friend class QGLWindowSurface;
- friend class QGLPixmapData;
friend class QGLPixmapFilterBase;
friend class QGLTextureGlyphCache;
friend struct QGLGlyphTexture;
@@ -469,7 +467,6 @@ private:
friend class QGLFBOGLPaintDevice;
friend class QGLPaintDevice;
friend class QGLWidgetGLPaintDevice;
- friend class QX11GLPixmapData;
friend class QX11GLSharedContexts;
friend class QGLContextResourceBase;
friend class QSGDistanceFieldGlyphCache;
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index 4de5122a86..dcf340fb10 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -261,8 +261,7 @@ void QGLContextPrivate::destroyEglSurfaceForDevice()
#if defined(Q_WS_X11) || defined(Q_OS_SYMBIAN)
// Make sure we don't call eglDestroySurface on a surface which
// was created for a different winId. This applies only to QGLWidget
- // paint device, so make sure this is the one we're operating on
- // (as opposed to a QGLWindowSurface use case).
+ // paint device, so make sure this is the one we're operating on.
if (paintDevice && paintDevice->devType() == QInternal::Widget) {
QWidget *w = static_cast<QWidget *>(paintDevice);
if (QGLWidget *wgl = qobject_cast<QGLWidget *>(w)) {
@@ -281,16 +280,16 @@ void QGLContextPrivate::destroyEglSurfaceForDevice()
EGLSurface QGLContextPrivate::eglSurfaceForDevice() const
{
- // If a QPixmapData had to create the QGLContext, we don't have a paintDevice
+ // If a QPlatformPixmap had to create the QGLContext, we don't have a paintDevice
if (!paintDevice)
return eglSurface;
#ifdef Q_WS_X11
if (paintDevice->devType() == QInternal::Pixmap) {
- QPixmapData *pmd = static_cast<QPixmap*>(paintDevice)->data_ptr().data();
- if (pmd->classId() == QPixmapData::X11Class) {
- QX11PixmapData* x11PixmapData = static_cast<QX11PixmapData*>(pmd);
- return (EGLSurface)x11PixmapData->gl_surface;
+ QPlatformPixmap *pmd = static_cast<QPixmap*>(paintDevice)->data_ptr().data();
+ if (pmd->classId() == QPlatformPixmap::X11Class) {
+ QX11PlatformPixmap* x11PlatformPixmap = static_cast<QX11PlatformPixmap*>(pmd);
+ return (EGLSurface)x11PlatformPixmap->gl_surface;
}
}
#endif
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 4c22f0f3d7..f2590e82b1 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -60,7 +60,7 @@
#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"
@@ -69,7 +69,7 @@
#endif
#if defined(Q_WS_QPA)
-#include <QtGui/QPlatformGLContext>
+#include <QtGui/QGuiGLContext>
#endif
QT_BEGIN_NAMESPACE
@@ -96,10 +96,6 @@ QT_END_INCLUDE_NAMESPACE
class QMacWindowChangeEvent;
#endif
-#ifdef Q_WS_QWS
-class QWSGLWindowSurface;
-#endif
-
#ifndef QT_NO_EGL
class QEglContext;
#endif
@@ -212,8 +208,6 @@ public:
#elif defined(Q_WS_MAC)
QGLContext *olcx;
void updatePaintDevice();
-#elif defined(Q_WS_QWS)
- QWSGLWindowSurface *wsurf;
#endif
#ifdef Q_OS_SYMBIAN
void recreateEglSurface();
@@ -375,7 +369,7 @@ public:
#endif
#if defined(Q_WS_QPA)
- QPlatformGLContext *platformContext;
+ QGuiGLContext *guiGlContext;
void setupSharing();
#elif defined(Q_WS_X11) || defined(Q_WS_MAC)
@@ -388,11 +382,11 @@ public:
void* pbuf;
quint32 gpm;
int screen;
- QHash<QPixmapData*, QPixmap> boundPixmaps;
+ QHash<QPlatformPixmap*, QPixmap> boundPixmaps;
QGLTexture *bindTextureFromNativePixmap(QPixmap*, const qint64 key,
QGLContext::BindOptions options);
- static void destroyGlSurfaceForPixmap(QPixmapData*);
- static void unbindPixmapFromTexture(QPixmapData*);
+ static void destroyGlSurfaceForPixmap(QPlatformPixmap*);
+ static void unbindPixmapFromTexture(QPlatformPixmap*);
#endif
#if defined(Q_WS_MAC)
bool update;
@@ -508,18 +502,18 @@ 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) {
@@ -571,7 +565,7 @@ public:
if (options & QGLContext::MemoryManagedBindOption) {
Q_ASSERT(context);
#if !defined(Q_WS_X11)
- QPixmapData *boundPixmap = 0;
+ QPlatformPixmap *boundPixmap = 0;
#endif
context->d_ptr->texture_destroyer->emitFreeTexture(context, boundPixmap, id);
}
@@ -584,7 +578,7 @@ public:
QGLContext::BindOptions options;
#if defined(Q_WS_X11)
- QPixmapData* boundPixmap;
+ QPlatformPixmap* boundPixmap;
#endif
bool canBindCompressedTexture
@@ -629,8 +623,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;
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp
index 9ba8b75362..e6c135bb7f 100644
--- a/src/opengl/qgl_qpa.cpp
+++ b/src/opengl/qgl_qpa.cpp
@@ -40,12 +40,14 @@
****************************************************************************/
#include <QApplication>
-#include <QtGui/private/qapplication_p.h>
+#include <private/qapplication_p.h>
#include <QPixmap>
#include <QDebug>
-#include <QtGui/private/qapplication_p.h>
+#include <private/qapplication_p.h>
+#include <QtGui/QPlatformGLContext>
#include <QtGui/QPlatformWindow>
+#include <QtGui/QSurfaceFormat>
#include "qgl.h"
#include "qgl_p.h"
@@ -53,81 +55,66 @@
QT_BEGIN_NAMESPACE
/*!
- Returns an OpenGL format for the platform window format specified by \a format.
+ Returns an OpenGL format for the window format specified by \a format.
*/
-QGLFormat QGLFormat::fromPlatformWindowFormat(const QPlatformWindowFormat &format)
+QGLFormat QGLFormat::fromSurfaceFormat(const QSurfaceFormat &format)
{
QGLFormat retFormat;
- retFormat.setAccum(format.accum());
- if (format.accumBufferSize() >= 0)
- retFormat.setAccumBufferSize(format.accumBufferSize());
- retFormat.setAlpha(format.alpha());
if (format.alphaBufferSize() >= 0)
retFormat.setAlphaBufferSize(format.alphaBufferSize());
if (format.blueBufferSize() >= 0)
retFormat.setBlueBufferSize(format.blueBufferSize());
- retFormat.setDepth(format.depth());
- if (format.depthBufferSize() >= 0)
- retFormat.setDepthBufferSize(format.depthBufferSize());
- retFormat.setDirectRendering(format.directRendering());
- retFormat.setDoubleBuffer(format.doubleBuffer());
if (format.greenBufferSize() >= 0)
retFormat.setGreenBufferSize(format.greenBufferSize());
if (format.redBufferSize() >= 0)
retFormat.setRedBufferSize(format.redBufferSize());
- retFormat.setRgba(format.rgba());
- retFormat.setSampleBuffers(format.sampleBuffers());
- retFormat.setSamples(format.sampleBuffers());
- retFormat.setStencil(format.stencil());
- if (format.stencilBufferSize() >= 0)
+ if (format.depthBufferSize() >= 0)
+ retFormat.setDepthBufferSize(format.depthBufferSize());
+ if (format.samples() > 1) {
+ retFormat.setSampleBuffers(format.samples());
+ retFormat.setSamples(true);
+ }
+ if (format.stencilBufferSize() > 0) {
+ retFormat.setStencil(true);
retFormat.setStencilBufferSize(format.stencilBufferSize());
+ }
+ retFormat.setDoubleBuffer(format.swapBehavior() != QSurfaceFormat::SingleBuffer);
retFormat.setStereo(format.stereo());
- retFormat.setSwapInterval(format.swapInterval());
return retFormat;
}
/*!
- Returns a platform window format for the OpenGL format specified by \a format.
+ Returns a window format for the OpenGL format specified by \a format.
*/
-QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format)
+QSurfaceFormat QGLFormat::toSurfaceFormat(const QGLFormat &format)
{
- QPlatformWindowFormat retFormat;
- retFormat.setAccum(format.accum());
- if (format.accumBufferSize() >= 0)
- retFormat.setAccumBufferSize(format.accumBufferSize());
- retFormat.setAlpha(format.alpha());
- if (format.alphaBufferSize() >= 0)
- retFormat.setAlphaBufferSize(format.alphaBufferSize());
+ QSurfaceFormat retFormat;
+ if (format.alpha())
+ retFormat.setAlphaBufferSize(format.alphaBufferSize() == -1 ? 1 : format.alphaBufferSize());
if (format.blueBufferSize() >= 0)
retFormat.setBlueBufferSize(format.blueBufferSize());
- retFormat.setDepth(format.depth());
- if (format.depthBufferSize() >= 0)
- retFormat.setDepthBufferSize(format.depthBufferSize());
- retFormat.setDirectRendering(format.directRendering());
- retFormat.setDoubleBuffer(format.doubleBuffer());
if (format.greenBufferSize() >= 0)
retFormat.setGreenBufferSize(format.greenBufferSize());
if (format.redBufferSize() >= 0)
retFormat.setRedBufferSize(format.redBufferSize());
- retFormat.setRgba(format.rgba());
- retFormat.setSampleBuffers(format.sampleBuffers());
- if (format.samples() >= 0)
- retFormat.setSamples(format.samples());
- retFormat.setStencil(format.stencil());
- if (format.stencilBufferSize() >= 0)
- retFormat.setStencilBufferSize(format.stencilBufferSize());
+ if (format.depth())
+ retFormat.setDepthBufferSize(format.depthBufferSize() == -1 ? 1 : format.depthBufferSize());
+ retFormat.setSwapBehavior(format.doubleBuffer() ? QSurfaceFormat::DoubleBuffer : QSurfaceFormat::DefaultSwapBehavior);
+ if (format.sampleBuffers())
+ retFormat.setSamples(format.samples() == -1 ? 4 : format.samples());
+ if (format.stencil())
+ retFormat.setStencilBufferSize(format.stencilBufferSize() == -1 ? 1 : format.stencilBufferSize());
retFormat.setStereo(format.stereo());
- retFormat.setSwapInterval(format.swapInterval());
return retFormat;
}
void QGLContextPrivate::setupSharing() {
Q_Q(QGLContext);
- QPlatformGLContext *sharedPlatformGLContext = platformContext->platformWindowFormat().sharedGLContext();
- if (sharedPlatformGLContext) {
- QGLContext *actualSharedContext = QGLContext::fromPlatformGLContext(sharedPlatformGLContext);
+ QGuiGLContext *sharedContext = guiGlContext->shareContext();
+ if (sharedContext) {
+ QGLContext *actualSharedContext = QGLContext::fromGuiGLContext(sharedContext);
sharing = true;
- QGLContextGroup::addShare(q,actualSharedContext);
+ QGLContextGroup::addShare(q, actualSharedContext);
}
}
@@ -150,26 +137,28 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
d->valid = false;
}else {
QWidget *widget = static_cast<QWidget *>(d->paintDevice);
- if (!widget->platformWindow()){
- QGLFormat glformat = format();
- QPlatformWindowFormat winFormat = QGLFormat::toPlatformWindowFormat(glformat);
- if (shareContext) {
- winFormat.setSharedContext(shareContext->d_func()->platformContext);
- }
- if (widget->testAttribute(Qt::WA_TranslucentBackground))
- winFormat.setAlpha(true);
- winFormat.setWindowApi(QPlatformWindowFormat::OpenGL);
- winFormat.setWindowSurface(false);
- widget->setPlatformWindowFormat(winFormat);
+ QGLFormat glformat = format();
+ QSurfaceFormat winFormat = QGLFormat::toSurfaceFormat(glformat);
+ if (widget->testAttribute(Qt::WA_TranslucentBackground))
+ winFormat.setAlphaBufferSize(qMax(winFormat.alphaBufferSize(), 8));
+
+ if (!widget->windowHandle()->handle()) {
+ widget->windowHandle()->setSurfaceType(QWindow::OpenGLSurface);
+ widget->windowHandle()->setFormat(winFormat);
widget->winId();//make window
}
- d->platformContext = widget->platformWindow()->glContext();
- Q_ASSERT(d->platformContext);
- d->glFormat = QGLFormat::fromPlatformWindowFormat(d->platformContext->platformWindowFormat());
- d->valid =(bool) d->platformContext;
- if (d->valid) {
- d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
- }
+
+ delete d->guiGlContext;
+ QGuiGLContext *shareGlContext = shareContext ? shareContext->d_func()->guiGlContext : 0;
+ d->guiGlContext = new QGuiGLContext;
+ d->guiGlContext->setFormat(winFormat);
+ d->guiGlContext->setShareContext(shareGlContext);
+ d->valid = d->guiGlContext->create();
+
+ if (d->valid)
+ d->guiGlContext->setQGLContextHandle(this,qDeleteQGLContext);
+
+ d->glFormat = QGLFormat::fromSurfaceFormat(d->guiGlContext->format());
d->setupSharing();
}
@@ -190,42 +179,55 @@ void QGLContext::reset()
d->transpColor = QColor();
d->initDone = false;
QGLContextGroup::removeShare(this);
- if (d->platformContext) {
- d->platformContext->setQGLContextHandle(0,0);
+ if (d->guiGlContext) {
+ d->guiGlContext->setQGLContextHandle(0,0);
}
}
void QGLContext::makeCurrent()
{
Q_D(QGLContext);
- d->platformContext->makeCurrent();
+ if (!d->paintDevice || d->paintDevice->devType() != QInternal::Widget)
+ return;
+
+ QWidget *widget = static_cast<QWidget *>(d->paintDevice);
+ if (!widget->windowHandle())
+ return;
- if (!d->workaroundsCached) {
- d->workaroundsCached = true;
- const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
- if (renderer && strstr(renderer, "Mali")) {
- d->workaround_brokenFBOReadBack = true;
+ if (d->guiGlContext->makeCurrent(widget->windowHandle())) {
+ if (!d->workaroundsCached) {
+ d->workaroundsCached = true;
+ const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
+ if (renderer && strstr(renderer, "Mali")) {
+ d->workaround_brokenFBOReadBack = true;
+ }
}
}
-
}
void QGLContext::doneCurrent()
{
Q_D(QGLContext);
- d->platformContext->doneCurrent();
+ d->guiGlContext->doneCurrent();
}
void QGLContext::swapBuffers() const
{
Q_D(const QGLContext);
- d->platformContext->swapBuffers();
+ if (!d->paintDevice || d->paintDevice->devType() != QInternal::Widget)
+ return;
+
+ QWidget *widget = static_cast<QWidget *>(d->paintDevice);
+ if (!widget->windowHandle())
+ return;
+
+ d->guiGlContext->swapBuffers(widget->windowHandle());
}
void *QGLContext::getProcAddress(const QString &procName) const
{
Q_D(const QGLContext);
- return d->platformContext->getProcAddress(procName);
+ return (void *)d->guiGlContext->getProcAddress(procName.toAscii());
}
void QGLWidget::setContext(QGLContext *context,
@@ -283,33 +285,34 @@ void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase)
class QGLTemporaryContextPrivate
{
public:
- QWidget *widget;
- QPlatformGLContext *context;
+ QWindow *window;
+ QGuiGLContext *context;
+
+ QGLContext *oldContext;
};
QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
: d(new QGLTemporaryContextPrivate)
{
- d->context = const_cast<QPlatformGLContext *>(QPlatformGLContext::currentContext());
- if (d->context)
- d->context->doneCurrent();
- d->widget = new QWidget;
- d->widget->setGeometry(0,0,3,3);
- QPlatformWindowFormat format = d->widget->platformWindowFormat();
- format.setWindowApi(QPlatformWindowFormat::OpenGL);
- format.setWindowSurface(false);
- d->widget->setPlatformWindowFormat(format);
- d->widget->winId();
+ d->oldContext = const_cast<QGLContext *>(QGLContext::currentContext());
- d->widget->platformWindow()->glContext()->makeCurrent();
+ d->window = new QWindow;
+ d->window->setSurfaceType(QWindow::OpenGLSurface);
+ d->window->setGeometry(QRect(0, 0, 3, 3));
+ d->window->create();
+
+ d->context = new QGuiGLContext;
+ d->context->create();
+ d->context->makeCurrent(d->window);
}
QGLTemporaryContext::~QGLTemporaryContext()
{
- d->widget->platformWindow()->glContext()->doneCurrent();
- if (d->context)
- d->context->makeCurrent();
- delete d->widget;
+ if (d->oldContext)
+ d->oldContext->makeCurrent();
+
+ delete d->context;
+ delete d->window;
}
@@ -375,29 +378,34 @@ void QGLWidget::setColormap(const QGLColormap & c)
Q_UNUSED(c);
}
-QGLContext::QGLContext(QPlatformGLContext *platformContext)
+QGLContext::QGLContext(QGuiGLContext *context)
: d_ptr(new QGLContextPrivate(this))
{
Q_D(QGLContext);
- d->init(0,QGLFormat::fromPlatformWindowFormat(platformContext->platformWindowFormat()));
- d->platformContext = platformContext;
- d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
- d->valid = true;
+ d->init(0, QGLFormat::fromSurfaceFormat(context->format()));
+ d->guiGlContext = context;
+ d->guiGlContext->setQGLContextHandle(this,qDeleteQGLContext);
+ d->valid = context->isValid();
d->setupSharing();
}
+QGuiGLContext *QGLContext::contextHandle() const
+{
+ Q_D(const QGLContext);
+ return d->guiGlContext;
+}
+
/*!
- Returns a OpenGL context for the platform-specific OpenGL context given by
- \a platformContext.
+ Returns a OpenGL context for the window context specified by \a windowContext
*/
-QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContext)
+QGLContext *QGLContext::fromGuiGLContext(QGuiGLContext *context)
{
- if (!platformContext)
+ if (!context)
return 0;
- if (platformContext->qGLContextHandle()) {
- return reinterpret_cast<QGLContext *>(platformContext->qGLContextHandle());
+ if (context->qGLContextHandle()) {
+ return reinterpret_cast<QGLContext *>(context->qGLContextHandle());
}
- QGLContext *glContext = new QGLContext(platformContext);
+ QGLContext *glContext = new QGLContext(context);
//Dont call create on context. This can cause the platformFormat to be set on the widget, which
//will cause the platformWindow to be recreated.
return glContext;
diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp
deleted file mode 100644
index c0844786e2..0000000000
--- a/src/opengl/qgl_qws.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgl.h"
-#include "qgl_egl_p.h"
-#include "qglpixelbuffer.h"
-
-#include <qglscreen_qws.h>
-#include <qscreenproxy_qws.h>
-#include <private/qglwindowsurface_qws_p.h>
-
-#include <private/qbackingstore_p.h>
-#include <private/qfont_p.h>
-#include <private/qfontengine_p.h>
-#include <private/qgl_p.h>
-#include <private/qpaintengine_opengl_p.h>
-#include <qpixmap.h>
-#include <qtimer.h>
-#include <qapplication.h>
-#include <qstack.h>
-#include <qdesktopwidget.h>
-#include <qdebug.h>
-#include <qvarlengtharray.h>
-
-QT_BEGIN_NAMESPACE
-
-static QGLScreen *glScreenForDevice(QPaintDevice *device)
-{
- QScreen *screen = qt_screen;
- if (screen->classId() == QScreen::MultiClass) {
- int screenNumber;
- if (device && device->devType() == QInternal::Widget)
- screenNumber = qApp->desktop()->screenNumber(static_cast<QWidget *>(device));
- else
- screenNumber = 0;
- screen = screen->subScreens()[screenNumber];
- }
- while (screen->classId() == QScreen::ProxyClass ||
- screen->classId() == QScreen::TransformedClass) {
- screen = static_cast<QProxyScreen *>(screen)->screen();
- }
- if (screen->classId() == QScreen::GLClass)
- return static_cast<QGLScreen *>(screen);
- else
- return 0;
-}
-
-/*
- QGLTemporaryContext implementation
-*/
-
-class QGLTemporaryContextPrivate
-{
-public:
- QGLWidget *widget;
-};
-
-QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
- : d(new QGLTemporaryContextPrivate)
-{
- d->widget = new QGLWidget;
- d->widget->makeCurrent();
-}
-
-QGLTemporaryContext::~QGLTemporaryContext()
-{
- delete d->widget;
-}
-
-/*****************************************************************************
- QOpenGL debug facilities
- *****************************************************************************/
-//#define DEBUG_OPENGL_REGION_UPDATE
-
-bool QGLFormat::hasOpenGLOverlays()
-{
- QGLScreen *glScreen = glScreenForDevice(0);
- if (glScreen)
- return (glScreen->options() & QGLScreen::Overlays);
- else
- return false;
-}
-
-static EGLSurface qt_egl_create_surface
- (QEglContext *context, QPaintDevice *device,
- const QEglProperties *properties = 0)
-{
- // Get the screen surface functions, which are used to create native ids.
- QGLScreen *glScreen = glScreenForDevice(device);
- if (!glScreen)
- return EGL_NO_SURFACE;
- QGLScreenSurfaceFunctions *funcs = glScreen->surfaceFunctions();
- if (!funcs)
- return EGL_NO_SURFACE;
-
- // Create the native drawable for the paint device.
- int devType = device->devType();
- EGLNativePixmapType pixmapDrawable = 0;
- EGLNativeWindowType windowDrawable = 0;
- bool ok;
- if (devType == QInternal::Pixmap) {
- ok = funcs->createNativePixmap(static_cast<QPixmap *>(device), &pixmapDrawable);
- } else if (devType == QInternal::Image) {
- ok = funcs->createNativeImage(static_cast<QImage *>(device), &pixmapDrawable);
- } else {
- ok = funcs->createNativeWindow(static_cast<QWidget *>(device), &windowDrawable);
- }
- if (!ok) {
- qWarning("QEglContext::createSurface(): Cannot create the native EGL drawable");
- return EGL_NO_SURFACE;
- }
-
- // Create the EGL surface to draw into, based on the native drawable.
- const int *props;
- if (properties)
- props = properties->properties();
- else
- props = 0;
- EGLSurface surf;
- if (devType == QInternal::Widget) {
- surf = eglCreateWindowSurface
- (context->display(), context->config(), windowDrawable, props);
- } else {
- surf = eglCreatePixmapSurface
- (context->display(), context->config(), pixmapDrawable, props);
- }
- if (surf == EGL_NO_SURFACE)
- qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError());
- return surf;
-}
-
-bool QGLContext::chooseContext(const QGLContext* shareContext)
-{
- Q_D(QGLContext);
-
- // Validate the device.
- if (!device())
- return false;
- int devType = device()->devType();
- if (devType != QInternal::Pixmap && devType != QInternal::Image && devType != QInternal::Widget) {
- qWarning("QGLContext::chooseContext(): Cannot create QGLContext's for paint device type %d", devType);
- return false;
- }
-
- // Get the display and initialize it.
- d->eglContext = new QEglContext();
- d->ownsEglContext = true;
- d->eglContext->setApi(QEgl::OpenGL);
-
- // Construct the configuration we need for this surface.
- QEglProperties configProps;
- qt_eglproperties_set_glformat(configProps, d->glFormat);
- configProps.setDeviceType(devType);
- configProps.setPaintDeviceFormat(device());
- configProps.setRenderableType(QEgl::OpenGL);
-
- // Search for a matching configuration, reducing the complexity
- // each time until we get something that matches.
- if (!d->eglContext->chooseConfig(configProps)) {
- delete d->eglContext;
- d->eglContext = 0;
- return false;
- }
-
- // Inform the higher layers about the actual format properties.
- qt_glformat_from_eglconfig(d->glFormat, d->eglContext->config());
-
- // Create a new context for the configuration.
- if (!d->eglContext->createContext
- (shareContext ? shareContext->d_func()->eglContext : 0)) {
- delete d->eglContext;
- d->eglContext = 0;
- return false;
- }
- d->sharing = d->eglContext->isSharing();
- if (d->sharing && shareContext)
- const_cast<QGLContext *>(shareContext)->d_func()->sharing = true;
-
-#if defined(EGL_VERSION_1_1)
- if (d->glFormat.swapInterval() != -1 && devType == QInternal::Widget)
- eglSwapInterval(d->eglContext->display(), d->glFormat.swapInterval());
-#endif
-
- // Create the EGL surface to draw into. We cannot use
- // QEglContext::createSurface() because it does not have
- // access to the QGLScreen.
- d->eglSurface = qt_egl_create_surface(d->eglContext, device());
- if (d->eglSurface == EGL_NO_SURFACE) {
- delete d->eglContext;
- d->eglContext = 0;
- return false;
- }
-
- return true;
-}
-
-
-bool QGLWidget::event(QEvent *e)
-{
- return QWidget::event(e);
-}
-
-
-void QGLWidget::resizeEvent(QResizeEvent *)
-{
- Q_D(QGLWidget);
- if (!isValid())
- return;
- makeCurrent();
- if (!d->glcx->initialized())
- glInit();
- resizeGL(width(), height());
- //handle overlay
-}
-
-const QGLContext* QGLWidget::overlayContext() const
-{
- return 0;
-}
-
-void QGLWidget::makeOverlayCurrent()
-{
- //handle overlay
-}
-
-void QGLWidget::updateOverlayGL()
-{
- //handle overlay
-}
-
-void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, bool deleteOldContext)
-{
- Q_D(QGLWidget);
- if(context == 0) {
- qWarning("QGLWidget::setContext: Cannot set null context");
- return;
- }
-
- if(d->glcx)
- d->glcx->doneCurrent();
- QGLContext* oldcx = d->glcx;
- d->glcx = context;
- if(!d->glcx->isValid())
- d->glcx->create(shareContext ? shareContext : oldcx);
- if(deleteOldContext)
- delete oldcx;
-}
-
-void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget* shareWidget)
-{
- Q_Q(QGLWidget);
-
- QGLScreen *glScreen = glScreenForDevice(q);
- if (glScreen) {
- wsurf = static_cast<QWSGLWindowSurface*>(glScreen->createSurface(q));
- q->setWindowSurface(wsurf);
- }
-
- initContext(context, shareWidget);
-
- if(q->isValid() && glcx->format().hasOverlay()) {
- //no overlay
- qWarning("QtOpenGL ES doesn't currently support overlays");
- }
-}
-
-void QGLWidgetPrivate::cleanupColormaps()
-{
-}
-
-const QGLColormap & QGLWidget::colormap() const
-{
- return d_func()->cmap;
-}
-
-void QGLWidget::setColormap(const QGLColormap &)
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp
deleted file mode 100644
index bc65bcd44a..0000000000
--- a/src/opengl/qgl_symbian.cpp
+++ /dev/null
@@ -1,472 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include "qgl.h"
-#include <fbs.h>
-#include <private/qt_s60_p.h>
-#include <private/qpixmap_s60_p.h>
-#include <private/qimagepixmapcleanuphooks_p.h>
-#include <private/qgl_p.h>
-#include <private/qpaintengine_opengl_p.h>
-#include <private/qwidget_p.h> // to access QWExtra
-#include <private/qnativeimagehandleprovider_p.h>
-#include "qgl_egl_p.h"
-#include "qpixmapdata_gl_p.h"
-#include "qgltexturepool_p.h"
-#include "qcolormap.h"
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-// Turn off "direct to window" rendering if EGL cannot support it.
-#if !defined(EGL_RENDER_BUFFER) || !defined(EGL_SINGLE_BUFFER)
-#if defined(QGL_DIRECT_TO_WINDOW)
-#undef QGL_DIRECT_TO_WINDOW
-#endif
-#endif
-
-// Determine if preserved window contents should be used.
-#if !defined(EGL_SWAP_BEHAVIOR) || !defined(EGL_BUFFER_PRESERVED)
-#if !defined(QGL_NO_PRESERVED_SWAP)
-#define QGL_NO_PRESERVED_SWAP 1
-#endif
-#endif
-
-extern int qt_gl_pixmap_serial;
-
-/*
- QGLTemporaryContext implementation
-*/
-
-
-class QGLTemporaryContextPrivate
-{
-public:
- bool initialized;
- RWindow *window;
- EGLContext context;
- EGLSurface surface;
- EGLDisplay display;
-};
-
-QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
- : d(new QGLTemporaryContextPrivate)
-{
- d->initialized = false;
- d->window = 0;
- d->context = 0;
- d->surface = 0;
-
- d->display = d->display = QEgl::display();
-
- EGLConfig config;
- int numConfigs = 0;
- EGLint attribs[] = {
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
-#ifdef QT_OPENGL_ES_2
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
-#endif
- EGL_NONE
- };
-
- eglChooseConfig(d->display, attribs, &config, 1, &numConfigs);
- if (!numConfigs) {
- qWarning("QGLTemporaryContext: No EGL configurations available.");
- return;
- }
-
- d->window = new RWindow(CCoeEnv::Static()->WsSession());
- d->window->Construct(CCoeEnv::Static()->RootWin(),(uint)this);
-
- d->surface = eglCreateWindowSurface(d->display, config, (EGLNativeWindowType) d->window, NULL);
-
- if (d->surface == EGL_NO_SURFACE) {
- qWarning("QGLTemporaryContext: Error creating EGL surface.");
- delete d->window;
- d->window = 0;
- return;
- }
-
- EGLint contextAttribs[] = {
-#ifdef QT_OPENGL_ES_2
- EGL_CONTEXT_CLIENT_VERSION, 2,
-#endif
- EGL_NONE
- };
- d->context = eglCreateContext(d->display, config, 0, contextAttribs);
- if (d->context != EGL_NO_CONTEXT
- && eglMakeCurrent(d->display, d->surface, d->surface, d->context))
- {
- d->initialized = true;
- } else {
- qWarning("QGLTemporaryContext: Error creating EGL context.");
- d->window = 0;
- return;
- }
-}
-
-QGLTemporaryContext::~QGLTemporaryContext()
-{
- if (d->initialized) {
- eglMakeCurrent(d->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- eglDestroyContext(d->display, d->context);
- eglDestroySurface(d->display, d->surface);
- delete d->window;
- }
-}
-
-bool QGLFormat::hasOpenGLOverlays()
-{
- return false;
-}
-
-// Chooses the EGL config and creates the EGL context
-bool QGLContext::chooseContext(const QGLContext* shareContext) // almost same as in qgl_x11egl.cpp
-{
- Q_D(QGLContext);
-
- if (!device())
- return false;
-
- int devType = device()->devType();
-
- if ((devType != QInternal::Widget) && (devType != QInternal::Pbuffer)) {
- qWarning("WARNING: Creating a QGLContext not supported on device type %d", devType);
- return false;
- }
-
- // Get the display and initialize it.
- if (d->eglContext == 0) {
- d->eglContext = new QEglContext();
- d->ownsEglContext = true;
- d->eglContext->setApi(QEgl::OpenGL);
-
- // If the device is a widget with WA_TranslucentBackground set, make sure the glFormat
- // has the alpha channel option set:
- if (devType == QInternal::Widget) {
- QWidget* widget = static_cast<QWidget*>(device());
- if (widget->testAttribute(Qt::WA_TranslucentBackground))
- d->glFormat.setAlpha(true);
- }
-
- // Construct the configuration we need for this surface.
- QEglProperties configProps;
- configProps.setDeviceType(devType);
- configProps.setPaintDeviceFormat(device());
- configProps.setRenderableType(QEgl::OpenGL);
- configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_SWAP_BEHAVIOR_PRESERVED_BIT);
-
- qt_eglproperties_set_glformat(configProps, d->glFormat);
-
- if (!d->eglContext->chooseConfig(configProps, QEgl::BestPixelFormat)) {
- delete d->eglContext;
- d->eglContext = 0;
- return false;
- }
-
- // Create a new context for the configuration.
- QEglContext* eglSharedContext = shareContext ? shareContext->d_func()->eglContext : 0;
- if (!d->eglContext->createContext(eglSharedContext)) {
- delete d->eglContext;
- d->eglContext = 0;
- return false;
- }
- d->sharing = d->eglContext->isSharing();
- if (d->sharing && shareContext)
- const_cast<QGLContext *>(shareContext)->d_func()->sharing = true;
- }
-
- // Inform the higher layers about the actual format properties
- qt_glformat_from_eglconfig(d->glFormat, d->eglContext->config());
-
- // Do don't create the EGLSurface for everything.
- // QWidget - yes, create the EGLSurface and store it in QGLContextPrivate::eglSurface
- // QGLWidget - yes, create the EGLSurface and store it in QGLContextPrivate::eglSurface
- // QGLPixelBuffer - no, it creates the surface itself and stores it in QGLPixelBufferPrivate::pbuf
-
- if (devType == QInternal::Widget) {
- if (d->eglSurface != EGL_NO_SURFACE)
- eglDestroySurface(d->eglContext->display(), d->eglSurface);
-
- d->eglSurface = QEgl::createSurface(device(), d->eglContext->config());
-
- eglGetError(); // Clear error state first.
-
-#ifdef QGL_NO_PRESERVED_SWAP
- eglSurfaceAttrib(QEgl::display(), d->eglSurface,
- EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED);
-
- if (eglGetError() != EGL_SUCCESS)
- qWarning("QGLContext: could not enable destroyed swap behaviour");
-#else
- eglSurfaceAttrib(QEgl::display(), d->eglSurface,
- EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
-
- if (eglGetError() != EGL_SUCCESS)
- qWarning("QGLContext: could not enable preserved swap behaviour");
-#endif
-
- setWindowCreated(true);
- }
-
- return true;
-}
-
-void QGLWidget::resizeEvent(QResizeEvent *)
-{
- Q_D(QGLWidget);
- if (!isValid())
- return;
-
- if (QGLContext::currentContext())
- doneCurrent();
-
- // Symbian needs to recreate the surface on resize.
- d->recreateEglSurface();
-
- makeCurrent();
- if (!d->glcx->initialized())
- glInit();
- resizeGL(width(), height());
- //handle overlay
-}
-
-const QGLContext* QGLWidget::overlayContext() const
-{
- return 0;
-}
-
-void QGLWidget::makeOverlayCurrent()
-{
- //handle overlay
-}
-
-void QGLWidget::updateOverlayGL()
-{
- //handle overlay
-}
-
-void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, bool deleteOldContext)
-{
- Q_D(QGLWidget);
- if (context == 0) {
- qWarning("QGLWidget::setContext: Cannot set null context");
- return;
- }
- if (!context->deviceIsPixmap() && context->device() != this) {
- qWarning("QGLWidget::setContext: Context must refer to this widget");
- return;
- }
-
- if (d->glcx)
- d->glcx->doneCurrent();
- QGLContext* oldcx = d->glcx;
- d->glcx = context;
-
- bool createFailed = false;
- if (!d->glcx->isValid()) {
- // Create the QGLContext here, which in turn chooses the EGL config
- // and creates the EGL context:
- if (!d->glcx->create(shareContext ? shareContext : oldcx))
- createFailed = true;
- }
- if (createFailed) {
- if (deleteOldContext)
- delete oldcx;
- return;
- }
-
- d->eglSurfaceWindowId = winId(); // Remember the window id we created the surface for
-}
-
-void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget* shareWidget)
-{
- Q_Q(QGLWidget);
-
- initContext(context, shareWidget);
-
- if(q->isValid() && glcx->format().hasOverlay()) {
- //no overlay
- qWarning("QtOpenGL ES doesn't currently support overlays");
- }
-}
-
-void QGLWidgetPrivate::cleanupColormaps()
-{
-}
-
-const QGLColormap & QGLWidget::colormap() const
-{
- return d_func()->cmap;
-}
-
-void QGLWidget::setColormap(const QGLColormap &)
-{
-}
-
-void QGLWidgetPrivate::recreateEglSurface()
-{
- Q_Q(QGLWidget);
-
- WId currentId = q->winId();
-
- if (glcx->d_func()->eglSurface != EGL_NO_SURFACE) {
- eglDestroySurface(glcx->d_func()->eglContext->display(),
- glcx->d_func()->eglSurface);
- }
-
- glcx->d_func()->eglSurface = QEgl::createSurface(glcx->device(),
- glcx->d_func()->eglContext->config());
-
-#if !defined(QGL_NO_PRESERVED_SWAP)
- eglGetError(); // Clear error state first.
- eglSurfaceAttrib(QEgl::display(), glcx->d_func()->eglSurface,
- EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
- if (eglGetError() != EGL_SUCCESS) {
- qWarning("QGLContext: could not enable preserved swap");
- }
-#endif
-
- eglSurfaceWindowId = currentId;
-}
-
-static inline bool knownGoodFormat(QImage::Format format)
-{
- switch (format) {
- case QImage::Format_RGB16: // EColor64K
- case QImage::Format_RGB32: // EColor16MU
- case QImage::Format_ARGB32_Premultiplied: // EColor16MAP
- return true;
- default:
- return false;
- }
-}
-
-void QGLPixmapData::fromNativeType(void* pixmap, NativeType type)
-{
- if (type == QPixmapData::FbsBitmap) {
- CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap *>(pixmap);
- QSize size(bitmap->SizeInPixels().iWidth, bitmap->SizeInPixels().iHeight);
- if (size.width() == w && size.height() == h)
- setSerialNumber(++qt_gl_pixmap_serial);
- resize(size.width(), size.height());
- m_source = QVolatileImage(bitmap);
- if (pixelType() == BitmapType) {
- m_source.ensureFormat(QImage::Format_MonoLSB);
- } else if (!knownGoodFormat(m_source.format())) {
- m_source.beginDataAccess();
- QImage::Format format = idealFormat(m_source.imageRef(), Qt::AutoColor);
- m_source.endDataAccess(true);
- m_source.ensureFormat(format);
- }
- m_hasAlpha = m_source.hasAlphaChannel();
- m_hasFillColor = false;
- m_dirty = true;
-
- } else if (type == QPixmapData::VolatileImage && pixmap) {
- // Support QS60Style in more efficient skin graphics retrieval.
- QVolatileImage *img = static_cast<QVolatileImage *>(pixmap);
- if (img->width() == w && img->height() == h)
- setSerialNumber(++qt_gl_pixmap_serial);
- resize(img->width(), img->height());
- m_source = *img;
- m_hasAlpha = m_source.hasAlphaChannel();
- m_hasFillColor = false;
- m_dirty = true;
- } else if (type == QPixmapData::NativeImageHandleProvider && pixmap) {
- destroyTexture();
- nativeImageHandleProvider = static_cast<QNativeImageHandleProvider *>(pixmap);
- // Cannot defer the retrieval, we need at least the size right away.
- createFromNativeImageHandleProvider();
- }
-}
-
-void* QGLPixmapData::toNativeType(NativeType type)
-{
- if (type == QPixmapData::FbsBitmap) {
- if (m_source.isNull())
- m_source = QVolatileImage(w, h, QImage::Format_ARGB32_Premultiplied);
- return m_source.duplicateNativeImage();
- }
-
- return 0;
-}
-
-bool QGLPixmapData::initFromNativeImageHandle(void *handle, const QString &type)
-{
- if (type == QLatin1String("RSgImage")) {
- fromNativeType(handle, QPixmapData::SgImage);
- return true;
- } else if (type == QLatin1String("CFbsBitmap")) {
- fromNativeType(handle, QPixmapData::FbsBitmap);
- return true;
- }
- return false;
-}
-
-void QGLPixmapData::createFromNativeImageHandleProvider()
-{
- void *handle = 0;
- QString type;
- nativeImageHandleProvider->get(&handle, &type);
- if (handle) {
- if (initFromNativeImageHandle(handle, type)) {
- nativeImageHandle = handle;
- nativeImageType = type;
- } else {
- qWarning("QGLPixmapData: Unknown native image type '%s'", qPrintable(type));
- }
- } else {
- qWarning("QGLPixmapData: Native handle is null");
- }
-}
-
-void QGLPixmapData::releaseNativeImageHandle()
-{
- if (nativeImageHandleProvider && nativeImageHandle) {
- nativeImageHandleProvider->release(nativeImageHandle, nativeImageType);
- nativeImageHandle = 0;
- nativeImageType = QString();
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp
index 22a222eb1b..c35488da02 100644
--- a/src/opengl/qgl_x11.cpp
+++ b/src/opengl/qgl_x11.cpp
@@ -1769,17 +1769,17 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
Q_Q(QGLContext);
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pixmap->data_ptr().data());
- Q_ASSERT(pixmapData->classId() == QPixmapData::X11Class);
+ QX11PlatformPixmap *handle = static_cast<QX11PlatformPixmap*>(pixmap->data_ptr().data());
+ Q_ASSERT(handle->classId() == QPlatformPixmap::X11Class);
// We can't use TFP if the pixmap has a separate X11 mask
- if (pixmapData->x11_mask)
+ if (handle->x11_mask)
return 0;
if (!qt_resolveTextureFromPixmap(paintDevice))
return 0;
- const QX11Info &x11Info = pixmapData->xinfo;
+ const QX11Info &x11Info = handle->xinfo;
// Store the configs (Can be static because configs aren't dependent on current context)
static GLXFBConfig glxRGBPixmapConfig = 0;
@@ -1787,7 +1787,7 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
static GLXFBConfig glxRGBAPixmapConfig = 0;
static bool RGBAConfigInverted = false;
- bool hasAlpha = pixmapData->hasAlphaChannel();
+ bool hasAlpha = handle->hasAlphaChannel();
// Check to see if we need a config
if ( (hasAlpha && !glxRGBAPixmapConfig) || (!hasAlpha && !glxRGBPixmapConfig) ) {
@@ -1822,15 +1822,15 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
}
// Check to see if the surface is still valid
- if (pixmapData->gl_surface &&
- hasAlpha != (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha))
+ if (handle->gl_surface &&
+ hasAlpha != (handle->flags & QX11PlatformPixmap::GlSurfaceCreatedWithAlpha))
{
// Surface is invalid!
- destroyGlSurfaceForPixmap(pixmapData);
+ destroyGlSurfaceForPixmap(handle);
}
// Check to see if we need a surface
- if (!pixmapData->gl_surface) {
+ if (!handle->gl_surface) {
GLXPixmap glxPixmap;
int pixmapAttribs[] = {
GLX_TEXTURE_FORMAT_EXT, hasAlpha ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT,
@@ -1842,21 +1842,21 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
// Wrap the X Pixmap into a GLXPixmap:
glxPixmap = glXCreatePixmap(x11Info.display(),
hasAlpha ? glxRGBAPixmapConfig : glxRGBPixmapConfig,
- pixmapData->handle(), pixmapAttribs);
+ handle->handle(), pixmapAttribs);
if (!glxPixmap)
return 0;
- pixmapData->gl_surface = (void*)glxPixmap;
+ handle->gl_surface = (void*)glxPixmap;
// Make sure the cleanup hook gets called so we can delete the glx pixmap
- QImagePixmapCleanupHooks::enableCleanupHooks(pixmapData);
+ QImagePixmapCleanupHooks::enableCleanupHooks(handle);
}
GLuint textureId;
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
- glXBindTexImageEXT(x11Info.display(), (GLXPixmap)pixmapData->gl_surface, GLX_FRONT_LEFT_EXT, 0);
+ glXBindTexImageEXT(x11Info.display(), (GLXPixmap)handle->gl_surface, GLX_FRONT_LEFT_EXT, 0);
glBindTexture(GL_TEXTURE_2D, textureId);
GLuint filtering = (options & QGLContext::LinearFilteringBindOption) ? GL_LINEAR : GL_NEAREST;
@@ -1868,7 +1868,7 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
QGLTexture *texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, options);
if (texture->options & QGLContext::InvertedYBindOption)
- pixmapData->flags |= QX11PixmapData::InvertedWhenBoundToTexture;
+ handle->flags |= QX11PlatformPixmap::InvertedWhenBoundToTexture;
// We assume the cost of bound pixmaps is zero
QGLTextureCache::instance()->insert(q, key, texture, 0);
@@ -1878,26 +1878,26 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
}
-void QGLContextPrivate::destroyGlSurfaceForPixmap(QPixmapData* pmd)
+void QGLContextPrivate::destroyGlSurfaceForPixmap(QPlatformPixmap* pmd)
{
#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX)
- Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
- if (pixmapData->gl_surface) {
- glXDestroyPixmap(QX11Info::display(), (GLXPixmap)pixmapData->gl_surface);
- pixmapData->gl_surface = 0;
+ Q_ASSERT(pmd->classId() == QPlatformPixmap::X11Class);
+ QX11PlatformPixmap *handle = static_cast<QX11PlatformPixmap*>(pmd);
+ if (handle->gl_surface) {
+ glXDestroyPixmap(QX11Info::display(), (GLXPixmap)handle->gl_surface);
+ handle->gl_surface = 0;
}
#endif
}
-void QGLContextPrivate::unbindPixmapFromTexture(QPixmapData* pmd)
+void QGLContextPrivate::unbindPixmapFromTexture(QPlatformPixmap* pmd)
{
#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX)
- Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
+ Q_ASSERT(pmd->classId() == QPlatformPixmap::X11Class);
Q_ASSERT(QGLContext::currentContext());
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
- if (pixmapData->gl_surface)
- glXReleaseTexImageEXT(QX11Info::display(), (GLXPixmap)pixmapData->gl_surface, GLX_FRONT_LEFT_EXT);
+ QX11PlatformPixmap *handle = static_cast<QX11PlatformPixmap*>(pmd);
+ if (handle->gl_surface)
+ glXReleaseTexImageEXT(QX11Info::display(), (GLXPixmap)handle->gl_surface, GLX_FRONT_LEFT_EXT);
#endif
}
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index a491bef4c6..e8520414d6 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -171,13 +171,13 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
int devType = device()->devType();
- QX11PixmapData *x11PixmapData = 0;
+ QX11PlatformPixmap *x11PlatformPixmap = 0;
if (devType == QInternal::Pixmap) {
- QPixmapData *pmd = static_cast<QPixmap*>(device())->data_ptr().data();
- if (pmd->classId() == QPixmapData::X11Class)
- x11PixmapData = static_cast<QX11PixmapData*>(pmd);
+ QPlatformPixmap *pmd = static_cast<QPixmap*>(device())->data_ptr().data();
+ if (pmd->classId() == QPlatformPixmap::X11Class)
+ x11PlatformPixmap = static_cast<QX11PlatformPixmap*>(pmd);
else {
- // TODO: Replace the pixmap's data with a new QX11PixmapData
+ // TODO: Replace the pixmap's data with a new QX11PlatformPixmap
qWarning("WARNING: Creating a QGLContext on a QPixmap is only supported for X11 pixmap backend");
return false;
}
@@ -234,7 +234,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// Do don't create the EGLSurface for everything.
// QWidget - yes, create the EGLSurface and store it in QGLContextPrivate::eglSurface
// QGLWidget - yes, create the EGLSurface and store it in QGLContextPrivate::eglSurface
- // QPixmap - yes, create the EGLSurface but store it in QX11PixmapData::gl_surface
+ // QPixmap - yes, create the EGLSurface but store it in QX11PlatformPixmap::gl_surface
// QGLPixelBuffer - no, it creates the surface itself and stores it in QGLPixelBufferPrivate::pbuf
if (devType == QInternal::Widget) {
@@ -246,12 +246,12 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
setWindowCreated(true);
}
- if (x11PixmapData) {
+ if (x11PlatformPixmap) {
// TODO: Actually check to see if the existing surface can be re-used
- if (x11PixmapData->gl_surface)
- eglDestroySurface(d->eglContext->display(), (EGLSurface)x11PixmapData->gl_surface);
+ if (x11PlatformPixmap->gl_surface)
+ eglDestroySurface(d->eglContext->display(), (EGLSurface)x11PlatformPixmap->gl_surface);
- x11PixmapData->gl_surface = (void*)QEgl::createSurface(device(), d->eglContext->config());
+ x11PlatformPixmap->gl_surface = (void*)QEgl::createSurface(device(), d->eglContext->config());
}
return true;
@@ -415,17 +415,17 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
return 0;
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pixmap->data_ptr().data());
- Q_ASSERT(pixmapData->classId() == QPixmapData::X11Class);
- bool hasAlpha = pixmapData->hasAlphaChannel();
+ QX11PlatformPixmap *handle = static_cast<QX11PlatformPixmap*>(pixmap->data_ptr().data());
+ Q_ASSERT(handle->classId() == QPlatformPixmap::X11Class);
+ bool hasAlpha = handle->hasAlphaChannel();
bool pixmapHasValidSurface = false;
bool textureIsBound = false;
GLuint textureId;
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
- if (haveTFP && pixmapData->gl_surface &&
- hasAlpha == (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha))
+ if (haveTFP && handle->gl_surface &&
+ hasAlpha == (handle->flags & QX11PlatformPixmap::GlSurfaceCreatedWithAlpha))
{
pixmapHasValidSurface = true;
}
@@ -433,11 +433,11 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
// If we already have a valid EGL surface for the pixmap, we should use it
if (pixmapHasValidSurface) {
EGLBoolean success;
- success = eglBindTexImage(QEgl::display(), (EGLSurface)pixmapData->gl_surface, EGL_BACK_BUFFER);
+ success = eglBindTexImage(QEgl::display(), (EGLSurface)handle->gl_surface, EGL_BACK_BUFFER);
if (success == EGL_FALSE) {
qWarning() << "eglBindTexImage() failed:" << QEgl::errorString();
- eglDestroySurface(QEgl::display(), (EGLSurface)pixmapData->gl_surface);
- pixmapData->gl_surface = (void*)EGL_NO_SURFACE;
+ eglDestroySurface(QEgl::display(), (EGLSurface)handle->gl_surface);
+ handle->gl_surface = (void*)EGL_NO_SURFACE;
} else
textureIsBound = true;
}
@@ -469,29 +469,29 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
if (!textureIsBound && haveTFP) {
// Check to see if the surface is still valid
- if (pixmapData->gl_surface &&
- hasAlpha != (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha))
+ if (handle->gl_surface &&
+ hasAlpha != (handle->flags & QX11PlatformPixmap::GlSurfaceCreatedWithAlpha))
{
// Surface is invalid!
- destroyGlSurfaceForPixmap(pixmapData);
+ destroyGlSurfaceForPixmap(handle);
}
- if (pixmapData->gl_surface == 0) {
+ if (handle->gl_surface == 0) {
EGLConfig config = QEgl::defaultConfig(QInternal::Pixmap,
QEgl::OpenGL,
hasAlpha ? QEgl::Translucent : QEgl::NoOptions);
- pixmapData->gl_surface = (void*)QEgl::createSurface(pixmap, config);
- if (pixmapData->gl_surface == (void*)EGL_NO_SURFACE)
+ handle->gl_surface = (void*)QEgl::createSurface(pixmap, config);
+ if (handle->gl_surface == (void*)EGL_NO_SURFACE)
return false;
}
EGLBoolean success;
- success = eglBindTexImage(QEgl::display(), (EGLSurface)pixmapData->gl_surface, EGL_BACK_BUFFER);
+ success = eglBindTexImage(QEgl::display(), (EGLSurface)handle->gl_surface, EGL_BACK_BUFFER);
if (success == EGL_FALSE) {
qWarning() << "eglBindTexImage() failed:" << QEgl::errorString();
- eglDestroySurface(QEgl::display(), (EGLSurface)pixmapData->gl_surface);
- pixmapData->gl_surface = (void*)EGL_NO_SURFACE;
+ eglDestroySurface(QEgl::display(), (EGLSurface)handle->gl_surface);
+ handle->gl_surface = (void*)EGL_NO_SURFACE;
haveTFP = false; // If TFP isn't working, disable it's use
} else
textureIsBound = true;
@@ -501,7 +501,7 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
if (textureIsBound) {
texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, options);
- pixmapData->flags |= QX11PixmapData::InvertedWhenBoundToTexture;
+ handle->flags |= QX11PlatformPixmap::InvertedWhenBoundToTexture;
// We assume the cost of bound pixmaps is zero
QGLTextureCache::instance()->insert(q, key, texture, 0);
@@ -514,29 +514,29 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
}
-void QGLContextPrivate::destroyGlSurfaceForPixmap(QPixmapData* pmd)
+void QGLContextPrivate::destroyGlSurfaceForPixmap(QPlatformPixmap* pmd)
{
- Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
- if (pixmapData->gl_surface) {
+ Q_ASSERT(pmd->classId() == QPlatformPixmap::X11Class);
+ QX11PlatformPixmap *handle = static_cast<QX11PlatformPixmap*>(pmd);
+ if (handle->gl_surface) {
EGLBoolean success;
- success = eglDestroySurface(QEgl::display(), (EGLSurface)pixmapData->gl_surface);
+ success = eglDestroySurface(QEgl::display(), (EGLSurface)handle->gl_surface);
if (success == EGL_FALSE) {
qWarning() << "destroyGlSurfaceForPixmap() - Error deleting surface: "
<< QEgl::errorString();
}
- pixmapData->gl_surface = 0;
+ handle->gl_surface = 0;
}
}
-void QGLContextPrivate::unbindPixmapFromTexture(QPixmapData* pmd)
+void QGLContextPrivate::unbindPixmapFromTexture(QPlatformPixmap* pmd)
{
- Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
- if (pixmapData->gl_surface) {
+ Q_ASSERT(pmd->classId() == QPlatformPixmap::X11Class);
+ QX11PlatformPixmap *handle = static_cast<QX11PlatformPixmap*>(pmd);
+ if (handle->gl_surface) {
EGLBoolean success;
success = eglReleaseTexImage(QEgl::display(),
- (EGLSurface)pixmapData->gl_surface,
+ (EGLSurface)handle->gl_surface,
EGL_BACK_BUFFER);
if (success == EGL_FALSE) {
qWarning() << "unbindPixmapFromTexture() - Unable to release bound texture: "
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
index b4e12d8b7e..08807bdd49 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -43,14 +43,6 @@
#include <private/qgl_p.h>
#include <private/qglpixelbuffer_p.h>
#include <private/qglframebufferobject_p.h>
-#ifdef Q_WS_X11
-#include <private/qpixmapdata_x11gl_p.h>
-#endif
-
-#if !defined(QT_OPENGL_ES_1)
-#include <private/qpixmapdata_gl_p.h>
-#include <private/qwindowsurface_gl_p.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -220,19 +212,7 @@ QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd)
glpd = &(static_cast<QGLFramebufferObject*>(pd)->d_func()->glDevice);
break;
case QInternal::Pixmap: {
-#if !defined(QT_OPENGL_ES_1)
- QPixmapData* pmd = static_cast<QPixmap*>(pd)->pixmapData();
- if (pmd->classId() == QPixmapData::OpenGLClass)
- glpd = static_cast<QGLPixmapData*>(pmd)->glDevice();
-#ifdef Q_WS_X11
- else if (pmd->classId() == QPixmapData::X11Class)
- glpd = static_cast<QX11GLPixmapData*>(pmd);
-#endif
- else
- qWarning("Pixmap type not supported for GL rendering");
-#else
- qWarning("Pixmap render targets not supported on OpenGL ES 1.x");
-#endif
+ qWarning("Pixmap type not supported for GL rendering");
break;
}
default:
diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h
index c5390645e2..32ae85dc90 100644
--- a/src/opengl/qglpaintdevice_p.h
+++ b/src/opengl/qglpaintdevice_p.h
@@ -55,7 +55,7 @@
#include <qpaintdevice.h>
-#include <qgl.h>
+#include <QtOpenGL/qgl.h>
QT_BEGIN_NAMESPACE
diff --git a/src/opengl/qglpixelbuffer.h b/src/opengl/qglpixelbuffer.h
index dcd1a6ca71..1cffb0ec0b 100644
--- a/src/opengl/qglpixelbuffer.h
+++ b/src/opengl/qglpixelbuffer.h
@@ -109,7 +109,6 @@ private:
Q_DISABLE_COPY(QGLPixelBuffer)
QScopedPointer<QGLPixelBufferPrivate> d_ptr;
friend class QGLDrawable;
- friend class QGLWindowSurface;
friend class QGLPaintDevice;
friend class QGLPBufferGLPaintDevice;
friend class QGLContextPrivate;
diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h
index eb761047e7..05d8823909 100644
--- a/src/opengl/qglpixelbuffer_p.h
+++ b/src/opengl/qglpixelbuffer_p.h
@@ -125,7 +125,7 @@ struct GLXFBConfig {
#endif // Q_OS_HPUX
-#elif defined(Q_WS_WIN)
+#elif defined(Q_OS_WIN)
DECLARE_HANDLE(HPBUFFERARB);
#elif !defined(QT_NO_EGL)
#include <QtGui/private/qegl_p.h>
diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp
index 7546d84064..6c807248ee 100644
--- a/src/opengl/qglpixmapfilter.cpp
+++ b/src/opengl/qglpixmapfilter.cpp
@@ -40,13 +40,11 @@
****************************************************************************/
#include "private/qpixmapfilter_p.h"
-#include "private/qpixmapdata_gl_p.h"
#include "private/qpaintengineex_opengl2_p.h"
#include "private/qglengineshadermanager_p.h"
-#include "private/qpixmapdata_p.h"
+#include "qplatformpixmap_qpa.h"
#include "private/qimagepixmapcleanuphooks_p.h"
#include "qglpixmapfilter_p.h"
-#include "qgraphicssystem_gl_p.h"
#include "qpaintengine_opengl_p.h"
#include "qcache.h"
@@ -326,7 +324,7 @@ public:
void timerEvent(QTimerEvent *event);
private:
- static void pixmapDestroyed(QPixmapData *pixmap);
+ static void pixmapDestroyed(QPlatformPixmap *pixmap);
QCache<quint64, QGLBlurTextureInfo > cache;
@@ -382,8 +380,8 @@ void QGLBlurTextureCache::insertBlurTextureInfo(const QPixmap &pixmap, QGLBlurTe
{
static bool hookAdded = false;
if (!hookAdded) {
- QImagePixmapCleanupHooks::instance()->addPixmapDataDestructionHook(pixmapDestroyed);
- QImagePixmapCleanupHooks::instance()->addPixmapDataModificationHook(pixmapDestroyed);
+ QImagePixmapCleanupHooks::instance()->addPlatformPixmapDestructionHook(pixmapDestroyed);
+ QImagePixmapCleanupHooks::instance()->addPlatformPixmapModificationHook(pixmapDestroyed);
hookAdded = true;
}
@@ -396,7 +394,7 @@ void QGLBlurTextureCache::insertBlurTextureInfo(const QPixmap &pixmap, QGLBlurTe
timerId = startTimer(8000);
}
-void QGLBlurTextureCache::pixmapDestroyed(QPixmapData *pmd)
+void QGLBlurTextureCache::pixmapDestroyed(QPlatformPixmap *pmd)
{
foreach (QGLBlurTextureCache *cache, blurTextureCaches) {
if (cache->hasBlurTextureInfo(pmd->cacheKey()))
diff --git a/src/opengl/qglscreen_qws.cpp b/src/opengl/qglscreen_qws.cpp
deleted file mode 100644
index 517813e628..0000000000
--- a/src/opengl/qglscreen_qws.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGLScreen>
-#include <QGLContext>
-#include <QGLWidget>
-#include "private/qglwindowsurface_qws_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGLScreenPrivate
-{
-public:
- QGLScreen::Options options;
- QGLScreenSurfaceFunctions *functions;
-};
-
-/*!
- \internal
- \preliminary
- \class QGLScreen
-
- \brief This class encapsulates an OpenGL screen driver.
-*/
-
-QGLScreen::QGLScreen(int displayId)
- : QScreen(displayId, GLClass), d_ptr(new QGLScreenPrivate)
-{
- d_ptr->options = NoOptions;
- d_ptr->functions = new QGLScreenSurfaceFunctions();
-}
-
-QGLScreen::~QGLScreen()
-{
- delete d_ptr->functions;
- delete d_ptr;
-}
-
-/*!
- \since 4.3
- \obsolete
-
- Initializes the \a context and sets up the QGLWindowSurface of the
- QWidget of \a context based on the parameters of \a context and
- based on its own requirements. The format() of \a context needs
- to be updated with the actual parameters of the OpenGLES drawable
- that was set up.
-
- \a shareContext is used in the same way as for QGLContext. It is
- the context with which \a context shares display lists and texture
- ids etc. The window surface must be set up so that this sharing
- works.
-
- Returns true in case of success and false if it is not possible to
- create the necessary OpenGLES drawable/context.
-
- Since 4.4.2, this function will be not be called if options()
- indicates that a native window or pixmap drawable can be created
- via the functions in the surfaceFunctions() object.
-
- This function is obsolete in Qt 4.5 and higher. Use surfaceFunctions()
- instead.
-
- \sa options(), surfaceFunctions()
-*/
-bool
-QGLScreen::chooseContext(QGLContext *context, const QGLContext *shareContext)
-{
- Q_UNUSED(context);
- Q_UNUSED(shareContext);
- return false;
-}
-
-/*!
- \enum QGLScreen::Option
- This enum defines options that can be set on QGLScreen instances.
-
- \value NoOptions There are no special options on the screen. This is the default.
- \value NativeWindows Native windows can be created with QGLScreenSurfaceFunctions::createNativeWindow().
- \value NativePixmaps Native pixmaps can be created with QGLScreenSurfaceFunctions::createNativePixmap().
- \value NativeImages Native images can be created with QGLScreenSurfaceFunctions::createNativeImage().
- \value Overlays The screen supports GL overlays.
-*/
-
-/*!
- \since 4.4.2
-
- Returns the options associated with this QGLScreen.
-
- \sa setOptions()
-*/
-QGLScreen::Options QGLScreen::options() const
-{
- return d_ptr->options;
-}
-
-/*!
- \since 4.4.2
-
- Sets the options associated with this QGLScreen to \a value.
-
- \sa options()
-*/
-void QGLScreen::setOptions(QGLScreen::Options value)
-{
- d_ptr->options = value;
-}
-
-/*!
- \since 4.4.2
-
- Returns the surface functions object for this QGLScreen.
-
- \sa setSurfaceFunctions()
-*/
-QGLScreenSurfaceFunctions *QGLScreen::surfaceFunctions() const
-{
- return d_ptr->functions;
-}
-
-/*!
- \since 4.4.2
-
- Sets the surface functions object for this QGLScreen to \a functions.
- The QGLScreen will take over ownership of \a functions and delete
- it when the QGLScreen is deleted.
-
- \sa setSurfaceFunctions()
-*/
-void QGLScreen::setSurfaceFunctions(QGLScreenSurfaceFunctions *functions)
-{
- if (functions && functions != d_ptr->functions) {
- delete d_ptr->functions;
- d_ptr->functions = functions;
- }
-}
-
-/*!
- \internal
- \preliminary
- \class QGLScreenSurfaceFunctions
- \brief The QGLScreenSurfaceFunctions class encapsulates the functions for creating native windows and pixmaps for OpenGL ES.
-*/
-
-/*!
- \since 4.4.2
-
- Creates a native OpenGLES drawable for the surface of \a widget and
- returns it in \a native. Returns true if the OpenGLES drawable could
- be created, or false if windows are not supported.
-
- This function will be called if the NativeWindows option is set on
- the screen.
-
- \sa createNativePixmap(), createNativeImage(), QGLScreen::options()
-*/
-bool QGLScreenSurfaceFunctions::createNativeWindow(QWidget *widget, EGLNativeWindowType *native)
-{
- Q_UNUSED(widget);
- Q_UNUSED(native);
- return false;
-}
-
-/*!
- \since 4.4.2
-
- Creates a native OpenGLES drawable for directly rendering into
- \a pixmap and returns it in \a native. Returns true if the OpenGLES
- drawable could be created, or false if direct rendering into pixmaps
- is not supported.
-
- This function will be called if the NativePixmaps option is set on
- the screen.
-
- \sa createNativeWindow(), createNativeImage(), QGLScreen::options()
-*/
-bool QGLScreenSurfaceFunctions::createNativePixmap(QPixmap *pixmap, EGLNativePixmapType *native)
-{
- Q_UNUSED(pixmap);
- Q_UNUSED(native);
- return false;
-}
-
-/*!
- \since 4.4.2
-
- Creates a native OpenGLES drawable for directly rendering into
- \a image and returns it in \a native. Returns true if the OpenGLES
- drawable could be created, or false if direct rendering into images
- is not supported.
-
- This function will be called if the NativeImages option is set on
- the screen.
-
- \sa createNativeWindow(), createNativePixmap(), QGLScreen::options()
-*/
-bool QGLScreenSurfaceFunctions::createNativeImage(QImage *image, EGLNativePixmapType *native)
-{
- Q_UNUSED(image);
- Q_UNUSED(native);
- return false;
-}
-
-QT_END_NAMESPACE
diff --git a/src/opengl/qglscreen_qws.h b/src/opengl/qglscreen_qws.h
deleted file mode 100644
index a033b6badb..0000000000
--- a/src/opengl/qglscreen_qws.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCREENEGL_P_H
-#define QSCREENEGL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QScreenEGL class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGui/QScreen>
-#include <QtOpenGL/qgl.h>
-#if defined(QT_OPENGL_ES_2)
-#include <EGL/egl.h>
-#else
-#include <GLES/egl.h>
-#endif
-#if !defined(EGL_VERSION_1_3) && !defined(QEGL_NATIVE_TYPES_DEFINED)
-#undef EGLNativeWindowType
-#undef EGLNativePixmapType
-#undef EGLNativeDisplayType
-typedef NativeWindowType EGLNativeWindowType;
-typedef NativePixmapType EGLNativePixmapType;
-typedef NativeDisplayType EGLNativeDisplayType;
-#define QEGL_NATIVE_TYPES_DEFINED 1
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(OpenGL)
-
-class QGLScreenPrivate;
-
-class Q_OPENGL_EXPORT QGLScreenSurfaceFunctions
-{
-public:
- virtual bool createNativeWindow(QWidget *widget, EGLNativeWindowType *native);
- virtual bool createNativePixmap(QPixmap *pixmap, EGLNativePixmapType *native);
- virtual bool createNativeImage(QImage *image, EGLNativePixmapType *native);
-};
-
-class Q_OPENGL_EXPORT QGLScreen : public QScreen
-{
- Q_DECLARE_PRIVATE(QGLScreen)
-public:
- QGLScreen(int displayId);
- virtual ~QGLScreen();
-
- enum Option
- {
- NoOptions = 0,
- NativeWindows = 1,
- NativePixmaps = 2,
- NativeImages = 4,
- Overlays = 8
- };
- Q_DECLARE_FLAGS(Options, Option)
-
- QGLScreen::Options options() const;
-
- virtual bool chooseContext(QGLContext *context, const QGLContext *shareContext);
- virtual bool hasOpenGL() = 0;
-
- QGLScreenSurfaceFunctions *surfaceFunctions() const;
-
-protected:
- void setOptions(QGLScreen::Options value);
- void setSurfaceFunctions(QGLScreenSurfaceFunctions *functions);
-
-private:
- QGLScreenPrivate *d_ptr;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QGLScreen::Options)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCREENEGL_P_H
diff --git a/src/opengl/qgltexturepool.cpp b/src/opengl/qgltexturepool.cpp
deleted file mode 100644
index d809328725..0000000000
--- a/src/opengl/qgltexturepool.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgltexturepool_p.h"
-#include "qpixmapdata_gl_p.h"
-
-QT_BEGIN_NAMESPACE
-
-Q_OPENGL_EXPORT extern QGLWidget* qt_gl_share_widget();
-
-static QGLTexturePool *qt_gl_texture_pool = 0;
-
-class QGLTexturePoolPrivate
-{
-public:
- QGLTexturePoolPrivate() : lruFirst(0), lruLast(0) {}
-
- QGLPixmapData *lruFirst;
- QGLPixmapData *lruLast;
-};
-
-QGLTexturePool::QGLTexturePool()
- : d_ptr(new QGLTexturePoolPrivate())
-{
-}
-
-QGLTexturePool::~QGLTexturePool()
-{
-}
-
-QGLTexturePool *QGLTexturePool::instance()
-{
- if (!qt_gl_texture_pool)
- qt_gl_texture_pool = new QGLTexturePool();
- return qt_gl_texture_pool;
-}
-
-GLuint QGLTexturePool::createTextureForPixmap(GLenum target,
- GLint level,
- GLint internalformat,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- QGLPixmapData *data)
-{
- GLuint texture;
- glGenTextures(1, &texture);
- glBindTexture(target, texture);
- do {
- glTexImage2D(target, level, internalformat, width, height, 0, format, type, 0);
- GLenum error = glGetError();
- if (error == GL_NO_ERROR) {
- if (data)
- moveToHeadOfLRU(data);
- return texture;
- } else if (error != GL_OUT_OF_MEMORY) {
- qWarning("QGLTexturePool: cannot create temporary texture because of invalid params");
- return 0;
- }
- } while (reclaimSpace(internalformat, width, height, format, type, data));
- qWarning("QGLTexturePool: cannot reclaim sufficient space for a %dx%d pixmap",
- width, height);
- return 0;
-}
-
-bool QGLTexturePool::createPermanentTexture(GLuint texture,
- GLenum target,
- GLint level,
- GLint internalformat,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- const GLvoid *data)
-{
- glBindTexture(target, texture);
- do {
- glTexImage2D(target, level, internalformat, width, height, 0, format, type, data);
-
- GLenum error = glGetError();
- if (error == GL_NO_ERROR) {
- return true;
- } else if (error != GL_OUT_OF_MEMORY) {
- qWarning("QGLTexturePool: cannot create permanent texture because of invalid params");
- return false;
- }
- } while (reclaimSpace(internalformat, width, height, format, type, 0));
- qWarning("QGLTexturePool: cannot reclaim sufficient space for a %dx%d pixmap",
- width, height);
- return 0;
-}
-
-void QGLTexturePool::releaseTexture(QGLPixmapData *data, GLuint texture)
-{
- // Very simple strategy at the moment: just destroy the texture.
- if (data)
- removeFromLRU(data);
-
- QGLWidget *shareWidget = qt_gl_share_widget();
- if (shareWidget) {
- QGLShareContextScope ctx(shareWidget->context());
- glDeleteTextures(1, &texture);
- }
-}
-
-void QGLTexturePool::useTexture(QGLPixmapData *data)
-{
- moveToHeadOfLRU(data);
-}
-
-void QGLTexturePool::detachTexture(QGLPixmapData *data)
-{
- removeFromLRU(data);
-}
-
-bool QGLTexturePool::reclaimSpace(GLint internalformat,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- QGLPixmapData *data)
-{
- Q_UNUSED(internalformat); // For future use in picking the best texture to eject.
- Q_UNUSED(width);
- Q_UNUSED(height);
- Q_UNUSED(format);
- Q_UNUSED(type);
-
- bool succeeded = false;
- bool wasInLRU = false;
- if (data) {
- wasInLRU = data->inLRU;
- moveToHeadOfLRU(data);
- }
-
- QGLPixmapData *lrudata = pixmapLRU();
- if (lrudata && lrudata != data) {
- lrudata->reclaimTexture();
- succeeded = true;
- }
-
- if (data && !wasInLRU)
- removeFromLRU(data);
-
- return succeeded;
-}
-
-void QGLTexturePool::hibernate()
-{
- Q_D(QGLTexturePool);
- QGLPixmapData *pd = d->lruLast;
- while (pd) {
- QGLPixmapData *prevLRU = pd->prevLRU;
- pd->inTexturePool = false;
- pd->inLRU = false;
- pd->nextLRU = 0;
- pd->prevLRU = 0;
- pd->hibernate();
- pd = prevLRU;
- }
- d->lruFirst = 0;
- d->lruLast = 0;
-}
-
-void QGLTexturePool::moveToHeadOfLRU(QGLPixmapData *data)
-{
- Q_D(QGLTexturePool);
- if (data->inLRU) {
- if (!data->prevLRU)
- return; // Already at the head of the list.
- removeFromLRU(data);
- }
- data->inLRU = true;
- data->nextLRU = d->lruFirst;
- data->prevLRU = 0;
- if (d->lruFirst)
- d->lruFirst->prevLRU = data;
- else
- d->lruLast = data;
- d->lruFirst = data;
-}
-
-void QGLTexturePool::removeFromLRU(QGLPixmapData *data)
-{
- Q_D(QGLTexturePool);
- if (!data->inLRU)
- return;
- if (data->nextLRU)
- data->nextLRU->prevLRU = data->prevLRU;
- else
- d->lruLast = data->prevLRU;
- if (data->prevLRU)
- data->prevLRU->nextLRU = data->nextLRU;
- else
- d->lruFirst = data->nextLRU;
- data->inLRU = false;
-}
-
-QGLPixmapData *QGLTexturePool::pixmapLRU()
-{
- Q_D(QGLTexturePool);
- return d->lruLast;
-}
-
-QT_END_NAMESPACE
diff --git a/src/opengl/qgltexturepool_p.h b/src/opengl/qgltexturepool_p.h
deleted file mode 100644
index 27b730cbb9..0000000000
--- a/src/opengl/qgltexturepool_p.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGLTEXTUREPOOL_P_H
-#define QGLTEXTUREPOOL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgl.h"
-#include <QtCore/qscopedpointer.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGLPixmapData;
-class QGLTexturePoolPrivate;
-
-class QGLTexturePool
-{
-public:
- QGLTexturePool();
- virtual ~QGLTexturePool();
-
- static QGLTexturePool *instance();
-
- // Create a new texture with the specified parameters and associate
- // it with "data". The QGLPixmapData will be notified when the
- // texture needs to be reclaimed by the pool.
- //
- // This function will call reclaimSpace() when texture creation fails.
- GLuint createTextureForPixmap(GLenum target,
- GLint level,
- GLint internalformat,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- QGLPixmapData *data);
-
- // Create a permanent texture with the specified parameters.
- // If there is insufficient space for the texture,
- // then this function will call reclaimSpace() and try again.
- //
- // The caller is responsible for calling glDeleteTextures()
- // when it no longer needs the texture, as the texture is not
- // recorded in the texture pool.
- bool createPermanentTexture(GLuint texture,
- GLenum target,
- GLint level,
- GLint internalformat,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- const GLvoid *data);
-
- // Release a texture that is no longer required.
- void releaseTexture(QGLPixmapData *data, GLuint texture);
-
- // Notify the pool that a QGLPixmapData object is using
- // an texture again. This allows the pool to move the texture
- // within a least-recently-used list of QGLPixmapData objects.
- void useTexture(QGLPixmapData *data);
-
- // Notify the pool that the texture associated with a
- // QGLPixmapData is being detached from the pool. The caller
- // will become responsible for calling glDeleteTextures().
- void detachTexture(QGLPixmapData *data);
-
- // Reclaim space for an image allocation with the specified parameters.
- // Returns true if space was reclaimed, or false if there is no
- // further space that can be reclaimed. The "data" parameter
- // indicates the pixmap that is trying to obtain space which should
- // not itself be reclaimed.
- bool reclaimSpace(GLint internalformat,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- QGLPixmapData *data);
-
- // Hibernate the image pool because the context is about to be
- // destroyed. All textures left in the pool should be released.
- void hibernate();
-
-protected:
- // Helper functions for managing the LRU list of QGLPixmapData objects.
- void moveToHeadOfLRU(QGLPixmapData *data);
- void removeFromLRU(QGLPixmapData *data);
- QGLPixmapData *pixmapLRU();
-
-private:
- QScopedPointer<QGLTexturePoolPrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QGLTexturePool)
- Q_DISABLE_COPY(QGLTexturePool)
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/opengl/qglwindowsurface_qws.cpp b/src/opengl/qglwindowsurface_qws.cpp
deleted file mode 100644
index b3ad45185e..0000000000
--- a/src/opengl/qglwindowsurface_qws.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui/QPaintDevice>
-#include <QtGui/QWidget>
-#include <QtOpenGL/QGLWidget>
-#include "private/qglwindowsurface_qws_p.h"
-#include "private/qpaintengine_opengl_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QWSGLWindowSurface
- \since 4.3
- \ingroup qws
- \preliminary
-
- \brief The QWSGLWindowSurface class provides the drawing area for top-level
- windows with Qt for Embedded Linux on EGL/OpenGL ES. It also provides the
- drawing area for \l{QGLWidget}s whether they are top-level windows or
- children of another QWidget.
-
- Note that this class is only available in Qt for Embedded Linux and only
- available if Qt is configured with OpenGL support.
-*/
-
-class QWSGLWindowSurfacePrivate
-{
-public:
- QWSGLWindowSurfacePrivate() :
- qglContext(0), ownsContext(false) {}
-
- QGLContext *qglContext;
- bool ownsContext;
-};
-
-/*!
- Constructs an empty QWSGLWindowSurface for the given top-level \a window.
- The window surface is later initialized from chooseContext() and resources for it
- is typically allocated in setGeometry().
-*/
-QWSGLWindowSurface::QWSGLWindowSurface(QWidget *window)
- : QWSWindowSurface(window),
- d_ptr(new QWSGLWindowSurfacePrivate)
-{
-}
-
-/*!
- Constructs an empty QWSGLWindowSurface.
-*/
-QWSGLWindowSurface::QWSGLWindowSurface()
- : d_ptr(new QWSGLWindowSurfacePrivate)
-{
-}
-
-/*!
- Destroys the QWSGLWindowSurface object and frees any
- allocated resources.
- */
-QWSGLWindowSurface::~QWSGLWindowSurface()
-{
- Q_D(QWSGLWindowSurface);
- if (d->ownsContext)
- delete d->qglContext;
- delete d;
-}
-
-/*!
- Returns the QGLContext of the window surface.
-*/
-QGLContext *QWSGLWindowSurface::context() const
-{
- Q_D(const QWSGLWindowSurface);
- if (!d->qglContext) {
- QWSGLWindowSurface *that = const_cast<QWSGLWindowSurface*>(this);
- that->setContext(new QGLContext(QGLFormat::defaultFormat()));
- that->d_func()->ownsContext = true;
- }
- return d->qglContext;
-}
-
-/*!
- Sets the QGLContext for this window surface to \a context.
-*/
-void QWSGLWindowSurface::setContext(QGLContext *context)
-{
- Q_D(QWSGLWindowSurface);
- if (d->ownsContext) {
- delete d->qglContext;
- d->ownsContext = false;
- }
- d->qglContext = context;
-}
-
-QT_END_NAMESPACE
diff --git a/src/opengl/qglwindowsurface_qws_p.h b/src/opengl/qglwindowsurface_qws_p.h
deleted file mode 100644
index 07362b1b88..0000000000
--- a/src/opengl/qglwindowsurface_qws_p.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGLWINDOWSURFACE_QWS_P_H
-#define QGLWINDOWSURFACE_QWS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QWSGLWindowSurface class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-#include <QPaintDevice>
-#include "private/qwindowsurface_qws_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QPaintDevice;
-class QPoint;
-class QRegion;
-class QSize;
-class QWidget;
-class QGLContext;
-
-class QWSGLWindowSurfacePrivate;
-
-class Q_OPENGL_EXPORT QWSGLWindowSurface : public QWSWindowSurface
-{
- Q_DECLARE_PRIVATE(QWSGLWindowSurface)
-
-public:
- QWSGLWindowSurface(QWidget *widget);
- QWSGLWindowSurface();
- ~QWSGLWindowSurface();
-
- QGLContext *context() const;
- void setContext(QGLContext *context);
-
-private:
- QWSGLWindowSurfacePrivate *d_ptr;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QGLWINDOWSURFACE_QWS_P_H
diff --git a/src/opengl/qgraphicsshadereffect.cpp b/src/opengl/qgraphicsshadereffect.cpp
index c7a058e9ef..8cca7eae1c 100644
--- a/src/opengl/qgraphicsshadereffect.cpp
+++ b/src/opengl/qgraphicsshadereffect.cpp
@@ -46,8 +46,8 @@
#define QGL_HAVE_CUSTOM_SHADERS 1
#endif
#include <QtGui/qpainter.h>
-#include <QtGui/qgraphicsitem.h>
-#include <QtGui/private/qgraphicseffect_p.h>
+#include <QtWidgets/qgraphicsitem.h>
+#include <private/qgraphicseffect_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/opengl/qgraphicsshadereffect_p.h b/src/opengl/qgraphicsshadereffect_p.h
index 12d716524b..7ae5f53d7e 100644
--- a/src/opengl/qgraphicsshadereffect_p.h
+++ b/src/opengl/qgraphicsshadereffect_p.h
@@ -53,7 +53,7 @@
// We mean it.
//
-#include <QtGui/qgraphicseffect.h>
+#include <QtWidgets/qgraphicseffect.h>
QT_BEGIN_HEADER
diff --git a/src/opengl/qgraphicssystem_gl.cpp b/src/opengl/qgraphicssystem_gl.cpp
deleted file mode 100644
index 01a2864ecc..0000000000
--- a/src/opengl/qgraphicssystem_gl.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystem_gl_p.h"
-#include <QGraphicsView>
-
-#include "private/qpixmap_raster_p.h"
-#include "private/qpixmapdata_gl_p.h"
-#include "private/qwindowsurface_gl_p.h"
-#include "private/qgl_p.h"
-#include <private/qwindowsurface_raster_p.h>
-
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
-#include "private/qpixmapdata_x11gl_p.h"
-#include "private/qwindowsurface_x11gl_p.h"
-#endif
-
-#if defined(Q_OS_SYMBIAN)
-#include <QtGui/private/qapplication_p.h>
-#endif
-
-#ifdef QGL_USE_TEXTURE_POOL
-#include "private/qgltexturepool_p.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-extern QGLWidget *qt_gl_getShareWidget();
-
-QPixmapData *QGLGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- return new QGLPixmapData(type);
-}
-
-QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
-#ifdef Q_WS_WIN
- // On Windows the QGLWindowSurface class can't handle
- // drop shadows and native effects, e.g. fading a menu in/out using
- // top level window opacity.
- if (widget->windowType() == Qt::Popup)
- return new QRasterWindowSurface(widget);
-#endif
-
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
- if (m_useX11GL && QX11GLPixmapData::hasX11GLPixmaps()) {
- // If the widget is a QGraphicsView which will be re-drawing the entire
- // scene each frame anyway, we should use QGLWindowSurface as this may
- // provide proper buffer flipping, which should be faster than QX11GL's
- // blitting approach:
- QGraphicsView* qgv = qobject_cast<QGraphicsView*>(widget);
- if (qgv && qgv->viewportUpdateMode() == QGraphicsView::FullViewportUpdate)
- return new QGLWindowSurface(widget);
- else
- return new QX11GLWindowSurface(widget);
- }
-#endif
-
-#if defined(Q_OS_SYMBIAN)
- if (!QApplicationPrivate::instance()->useTranslucentEGLSurfaces) {
- QWidgetPrivate *d = qt_widget_private(widget);
- if (!d->isOpaque && widget->testAttribute(Qt::WA_TranslucentBackground))
- return d->createDefaultWindowSurface_sys();
- }
-#endif
-
- return new QGLWindowSurface(widget);
-}
-#ifdef QGL_USE_TEXTURE_POOL
-void QGLGraphicsSystem::releaseCachedResources()
-{
- QGLTexturePool::instance()->hibernate();
-}
-#endif
-QT_END_NAMESPACE
-
diff --git a/src/opengl/qgraphicssystem_gl_p.h b/src/opengl/qgraphicssystem_gl_p.h
deleted file mode 100644
index 6e8e9a8966..0000000000
--- a/src/opengl/qgraphicssystem_gl_p.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_RASTER_P_H
-#define QGRAPHICSSYSTEM_RASTER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qgraphicssystem_p.h"
-
-#include <QMap>
-
-QT_BEGIN_NAMESPACE
-
-class Q_OPENGL_EXPORT QGLGraphicsSystem : public QGraphicsSystem
-{
-public:
- QGLGraphicsSystem(bool useX11GL);
-
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-
-#ifdef QGL_USE_TEXTURE_POOL
- void releaseCachedResources();
-#endif
-private:
- bool m_useX11GL;
-};
-
-QT_END_NAMESPACE
-
-#endif
-
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index 56a6af1cfe..3c35c0334c 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -2361,8 +2361,8 @@ void QOpenGLPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOpe
} else {
#ifndef Q_WS_QWS
// Only use the system clip if we're currently rendering a widget with a GL painter.
- if (d->currentClipWidget) {
- QWidgetPrivate *widgetPrivate = qt_widget_private(d->currentClipWidget->window());
+ if (d->currentClipDevice) {
+ QWidgetPrivate *widgetPrivate = qt_widget_private(static_cast<QWidget *>(d->currentClipDevice)->window());
d->use_system_clip = widgetPrivate->extra && widgetPrivate->extra->inRenderWithPainter;
}
#endif
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp
deleted file mode 100644
index e909ff30b9..0000000000
--- a/src/opengl/qpixmapdata_gl.cpp
+++ /dev/null
@@ -1,829 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpixmap.h"
-#include "qglframebufferobject.h"
-
-#include <private/qpaintengine_raster_p.h>
-
-#include "qpixmapdata_gl_p.h"
-
-#include <private/qgl_p.h>
-#include <private/qdrawhelper_p.h>
-#include <private/qimage_p.h>
-#include <private/qfont_p.h>
-
-#include <private/qpaintengineex_opengl2_p.h>
-
-#include <qdesktopwidget.h>
-#include <qfile.h>
-#include <qimagereader.h>
-#include <qbuffer.h>
-
-QT_BEGIN_NAMESPACE
-
-Q_OPENGL_EXPORT extern const QGLContext* qt_gl_share_context();
-
-/*!
- \class QGLFramebufferObjectPool
- \since 4.6
-
- \brief The QGLFramebufferObject class provides a pool of framebuffer
- objects for offscreen rendering purposes.
-
- When requesting an FBO of a given size and format, an FBO of the same
- format and a size at least as big as the requested size will be returned.
-
- \internal
-*/
-
-static inline int areaDiff(const QSize &size, const QGLFramebufferObject *fbo)
-{
- return qAbs(size.width() * size.height() - fbo->width() * fbo->height());
-}
-
-extern int qt_next_power_of_two(int v);
-
-static inline QSize maybeRoundToNextPowerOfTwo(const QSize &sz)
-{
-#ifdef QT_OPENGL_ES_2
- QSize rounded(qt_next_power_of_two(sz.width()), qt_next_power_of_two(sz.height()));
- if (rounded.width() * rounded.height() < 1.20 * sz.width() * sz.height())
- return rounded;
-#endif
- return sz;
-}
-
-
-QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize, const QGLFramebufferObjectFormat &requestFormat, bool strictSize)
-{
- QGLFramebufferObject *chosen = 0;
- QGLFramebufferObject *candidate = 0;
- for (int i = 0; !chosen && i < m_fbos.size(); ++i) {
- QGLFramebufferObject *fbo = m_fbos.at(i);
-
- if (strictSize) {
- if (fbo->size() == requestSize && fbo->format() == requestFormat) {
- chosen = fbo;
- break;
- } else {
- continue;
- }
- }
-
- if (fbo->format() == requestFormat) {
- // choose the fbo with a matching format and the closest size
- if (!candidate || areaDiff(requestSize, candidate) > areaDiff(requestSize, fbo))
- candidate = fbo;
- }
-
- if (candidate) {
- m_fbos.removeOne(candidate);
-
- const QSize fboSize = candidate->size();
- QSize sz = fboSize;
-
- if (sz.width() < requestSize.width())
- sz.setWidth(qMax(requestSize.width(), qRound(sz.width() * 1.5)));
- if (sz.height() < requestSize.height())
- sz.setHeight(qMax(requestSize.height(), qRound(sz.height() * 1.5)));
-
- // wasting too much space?
- if (sz.width() * sz.height() > requestSize.width() * requestSize.height() * 4)
- sz = requestSize;
-
- if (sz != fboSize) {
- delete candidate;
- candidate = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(sz), requestFormat);
- }
-
- chosen = candidate;
- }
- }
-
- if (!chosen) {
- if (strictSize)
- chosen = new QGLFramebufferObject(requestSize, requestFormat);
- else
- chosen = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(requestSize), requestFormat);
- }
-
- if (!chosen->isValid()) {
- delete chosen;
- chosen = 0;
- }
-
- return chosen;
-}
-
-void QGLFramebufferObjectPool::release(QGLFramebufferObject *fbo)
-{
- if (fbo)
- m_fbos << fbo;
-}
-
-
-QPaintEngine* QGLPixmapGLPaintDevice::paintEngine() const
-{
- return data->paintEngine();
-}
-
-void QGLPixmapGLPaintDevice::beginPaint()
-{
- if (!data->isValid())
- return;
-
- // QGLPaintDevice::beginPaint will store the current binding and replace
- // it with m_thisFBO:
- m_thisFBO = data->m_renderFbo->handle();
- QGLPaintDevice::beginPaint();
-
- Q_ASSERT(data->paintEngine()->type() == QPaintEngine::OpenGL2);
-
- // QPixmap::fill() is deferred until now, where we actually need to do the fill:
- if (data->needsFill()) {
- const QColor &c = data->fillColor();
- float alpha = c.alphaF();
- glDisable(GL_SCISSOR_TEST);
- glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha);
- glClear(GL_COLOR_BUFFER_BIT);
- }
- else if (!data->isUninitialized()) {
- // If the pixmap (GL Texture) has valid content (it has been
- // uploaded from an image or rendered into before), we need to
- // copy it from the texture to the render FBO.
-
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_SCISSOR_TEST);
- glDisable(GL_BLEND);
-
-#if !defined(QT_OPENGL_ES_2)
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, data->width(), data->height(), 0, -999999, 999999);
-#endif
-
- glViewport(0, 0, data->width(), data->height());
-
- // Pass false to bind so it doesn't copy the FBO into the texture!
- context()->drawTexture(QRect(0, 0, data->width(), data->height()), data->bind(false));
- }
-}
-
-void QGLPixmapGLPaintDevice::endPaint()
-{
- if (!data->isValid())
- return;
-
- data->copyBackFromRenderFbo(false);
-
- // Base's endPaint will restore the previous FBO binding
- QGLPaintDevice::endPaint();
-
- qgl_fbo_pool()->release(data->m_renderFbo);
- data->m_renderFbo = 0;
-}
-
-QGLContext* QGLPixmapGLPaintDevice::context() const
-{
- data->ensureCreated();
- return data->m_ctx;
-}
-
-QSize QGLPixmapGLPaintDevice::size() const
-{
- return data->size();
-}
-
-bool QGLPixmapGLPaintDevice::alphaRequested() const
-{
- return data->m_hasAlpha;
-}
-
-void QGLPixmapGLPaintDevice::setPixmapData(QGLPixmapData* d)
-{
- data = d;
-}
-
-static int qt_gl_pixmap_serial = 0;
-
-QGLPixmapData::QGLPixmapData(PixelType type)
- : QPixmapData(type, OpenGLClass)
- , m_renderFbo(0)
- , m_engine(0)
- , m_ctx(0)
- , m_dirty(false)
- , m_hasFillColor(false)
- , m_hasAlpha(false)
-{
- setSerialNumber(++qt_gl_pixmap_serial);
- m_glDevice.setPixmapData(this);
-}
-
-QGLPixmapData::~QGLPixmapData()
-{
- const QGLContext *shareContext = qt_gl_share_context();
- if (!shareContext)
- return;
-
- delete m_engine;
-
- if (m_texture.id) {
- QGLShareContextScope ctx(shareContext);
- glDeleteTextures(1, &m_texture.id);
- }
-}
-
-QPixmapData *QGLPixmapData::createCompatiblePixmapData() const
-{
- return new QGLPixmapData(pixelType());
-}
-
-bool QGLPixmapData::isValid() const
-{
- return w > 0 && h > 0;
-}
-
-bool QGLPixmapData::isValidContext(const QGLContext *ctx) const
-{
- if (ctx == m_ctx)
- return true;
-
- const QGLContext *share_ctx = qt_gl_share_context();
- return ctx == share_ctx || QGLContext::areSharing(ctx, share_ctx);
-}
-
-void QGLPixmapData::resize(int width, int height)
-{
- if (width == w && height == h)
- return;
-
- if (width <= 0 || height <= 0) {
- width = 0;
- height = 0;
- }
-
- w = width;
- h = height;
- is_null = (w <= 0 || h <= 0);
- d = pixelType() == QPixmapData::PixmapType ? 32 : 1;
-
- if (m_texture.id) {
- QGLShareContextScope ctx(qt_gl_share_context());
- glDeleteTextures(1, &m_texture.id);
- m_texture.id = 0;
- }
-
- m_source = QImage();
- m_dirty = isValid();
- setSerialNumber(++qt_gl_pixmap_serial);
-}
-
-void QGLPixmapData::ensureCreated() const
-{
- if (!m_dirty)
- return;
-
- m_dirty = false;
-
- QGLShareContextScope ctx(qt_gl_share_context());
- m_ctx = ctx;
-
- const GLenum internal_format = m_hasAlpha ? GL_RGBA : GL_RGB;
-#ifdef QT_OPENGL_ES_2
- const GLenum external_format = internal_format;
-#else
- const GLenum external_format = qt_gl_preferredTextureFormat();
-#endif
- const GLenum target = GL_TEXTURE_2D;
-
- if (!m_texture.id) {
- glGenTextures(1, &m_texture.id);
- glBindTexture(target, m_texture.id);
- glTexImage2D(target, 0, internal_format, w, h, 0, external_format, GL_UNSIGNED_BYTE, 0);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- }
-
- if (!m_source.isNull()) {
- if (external_format == GL_RGB) {
- const QImage tx = m_source.convertToFormat(QImage::Format_RGB888).mirrored(false, true);
-
- glBindTexture(target, m_texture.id);
- glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
- GL_UNSIGNED_BYTE, tx.bits());
- } else {
- const QImage tx = ctx->d_func()->convertToGLFormat(m_source, true, external_format);
-
- glBindTexture(target, m_texture.id);
- glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
- GL_UNSIGNED_BYTE, tx.bits());
- }
-
- if (useFramebufferObjects())
- m_source = QImage();
- }
-
- m_texture.options &= ~QGLContext::MemoryManagedBindOption;
-}
-
-void QGLPixmapData::fromImage(const QImage &image,
- Qt::ImageConversionFlags flags)
-{
- QImage img = image;
- createPixmapForImage(img, flags, false);
-}
-
-void QGLPixmapData::fromImageReader(QImageReader *imageReader,
- Qt::ImageConversionFlags flags)
-{
- QImage image = imageReader->read();
- if (image.isNull())
- return;
-
- createPixmapForImage(image, flags, true);
-}
-
-bool QGLPixmapData::fromFile(const QString &filename, const char *format,
- Qt::ImageConversionFlags flags)
-{
- if (pixelType() == QPixmapData::BitmapType)
- return QPixmapData::fromFile(filename, format, flags);
- QFile file(filename);
- if (file.open(QIODevice::ReadOnly)) {
- QByteArray data = file.peek(64);
- bool alpha;
- if (m_texture.canBindCompressedTexture
- (data.constData(), data.size(), format, &alpha)) {
- resize(0, 0);
- data = file.readAll();
- file.close();
- QGLShareContextScope ctx(qt_gl_share_context());
- QSize size = m_texture.bindCompressedTexture
- (data.constData(), data.size(), format);
- if (!size.isEmpty()) {
- w = size.width();
- h = size.height();
- is_null = false;
- d = 32;
- m_hasAlpha = alpha;
- m_source = QImage();
- m_dirty = isValid();
- return true;
- }
- return false;
- }
- }
-
- QImage image = QImageReader(filename, format).read();
- if (image.isNull())
- return false;
-
- createPixmapForImage(image, flags, true);
-
- return !isNull();
-}
-
-bool QGLPixmapData::fromData(const uchar *buffer, uint len, const char *format,
- Qt::ImageConversionFlags flags)
-{
- bool alpha;
- const char *buf = reinterpret_cast<const char *>(buffer);
- if (m_texture.canBindCompressedTexture(buf, int(len), format, &alpha)) {
- resize(0, 0);
- QGLShareContextScope ctx(qt_gl_share_context());
- QSize size = m_texture.bindCompressedTexture(buf, int(len), format);
- if (!size.isEmpty()) {
- w = size.width();
- h = size.height();
- is_null = false;
- d = 32;
- m_hasAlpha = alpha;
- m_source = QImage();
- m_dirty = isValid();
- return true;
- }
- }
-
- QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(buffer), len);
- QBuffer b(&a);
- b.open(QIODevice::ReadOnly);
- QImage image = QImageReader(&b, format).read();
- if (image.isNull())
- return false;
-
- createPixmapForImage(image, flags, true);
-
- return !isNull();
-}
-
-/*!
- out-of-place conversion (inPlace == false) will always detach()
- */
-void QGLPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace)
-{
- if (image.size() == QSize(w, h))
- setSerialNumber(++qt_gl_pixmap_serial);
-
- resize(image.width(), image.height());
-
- if (pixelType() == BitmapType) {
- m_source = image.convertToFormat(QImage::Format_MonoLSB);
-
- } else {
- QImage::Format format = QImage::Format_RGB32;
- if (qApp->desktop()->depth() == 16)
- format = QImage::Format_RGB16;
-
- if (image.hasAlphaChannel()
- && ((flags & Qt::NoOpaqueDetection)
- || const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()))
- format = QImage::Format_ARGB32_Premultiplied;;
-
- if (inPlace && image.data_ptr()->convertInPlace(format, flags)) {
- m_source = image;
- } else {
- m_source = image.convertToFormat(format);
-
- // convertToFormat won't detach the image if format stays the same.
- if (image.format() == format)
- m_source.detach();
- }
- }
-
- m_dirty = true;
- m_hasFillColor = false;
-
- m_hasAlpha = m_source.hasAlphaChannel();
- w = image.width();
- h = image.height();
- is_null = (w <= 0 || h <= 0);
- d = m_source.depth();
-
- if (m_texture.id) {
- QGLShareContextScope ctx(qt_gl_share_context());
- glDeleteTextures(1, &m_texture.id);
- m_texture.id = 0;
- }
-}
-
-bool QGLPixmapData::scroll(int dx, int dy, const QRect &rect)
-{
- Q_UNUSED(dx);
- Q_UNUSED(dy);
- Q_UNUSED(rect);
- return false;
-}
-
-void QGLPixmapData::copy(const QPixmapData *data, const QRect &rect)
-{
- if (data->classId() != QPixmapData::OpenGLClass || !static_cast<const QGLPixmapData *>(data)->useFramebufferObjects()) {
- QPixmapData::copy(data, rect);
- return;
- }
-
- const QGLPixmapData *other = static_cast<const QGLPixmapData *>(data);
- if (other->m_renderFbo) {
- QGLShareContextScope ctx(qt_gl_share_context());
-
- resize(rect.width(), rect.height());
- m_hasAlpha = other->m_hasAlpha;
- ensureCreated();
-
- if (!ctx->d_ptr->fbo)
- glGenFramebuffers(1, &ctx->d_ptr->fbo);
-
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, ctx->d_ptr->fbo);
- glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, m_texture.id, 0);
-
- if (!other->m_renderFbo->isBound())
- glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, other->m_renderFbo->handle());
-
- glDisable(GL_SCISSOR_TEST);
- if (ctx->d_ptr->active_engine && ctx->d_ptr->active_engine->type() == QPaintEngine::OpenGL2)
- static_cast<QGL2PaintEngineEx *>(ctx->d_ptr->active_engine)->invalidateState();
-
- glBlitFramebufferEXT(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height(),
- 0, 0, w, h,
- GL_COLOR_BUFFER_BIT,
- GL_NEAREST);
-
- glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);
- } else {
- QPixmapData::copy(data, rect);
- }
-}
-
-void QGLPixmapData::fill(const QColor &color)
-{
- if (!isValid())
- return;
-
- bool hasAlpha = color.alpha() != 255;
- if (hasAlpha && !m_hasAlpha) {
- if (m_texture.id) {
- glDeleteTextures(1, &m_texture.id);
- m_texture.id = 0;
- m_dirty = true;
- }
- m_hasAlpha = color.alpha() != 255;
- }
-
- if (useFramebufferObjects()) {
- m_source = QImage();
- m_hasFillColor = true;
- m_fillColor = color;
- } else {
-
- if (m_source.isNull()) {
- m_fillColor = color;
- m_hasFillColor = true;
-
- } else if (m_source.depth() == 32) {
- m_source.fill(PREMUL(color.rgba()));
-
- } else if (m_source.depth() == 1) {
- if (color == Qt::color1)
- m_source.fill(1);
- else
- m_source.fill(0);
- }
- }
-}
-
-bool QGLPixmapData::hasAlphaChannel() const
-{
- return m_hasAlpha;
-}
-
-QImage QGLPixmapData::fillImage(const QColor &color) const
-{
- QImage img;
- if (pixelType() == BitmapType) {
- img = QImage(w, h, QImage::Format_MonoLSB);
-
- img.setColorCount(2);
- img.setColor(0, QColor(Qt::color0).rgba());
- img.setColor(1, QColor(Qt::color1).rgba());
-
- if (color == Qt::color1)
- img.fill(1);
- else
- img.fill(0);
- } else {
- img = QImage(w, h,
- m_hasAlpha
- ? QImage::Format_ARGB32_Premultiplied
- : QImage::Format_RGB32);
- img.fill(PREMUL(color.rgba()));
- }
- return img;
-}
-
-extern QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alpha);
-
-QImage QGLPixmapData::toImage() const
-{
- if (!isValid())
- return QImage();
-
- if (m_renderFbo) {
- copyBackFromRenderFbo(true);
- } else if (!m_source.isNull()) {
- QImageData *data = const_cast<QImage &>(m_source).data_ptr();
- if (data->paintEngine && data->paintEngine->isActive()
- && data->paintEngine->paintDevice() == &m_source)
- {
- return m_source.copy();
- }
- return m_source;
- } else if (m_dirty || m_hasFillColor) {
- return fillImage(m_fillColor);
- } else {
- ensureCreated();
- }
-
- QGLShareContextScope ctx(qt_gl_share_context());
- glBindTexture(GL_TEXTURE_2D, m_texture.id);
- return qt_gl_read_texture(QSize(w, h), true, true);
-}
-
-struct TextureBuffer
-{
- QGLFramebufferObject *fbo;
- QGL2PaintEngineEx *engine;
-};
-
-Q_GLOBAL_STATIC(QGLFramebufferObjectPool, _qgl_fbo_pool)
-QGLFramebufferObjectPool* qgl_fbo_pool()
-{
- return _qgl_fbo_pool();
-}
-
-void QGLPixmapData::copyBackFromRenderFbo(bool keepCurrentFboBound) const
-{
- if (!isValid())
- return;
-
- m_hasFillColor = false;
-
- const QGLContext *share_ctx = qt_gl_share_context();
- QGLShareContextScope ctx(share_ctx);
-
- ensureCreated();
-
- if (!ctx->d_ptr->fbo)
- glGenFramebuffers(1, &ctx->d_ptr->fbo);
-
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, ctx->d_ptr->fbo);
- glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, m_texture.id, 0);
-
- const int x0 = 0;
- const int x1 = w;
- const int y0 = 0;
- const int y1 = h;
-
- if (!m_renderFbo->isBound())
- glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, m_renderFbo->handle());
-
- glDisable(GL_SCISSOR_TEST);
-
- glBlitFramebufferEXT(x0, y0, x1, y1,
- x0, y0, x1, y1,
- GL_COLOR_BUFFER_BIT,
- GL_NEAREST);
-
- if (keepCurrentFboBound) {
- glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);
- } else {
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, m_renderFbo->handle());
- ctx->d_ptr->current_fbo = m_renderFbo->handle();
- }
-}
-
-bool QGLPixmapData::useFramebufferObjects() const
-{
- return QGLFramebufferObject::hasOpenGLFramebufferObjects()
- && QGLFramebufferObject::hasOpenGLFramebufferBlit()
- && qt_gl_preferGL2Engine()
- && (w * h > 32*32); // avoid overhead of FBOs for small pixmaps
-}
-
-QPaintEngine* QGLPixmapData::paintEngine() const
-{
- if (!isValid())
- return 0;
-
- if (m_renderFbo)
- return m_engine;
-
- if (useFramebufferObjects()) {
- extern QGLWidget* qt_gl_share_widget();
-
- if (!QGLContext::currentContext())
- const_cast<QGLContext *>(qt_gl_share_context())->makeCurrent();
- QGLShareContextScope ctx(qt_gl_share_context());
-
- QGLFramebufferObjectFormat format;
- format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
- format.setSamples(4);
- format.setInternalTextureFormat(GLenum(m_hasAlpha ? GL_RGBA : GL_RGB));
-
- m_renderFbo = qgl_fbo_pool()->acquire(size(), format);
-
- if (m_renderFbo) {
- if (!m_engine)
- m_engine = new QGL2PaintEngineEx;
- return m_engine;
- }
-
- qWarning() << "Failed to create pixmap texture buffer of size " << size() << ", falling back to raster paint engine";
- }
-
- m_dirty = true;
- if (m_source.size() != size())
- m_source = QImage(size(), QImage::Format_ARGB32_Premultiplied);
- if (m_hasFillColor) {
- m_source.fill(PREMUL(m_fillColor.rgba()));
- m_hasFillColor = false;
- }
- return m_source.paintEngine();
-}
-
-extern QRgb qt_gl_convertToGLFormat(QRgb src_pixel, GLenum texture_format);
-
-// If copyBack is true, bind will copy the contents of the render
-// FBO to the texture (which is not bound to the texture, as it's
-// a multisample FBO).
-GLuint QGLPixmapData::bind(bool copyBack) const
-{
- if (m_renderFbo && copyBack) {
- copyBackFromRenderFbo(true);
- } else {
- ensureCreated();
- }
-
- GLuint id = m_texture.id;
- glBindTexture(GL_TEXTURE_2D, id);
-
- if (m_hasFillColor) {
- if (!useFramebufferObjects()) {
- m_source = QImage(w, h, QImage::Format_ARGB32_Premultiplied);
- m_source.fill(PREMUL(m_fillColor.rgba()));
- }
-
- m_hasFillColor = false;
-
- GLenum format = qt_gl_preferredTextureFormat();
- QImage tx(w, h, QImage::Format_ARGB32_Premultiplied);
- tx.fill(qt_gl_convertToGLFormat(m_fillColor.rgba(), format));
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, format, GL_UNSIGNED_BYTE, tx.bits());
- }
-
- return id;
-}
-
-QGLTexture* QGLPixmapData::texture() const
-{
- return &m_texture;
-}
-
-int QGLPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
-{
- if (w == 0)
- return 0;
-
- switch (metric) {
- case QPaintDevice::PdmWidth:
- return w;
- case QPaintDevice::PdmHeight:
- return h;
- case QPaintDevice::PdmNumColors:
- return 0;
- case QPaintDevice::PdmDepth:
- return d;
- case QPaintDevice::PdmWidthMM:
- return qRound(w * 25.4 / qt_defaultDpiX());
- case QPaintDevice::PdmHeightMM:
- return qRound(h * 25.4 / qt_defaultDpiY());
- case QPaintDevice::PdmDpiX:
- case QPaintDevice::PdmPhysicalDpiX:
- return qt_defaultDpiX();
- case QPaintDevice::PdmDpiY:
- case QPaintDevice::PdmPhysicalDpiY:
- return qt_defaultDpiY();
- default:
- qWarning("QGLPixmapData::metric(): Invalid metric");
- return 0;
- }
-}
-
-QGLPaintDevice *QGLPixmapData::glDevice() const
-{
- return &m_glDevice;
-}
-
-QT_END_NAMESPACE
diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h
deleted file mode 100644
index 909f264d05..0000000000
--- a/src/opengl/qpixmapdata_gl_p.h
+++ /dev/null
@@ -1,247 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPIXMAPDATA_GL_P_H
-#define QPIXMAPDATA_GL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgl_p.h"
-#include "qgl.h"
-
-#include "private/qpixmapdata_p.h"
-#include "private/qglpaintdevice_p.h"
-
-#ifdef Q_OS_SYMBIAN
-#include "private/qvolatileimage_p.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QPaintEngine;
-class QGLFramebufferObject;
-class QGLFramebufferObjectFormat;
-class QGLPixmapData;
-
-#ifdef QGL_USE_TEXTURE_POOL
-void qt_gl_register_pixmap(QGLPixmapData *pd);
-void qt_gl_unregister_pixmap(QGLPixmapData *pd);
-void qt_gl_hibernate_pixmaps();
-#endif
-
-#ifdef Q_OS_SYMBIAN
-class QNativeImageHandleProvider;
-#endif
-
-class QGLFramebufferObjectPool
-{
-public:
- QGLFramebufferObject *acquire(const QSize &size, const QGLFramebufferObjectFormat &format, bool strictSize = false);
- void release(QGLFramebufferObject *fbo);
-
-private:
- QList<QGLFramebufferObject *> m_fbos;
-};
-
-QGLFramebufferObjectPool* qgl_fbo_pool();
-
-
-class QGLPixmapGLPaintDevice : public QGLPaintDevice
-{
-public:
- QPaintEngine* paintEngine() const;
-
- void beginPaint();
- void endPaint();
- QGLContext* context() const;
- QSize size() const;
- bool alphaRequested() const;
-
- void setPixmapData(QGLPixmapData*);
-private:
- QGLPixmapData *data;
-};
-
-
-class Q_OPENGL_EXPORT QGLPixmapData : public QPixmapData
-{
-public:
- QGLPixmapData(PixelType type);
- ~QGLPixmapData();
-
- QPixmapData *createCompatiblePixmapData() const;
-
- // Re-implemented from QPixmapData:
- void resize(int width, int height);
- void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
- void fromImageReader(QImageReader *imageReader,
- Qt::ImageConversionFlags flags);
- bool fromFile(const QString &filename, const char *format,
- Qt::ImageConversionFlags flags);
- bool fromData(const uchar *buffer, uint len, const char *format,
- Qt::ImageConversionFlags flags);
- void copy(const QPixmapData *data, const QRect &rect);
- bool scroll(int dx, int dy, const QRect &rect);
- void fill(const QColor &color);
- bool hasAlphaChannel() const;
- QImage toImage() const;
- QPaintEngine *paintEngine() const;
- int metric(QPaintDevice::PaintDeviceMetric metric) const;
-
- // For accessing as a target:
- QGLPaintDevice *glDevice() const;
-
- // For accessing as a source:
- bool isValidContext(const QGLContext *ctx) const;
- GLuint bind(bool copyBack = true) const;
- QGLTexture *texture() const;
-
-#ifdef QGL_USE_TEXTURE_POOL
- void destroyTexture();
- // Detach this image from the image pool.
- void detachTextureFromPool();
- // Release the GL resources associated with this pixmap and copy
- // the pixmap's contents out of the GPU back into main memory.
- // The GL resource will be automatically recreated the next time
- // ensureCreated() is called. Does nothing if the pixmap cannot be
- // hibernated for some reason (e.g. texture is shared with another
- // process via a SgImage).
- void hibernate();
- // Called when the QGLTexturePool wants to reclaim this pixmap's
- // texture objects to reuse storage.
- void reclaimTexture();
- void forceToImage();
-#endif
-
-#ifdef Q_OS_SYMBIAN
- QImage::Format idealFormat(QImage &image, Qt::ImageConversionFlags flags);
- void* toNativeType(NativeType type);
- void fromNativeType(void* pixmap, NativeType type);
- bool initFromNativeImageHandle(void *handle, const QString &type);
- void createFromNativeImageHandleProvider();
- void releaseNativeImageHandle();
-#endif
-
-private:
- bool isValid() const;
-
- void ensureCreated() const;
-
- bool isUninitialized() const { return m_dirty && m_source.isNull(); }
-
- bool needsFill() const { return m_hasFillColor; }
- QColor fillColor() const { return m_fillColor; }
-
-
-
- QGLPixmapData(const QGLPixmapData &other);
- QGLPixmapData &operator=(const QGLPixmapData &other);
-
- void copyBackFromRenderFbo(bool keepCurrentFboBound) const;
- QSize size() const { return QSize(w, h); }
-
- bool useFramebufferObjects() const;
-
- QImage fillImage(const QColor &color) const;
-
- void createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace);
-
- mutable QGLFramebufferObject *m_renderFbo;
- mutable QPaintEngine *m_engine;
- mutable QGLContext *m_ctx;
-#ifdef Q_OS_SYMBIAN
- mutable QVolatileImage m_source;
- mutable QNativeImageHandleProvider *nativeImageHandleProvider;
- void *nativeImageHandle;
- QString nativeImageType;
-#else
- mutable QImage m_source;
-#endif
- mutable QGLTexture m_texture;
-
- // the texture is not in sync with the source image
- mutable bool m_dirty;
-
- // fill has been called and no painting has been done, so the pixmap is
- // represented by a single fill color
- mutable QColor m_fillColor;
- mutable bool m_hasFillColor;
-
- mutable bool m_hasAlpha;
-
- mutable QGLPixmapGLPaintDevice m_glDevice;
-
-#ifdef QGL_USE_TEXTURE_POOL
- QGLPixmapData *nextLRU;
- QGLPixmapData *prevLRU;
- mutable bool inLRU;
- mutable bool failedToAlloc;
- mutable bool inTexturePool;
-
- QGLPixmapData *next;
- QGLPixmapData *prev;
-
- friend class QGLTexturePool;
-
- friend void qt_gl_register_pixmap(QGLPixmapData *pd);
- friend void qt_gl_unregister_pixmap(QGLPixmapData *pd);
- friend void qt_gl_hibernate_pixmaps();
-#endif
-
- friend class QGLPixmapGLPaintDevice;
- friend class QMeeGoPixmapData;
- friend class QMeeGoLivePixmapData;
-};
-
-QT_END_NAMESPACE
-
-#endif // QPIXMAPDATA_GL_P_H
-
-
diff --git a/src/opengl/qpixmapdata_poolgl.cpp b/src/opengl/qpixmapdata_poolgl.cpp
deleted file mode 100644
index 5dd7b09c64..0000000000
--- a/src/opengl/qpixmapdata_poolgl.cpp
+++ /dev/null
@@ -1,934 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpixmap.h"
-#include "qglframebufferobject.h"
-
-#include <private/qpaintengine_raster_p.h>
-
-#include "qpixmapdata_gl_p.h"
-
-#include <private/qgl_p.h>
-#include <private/qdrawhelper_p.h>
-#include <private/qimage_p.h>
-#include <private/qnativeimagehandleprovider_p.h>
-#include <private/qfont_p.h>
-
-#include <private/qpaintengineex_opengl2_p.h>
-
-#include <qdesktopwidget.h>
-#include <qfile.h>
-#include <qimagereader.h>
-#include <qbuffer.h>
-
-#include "qgltexturepool_p.h"
-
-QT_BEGIN_NAMESPACE
-
-Q_OPENGL_EXPORT extern QGLWidget* qt_gl_share_widget();
-
-static inline int areaDiff(const QSize &size, const QGLFramebufferObject *fbo)
-{
- return qAbs(size.width() * size.height() - fbo->width() * fbo->height());
-}
-
-extern int qt_next_power_of_two(int v);
-
-static inline QSize maybeRoundToNextPowerOfTwo(const QSize &sz)
-{
-#ifdef QT_OPENGL_ES_2
- QSize rounded(qt_next_power_of_two(sz.width()), qt_next_power_of_two(sz.height()));
- if (rounded.width() * rounded.height() < 1.20 * sz.width() * sz.height())
- return rounded;
-#endif
- return sz;
-}
-
-
-QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize, const QGLFramebufferObjectFormat &requestFormat, bool strictSize)
-{
- QGLFramebufferObject *chosen = 0;
- QGLFramebufferObject *candidate = 0;
- for (int i = 0; !chosen && i < m_fbos.size(); ++i) {
- QGLFramebufferObject *fbo = m_fbos.at(i);
-
- if (strictSize) {
- if (fbo->size() == requestSize && fbo->format() == requestFormat) {
- chosen = fbo;
- break;
- } else {
- continue;
- }
- }
-
- if (fbo->format() == requestFormat) {
- // choose the fbo with a matching format and the closest size
- if (!candidate || areaDiff(requestSize, candidate) > areaDiff(requestSize, fbo))
- candidate = fbo;
- }
-
- if (candidate) {
- m_fbos.removeOne(candidate);
-
- const QSize fboSize = candidate->size();
- QSize sz = fboSize;
-
- if (sz.width() < requestSize.width())
- sz.setWidth(qMax(requestSize.width(), qRound(sz.width() * 1.5)));
- if (sz.height() < requestSize.height())
- sz.setHeight(qMax(requestSize.height(), qRound(sz.height() * 1.5)));
-
- // wasting too much space?
- if (sz.width() * sz.height() > requestSize.width() * requestSize.height() * 4)
- sz = requestSize;
-
- if (sz != fboSize) {
- delete candidate;
- candidate = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(sz), requestFormat);
- }
-
- chosen = candidate;
- }
- }
-
- if (!chosen) {
- if (strictSize)
- chosen = new QGLFramebufferObject(requestSize, requestFormat);
- else
- chosen = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(requestSize), requestFormat);
- }
-
- if (!chosen->isValid()) {
- delete chosen;
- chosen = 0;
- }
-
- return chosen;
-}
-
-void QGLFramebufferObjectPool::release(QGLFramebufferObject *fbo)
-{
- if (fbo)
- m_fbos << fbo;
-}
-
-
-QPaintEngine* QGLPixmapGLPaintDevice::paintEngine() const
-{
- return data->paintEngine();
-}
-
-void QGLPixmapGLPaintDevice::beginPaint()
-{
- if (!data->isValid())
- return;
-
- // QGLPaintDevice::beginPaint will store the current binding and replace
- // it with m_thisFBO:
- m_thisFBO = data->m_renderFbo->handle();
- QGLPaintDevice::beginPaint();
-
- Q_ASSERT(data->paintEngine()->type() == QPaintEngine::OpenGL2);
-
- // QPixmap::fill() is deferred until now, where we actually need to do the fill:
- if (data->needsFill()) {
- const QColor &c = data->fillColor();
- float alpha = c.alphaF();
- glDisable(GL_SCISSOR_TEST);
- glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha);
- glClear(GL_COLOR_BUFFER_BIT);
- }
- else if (!data->isUninitialized()) {
- // If the pixmap (GL Texture) has valid content (it has been
- // uploaded from an image or rendered into before), we need to
- // copy it from the texture to the render FBO.
-
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_SCISSOR_TEST);
- glDisable(GL_BLEND);
-
-#if !defined(QT_OPENGL_ES_2)
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, data->width(), data->height(), 0, -999999, 999999);
-#endif
-
- glViewport(0, 0, data->width(), data->height());
-
- // Pass false to bind so it doesn't copy the FBO into the texture!
- context()->drawTexture(QRect(0, 0, data->width(), data->height()), data->bind(false));
- }
-}
-
-void QGLPixmapGLPaintDevice::endPaint()
-{
- if (!data->isValid())
- return;
-
- data->copyBackFromRenderFbo(false);
-
- // Base's endPaint will restore the previous FBO binding
- QGLPaintDevice::endPaint();
-
- qgl_fbo_pool()->release(data->m_renderFbo);
- data->m_renderFbo = 0;
-}
-
-QGLContext* QGLPixmapGLPaintDevice::context() const
-{
- data->ensureCreated();
- return data->m_ctx;
-}
-
-QSize QGLPixmapGLPaintDevice::size() const
-{
- return data->size();
-}
-
-bool QGLPixmapGLPaintDevice::alphaRequested() const
-{
- return data->m_hasAlpha;
-}
-
-void QGLPixmapGLPaintDevice::setPixmapData(QGLPixmapData* d)
-{
- data = d;
-}
-
-int qt_gl_pixmap_serial = 0;
-
-QGLPixmapData::QGLPixmapData(PixelType type)
- : QPixmapData(type, OpenGLClass)
- , m_renderFbo(0)
- , m_engine(0)
- , m_ctx(0)
- , nativeImageHandleProvider(0)
- , nativeImageHandle(0)
- , m_dirty(false)
- , m_hasFillColor(false)
- , m_hasAlpha(false)
- , inLRU(false)
- , failedToAlloc(false)
- , inTexturePool(false)
-{
- setSerialNumber(++qt_gl_pixmap_serial);
- m_glDevice.setPixmapData(this);
-
- qt_gl_register_pixmap(this);
-}
-
-QGLPixmapData::~QGLPixmapData()
-{
- delete m_engine;
-
- destroyTexture();
- qt_gl_unregister_pixmap(this);
-}
-
-void QGLPixmapData::destroyTexture()
-{
- if (inTexturePool) {
- QGLTexturePool *pool = QGLTexturePool::instance();
- if (m_texture.id)
- pool->releaseTexture(this, m_texture.id);
- } else {
- if (m_texture.id) {
- QGLWidget *shareWidget = qt_gl_share_widget();
- if (shareWidget) {
- QGLShareContextScope ctx(shareWidget->context());
- glDeleteTextures(1, &m_texture.id);
- }
- }
- }
- m_texture.id = 0;
- inTexturePool = false;
-
- releaseNativeImageHandle();
-}
-
-QPixmapData *QGLPixmapData::createCompatiblePixmapData() const
-{
- return new QGLPixmapData(pixelType());
-}
-
-bool QGLPixmapData::isValid() const
-{
- return w > 0 && h > 0;
-}
-
-bool QGLPixmapData::isValidContext(const QGLContext *ctx) const
-{
- if (ctx == m_ctx)
- return true;
-
- const QGLContext *share_ctx = qt_gl_share_widget()->context();
- return ctx == share_ctx || QGLContext::areSharing(ctx, share_ctx);
-}
-
-void QGLPixmapData::resize(int width, int height)
-{
- if (width == w && height == h)
- return;
-
- if (width <= 0 || height <= 0) {
- width = 0;
- height = 0;
- }
-
- w = width;
- h = height;
- is_null = (w <= 0 || h <= 0);
- d = pixelType() == QPixmapData::PixmapType ? 32 : 1;
-
- destroyTexture();
-
- m_source = QVolatileImage();
- m_dirty = isValid();
- setSerialNumber(++qt_gl_pixmap_serial);
-}
-
-void QGLPixmapData::ensureCreated() const
-{
- if (!m_dirty)
- return;
-
- m_dirty = false;
-
- if (nativeImageHandleProvider && !nativeImageHandle)
- const_cast<QGLPixmapData *>(this)->createFromNativeImageHandleProvider();
-
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- m_ctx = ctx;
-
- const GLenum internal_format = m_hasAlpha ? GL_RGBA : GL_RGB;
-#ifdef QT_OPENGL_ES_2
- const GLenum external_format = internal_format;
-#else
- const GLenum external_format = qt_gl_preferredTextureFormat();
-#endif
- const GLenum target = GL_TEXTURE_2D;
-
- GLenum type = GL_UNSIGNED_BYTE;
- // Avoid conversion when pixmap is created from CFbsBitmap of EColor64K.
- if (!m_source.isNull() && m_source.format() == QImage::Format_RGB16)
- type = GL_UNSIGNED_SHORT_5_6_5;
-
- m_texture.options &= ~QGLContext::MemoryManagedBindOption;
-
- if (!m_texture.id) {
- m_texture.id = QGLTexturePool::instance()->createTextureForPixmap(
- target,
- 0, internal_format,
- w, h,
- external_format,
- type,
- const_cast<QGLPixmapData*>(this));
- if (!m_texture.id) {
- failedToAlloc = true;
- return;
- }
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
- inTexturePool = true;
- } else if (inTexturePool) {
- glBindTexture(target, m_texture.id);
- QGLTexturePool::instance()->useTexture(const_cast<QGLPixmapData*>(this));
- }
-
- if (!m_source.isNull() && m_texture.id) {
- if (external_format == GL_RGB) {
- m_source.beginDataAccess();
- QImage tx;
- if (type == GL_UNSIGNED_BYTE)
- tx = m_source.imageRef().convertToFormat(QImage::Format_RGB888).mirrored(false, true);
- else if (type == GL_UNSIGNED_SHORT_5_6_5)
- tx = m_source.imageRef().mirrored(false, true);
- m_source.endDataAccess(true);
-
- glBindTexture(target, m_texture.id);
- if (!tx.isNull())
- glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
- type, tx.constBits());
- else
- qWarning("QGLPixmapData: Failed to create GL_RGB image of size %dx%d", w, h);
- } else {
- // do byte swizzling ARGB -> RGBA
- m_source.beginDataAccess();
- const QImage tx = ctx->d_func()->convertToGLFormat(m_source.imageRef(), true, external_format);
- m_source.endDataAccess(true);
- glBindTexture(target, m_texture.id);
- if (!tx.isNull())
- glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
- type, tx.constBits());
- else
- qWarning("QGLPixmapData: Failed to create GL_RGBA image of size %dx%d", w, h);
- }
-
- if (useFramebufferObjects())
- m_source = QVolatileImage();
- }
-}
-
-
-void QGLPixmapData::fromImage(const QImage &image,
- Qt::ImageConversionFlags flags)
-{
- QImage img = image;
- createPixmapForImage(img, flags, false);
-}
-
-void QGLPixmapData::fromImageReader(QImageReader *imageReader,
- Qt::ImageConversionFlags flags)
-{
- QImage image = imageReader->read();
- if (image.isNull())
- return;
-
- createPixmapForImage(image, flags, true);
-}
-
-bool QGLPixmapData::fromFile(const QString &filename, const char *format,
- Qt::ImageConversionFlags flags)
-{
- if (pixelType() == QPixmapData::BitmapType)
- return QPixmapData::fromFile(filename, format, flags);
- QFile file(filename);
- if (file.open(QIODevice::ReadOnly)) {
- QByteArray data = file.peek(64);
- bool alpha;
- if (m_texture.canBindCompressedTexture
- (data.constData(), data.size(), format, &alpha)) {
- resize(0, 0);
- data = file.readAll();
- file.close();
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QSize size = m_texture.bindCompressedTexture
- (data.constData(), data.size(), format);
- if (!size.isEmpty()) {
- w = size.width();
- h = size.height();
- is_null = false;
- d = 32;
- m_hasAlpha = alpha;
- m_source = QVolatileImage();
- m_dirty = isValid();
- return true;
- }
- return false;
- }
- }
-
- QImage image = QImageReader(filename, format).read();
- if (image.isNull())
- return false;
-
- createPixmapForImage(image, flags, true);
-
- return !isNull();
-}
-
-bool QGLPixmapData::fromData(const uchar *buffer, uint len, const char *format,
- Qt::ImageConversionFlags flags)
-{
- bool alpha;
- const char *buf = reinterpret_cast<const char *>(buffer);
- if (m_texture.canBindCompressedTexture(buf, int(len), format, &alpha)) {
- resize(0, 0);
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QSize size = m_texture.bindCompressedTexture(buf, int(len), format);
- if (!size.isEmpty()) {
- w = size.width();
- h = size.height();
- is_null = false;
- d = 32;
- m_hasAlpha = alpha;
- m_source = QVolatileImage();
- m_dirty = isValid();
- return true;
- }
- }
-
- QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(buffer), len);
- QBuffer b(&a);
- b.open(QIODevice::ReadOnly);
- QImage image = QImageReader(&b, format).read();
- if (image.isNull())
- return false;
-
- createPixmapForImage(image, flags, true);
-
- return !isNull();
-}
-
-QImage::Format QGLPixmapData::idealFormat(QImage &image, Qt::ImageConversionFlags flags)
-{
- QImage::Format format = QImage::Format_RGB32;
- if (qApp->desktop()->depth() == 16)
- format = QImage::Format_RGB16;
-
- if (image.hasAlphaChannel()
- && ((flags & Qt::NoOpaqueDetection)
- || const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()))
- format = QImage::Format_ARGB32_Premultiplied;
-
- return format;
-}
-
-void QGLPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace)
-{
- if (image.size() == QSize(w, h))
- setSerialNumber(++qt_gl_pixmap_serial);
-
- resize(image.width(), image.height());
-
- if (pixelType() == BitmapType) {
- QImage convertedImage = image.convertToFormat(QImage::Format_MonoLSB);
- if (image.format() == QImage::Format_MonoLSB)
- convertedImage.detach();
-
- m_source = QVolatileImage(convertedImage);
-
- } else {
- QImage::Format format = idealFormat(image, flags);
-
- if (inPlace && image.data_ptr()->convertInPlace(format, flags)) {
- m_source = QVolatileImage(image);
- } else {
- QImage convertedImage = image.convertToFormat(format);
-
- // convertToFormat won't detach the image if format stays the same.
- if (image.format() == format)
- convertedImage.detach();
-
- m_source = QVolatileImage(convertedImage);
- }
- }
-
- m_dirty = true;
- m_hasFillColor = false;
-
- m_hasAlpha = m_source.hasAlphaChannel();
- w = image.width();
- h = image.height();
- is_null = (w <= 0 || h <= 0);
- d = m_source.depth();
-
- destroyTexture();
-}
-
-bool QGLPixmapData::scroll(int dx, int dy, const QRect &rect)
-{
- Q_UNUSED(dx);
- Q_UNUSED(dy);
- Q_UNUSED(rect);
- return false;
-}
-
-void QGLPixmapData::copy(const QPixmapData *data, const QRect &rect)
-{
- if (data->classId() != QPixmapData::OpenGLClass || !static_cast<const QGLPixmapData *>(data)->useFramebufferObjects()) {
- QPixmapData::copy(data, rect);
- return;
- }
-
- const QGLPixmapData *other = static_cast<const QGLPixmapData *>(data);
- if (other->m_renderFbo) {
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
-
- resize(rect.width(), rect.height());
- m_hasAlpha = other->m_hasAlpha;
- ensureCreated();
-
- if (!ctx->d_ptr->fbo)
- glGenFramebuffers(1, &ctx->d_ptr->fbo);
-
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, ctx->d_ptr->fbo);
- glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, m_texture.id, 0);
-
- if (!other->m_renderFbo->isBound())
- glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, other->m_renderFbo->handle());
-
- glDisable(GL_SCISSOR_TEST);
- if (ctx->d_ptr->active_engine && ctx->d_ptr->active_engine->type() == QPaintEngine::OpenGL2)
- static_cast<QGL2PaintEngineEx *>(ctx->d_ptr->active_engine)->invalidateState();
-
- glBlitFramebufferEXT(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height(),
- 0, 0, w, h,
- GL_COLOR_BUFFER_BIT,
- GL_NEAREST);
-
- glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);
- } else {
- QPixmapData::copy(data, rect);
- }
-}
-
-void QGLPixmapData::fill(const QColor &color)
-{
- if (!isValid())
- return;
-
- bool hasAlpha = color.alpha() != 255;
- if (hasAlpha && !m_hasAlpha) {
- if (m_texture.id) {
- destroyTexture();
- m_dirty = true;
- }
- m_hasAlpha = color.alpha() != 255;
- }
-
- if (useFramebufferObjects()) {
- m_source = QVolatileImage();
- m_hasFillColor = true;
- m_fillColor = color;
- } else {
- forceToImage();
-
- if (m_source.depth() == 32) {
- m_source.fill(PREMUL(color.rgba()));
-
- } else if (m_source.depth() == 1) {
- if (color == Qt::color1)
- m_source.fill(1);
- else
- m_source.fill(0);
- }
- }
-}
-
-bool QGLPixmapData::hasAlphaChannel() const
-{
- return m_hasAlpha;
-}
-
-QImage QGLPixmapData::fillImage(const QColor &color) const
-{
- QImage img;
- if (pixelType() == BitmapType) {
- img = QImage(w, h, QImage::Format_MonoLSB);
-
- img.setColorCount(2);
- img.setColor(0, QColor(Qt::color0).rgba());
- img.setColor(1, QColor(Qt::color1).rgba());
-
- if (color == Qt::color1)
- img.fill(1);
- else
- img.fill(0);
- } else {
- img = QImage(w, h,
- m_hasAlpha
- ? QImage::Format_ARGB32_Premultiplied
- : QImage::Format_RGB32);
- img.fill(PREMUL(color.rgba()));
- }
- return img;
-}
-
-extern QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alpha);
-
-QImage QGLPixmapData::toImage() const
-{
- if (!isValid())
- return QImage();
-
- if (m_renderFbo) {
- copyBackFromRenderFbo(true);
- } else if (!m_source.isNull()) {
- // QVolatileImage::toImage() will make a copy always so no check
- // for active painting is needed.
- QImage img = m_source.toImage();
- if (img.format() == QImage::Format_MonoLSB) {
- img.setColorCount(2);
- img.setColor(0, QColor(Qt::color0).rgba());
- img.setColor(1, QColor(Qt::color1).rgba());
- }
- return img;
- } else if (m_dirty || m_hasFillColor) {
- return fillImage(m_fillColor);
- } else {
- ensureCreated();
- }
-
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- glBindTexture(GL_TEXTURE_2D, m_texture.id);
- return qt_gl_read_texture(QSize(w, h), true, true);
-}
-
-struct TextureBuffer
-{
- QGLFramebufferObject *fbo;
- QGL2PaintEngineEx *engine;
-};
-
-Q_GLOBAL_STATIC(QGLFramebufferObjectPool, _qgl_fbo_pool)
-QGLFramebufferObjectPool* qgl_fbo_pool()
-{
- return _qgl_fbo_pool();
-}
-
-void QGLPixmapData::copyBackFromRenderFbo(bool keepCurrentFboBound) const
-{
- if (!isValid())
- return;
-
- m_hasFillColor = false;
-
- const QGLContext *share_ctx = qt_gl_share_widget()->context();
- QGLShareContextScope ctx(share_ctx);
-
- ensureCreated();
-
- if (!ctx->d_ptr->fbo)
- glGenFramebuffers(1, &ctx->d_ptr->fbo);
-
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, ctx->d_ptr->fbo);
- glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, m_texture.id, 0);
-
- const int x0 = 0;
- const int x1 = w;
- const int y0 = 0;
- const int y1 = h;
-
- if (!m_renderFbo->isBound())
- glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, m_renderFbo->handle());
-
- glDisable(GL_SCISSOR_TEST);
-
- glBlitFramebufferEXT(x0, y0, x1, y1,
- x0, y0, x1, y1,
- GL_COLOR_BUFFER_BIT,
- GL_NEAREST);
-
- if (keepCurrentFboBound) {
- glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);
- } else {
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, m_renderFbo->handle());
- ctx->d_ptr->current_fbo = m_renderFbo->handle();
- }
-}
-
-bool QGLPixmapData::useFramebufferObjects() const
-{
-#ifdef Q_OS_SYMBIAN
- // We don't want to use FBOs on Symbian
- return false;
-#else
- return QGLFramebufferObject::hasOpenGLFramebufferObjects()
- && QGLFramebufferObject::hasOpenGLFramebufferBlit()
- && qt_gl_preferGL2Engine()
- && (w * h > 32*32); // avoid overhead of FBOs for small pixmaps
-#endif
-}
-
-QPaintEngine* QGLPixmapData::paintEngine() const
-{
- if (!isValid())
- return 0;
-
- if (m_renderFbo)
- return m_engine;
-
- if (useFramebufferObjects()) {
- extern QGLWidget* qt_gl_share_widget();
-
- if (!QGLContext::currentContext())
- qt_gl_share_widget()->makeCurrent();
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
-
- QGLFramebufferObjectFormat format;
- format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
- format.setSamples(4);
- format.setInternalTextureFormat(GLenum(m_hasAlpha ? GL_RGBA : GL_RGB));
-
- m_renderFbo = qgl_fbo_pool()->acquire(size(), format);
-
- if (m_renderFbo) {
- if (!m_engine)
- m_engine = new QGL2PaintEngineEx;
- return m_engine;
- }
-
- qWarning() << "Failed to create pixmap texture buffer of size " << size() << ", falling back to raster paint engine";
- }
-
- // If the application wants to paint into the QPixmap, we first
- // force it to QImage format and then paint into that.
- // This is simpler than juggling multiple GL contexts.
- const_cast<QGLPixmapData *>(this)->forceToImage();
-
- if (m_hasFillColor) {
- m_source.fill(PREMUL(m_fillColor.rgba()));
- m_hasFillColor = false;
- }
- return m_source.paintEngine();
-}
-
-extern QRgb qt_gl_convertToGLFormat(QRgb src_pixel, GLenum texture_format);
-
-// If copyBack is true, bind will copy the contents of the render
-// FBO to the texture (which is not bound to the texture, as it's
-// a multisample FBO).
-GLuint QGLPixmapData::bind(bool copyBack) const
-{
- if (m_renderFbo && copyBack) {
- copyBackFromRenderFbo(true);
- } else {
- ensureCreated();
- }
-
- GLuint id = m_texture.id;
- glBindTexture(GL_TEXTURE_2D, id);
-
- if (m_hasFillColor) {
- if (!useFramebufferObjects()) {
- m_source = QVolatileImage(w, h, QImage::Format_ARGB32_Premultiplied);
- m_source.fill(PREMUL(m_fillColor.rgba()));
- }
-
- m_hasFillColor = false;
-
- GLenum format = qt_gl_preferredTextureFormat();
- QImage tx(w, h, QImage::Format_ARGB32_Premultiplied);
- tx.fill(qt_gl_convertToGLFormat(m_fillColor.rgba(), format));
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, format, GL_UNSIGNED_BYTE, tx.constBits());
- }
-
- return id;
-}
-
-QGLTexture* QGLPixmapData::texture() const
-{
- return &m_texture;
-}
-
-void QGLPixmapData::detachTextureFromPool()
-{
- if (inTexturePool) {
- QGLTexturePool::instance()->detachTexture(this);
- inTexturePool = false;
- }
-}
-
-void QGLPixmapData::hibernate()
-{
- // If the image was imported (e.g, from an SgImage under Symbian), then
- // skip the hibernation, there is no sense in copying it back to main
- // memory because the data is most likely shared between several processes.
- bool skipHibernate = (m_texture.id && m_source.isNull());
-#if defined(Q_OS_SYMBIAN)
- // However we have to proceed normally if the image was retrieved via
- // a handle provider.
- skipHibernate &= !nativeImageHandleProvider;
-#endif
- if (skipHibernate)
- return;
-
- forceToImage();
- destroyTexture();
-}
-
-void QGLPixmapData::reclaimTexture()
-{
- if (!inTexturePool)
- return;
- forceToImage();
- destroyTexture();
-}
-
-int QGLPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
-{
- if (w == 0)
- return 0;
-
- switch (metric) {
- case QPaintDevice::PdmWidth:
- return w;
- case QPaintDevice::PdmHeight:
- return h;
- case QPaintDevice::PdmNumColors:
- return 0;
- case QPaintDevice::PdmDepth:
- return d;
- case QPaintDevice::PdmWidthMM:
- return qRound(w * 25.4 / qt_defaultDpiX());
- case QPaintDevice::PdmHeightMM:
- return qRound(h * 25.4 / qt_defaultDpiY());
- case QPaintDevice::PdmDpiX:
- case QPaintDevice::PdmPhysicalDpiX:
- return qt_defaultDpiX();
- case QPaintDevice::PdmDpiY:
- case QPaintDevice::PdmPhysicalDpiY:
- return qt_defaultDpiY();
- default:
- qWarning("QGLPixmapData::metric(): Invalid metric");
- return 0;
- }
-}
-
-// Force the pixmap data to be backed by some valid data.
-void QGLPixmapData::forceToImage()
-{
- if (!isValid())
- return;
-
- if (m_source.isNull()) {
- QImage::Format format = QImage::Format_ARGB32_Premultiplied;
- if (pixelType() == BitmapType)
- format = QImage::Format_MonoLSB;
- m_source = QVolatileImage(w, h, format);
- }
-
- m_dirty = true;
-}
-
-QGLPaintDevice *QGLPixmapData::glDevice() const
-{
- return &m_glDevice;
-}
-
-QT_END_NAMESPACE
diff --git a/src/opengl/qpixmapdata_x11gl_egl.cpp b/src/opengl/qpixmapdata_x11gl_egl.cpp
deleted file mode 100644
index 8a8eb38b7c..0000000000
--- a/src/opengl/qpixmapdata_x11gl_egl.cpp
+++ /dev/null
@@ -1,403 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDebug>
-
-#include <QtGui/private/qt_x11_p.h>
-#include <QtGui/private/qegl_p.h>
-#include <QtGui/private/qeglproperties_p.h>
-#include <QtGui/private/qeglcontext_p.h>
-
-#if !defined(QT_OPENGL_ES_1)
-#include <QtOpenGL/private/qpaintengineex_opengl2_p.h>
-#endif
-
-#ifndef QT_OPENGL_ES_2
-#include <QtOpenGL/private/qpaintengine_opengl_p.h>
-#endif
-
-#include <QtOpenGL/private/qgl_p.h>
-#include <QtOpenGL/private/qgl_egl_p.h>
-
-#include "qpixmapdata_x11gl_p.h"
-
-QT_BEGIN_NAMESPACE
-
-
-class QX11GLSharedContexts
-{
-public:
- QX11GLSharedContexts()
- : rgbContext(0)
- , argbContext(0)
- , sharedQGLContext(0)
- , sharePixmap(0)
- {
- EGLint rgbConfigId;
- EGLint argbConfigId;
-
- do {
- EGLConfig rgbConfig = QEgl::defaultConfig(QInternal::Pixmap, QEgl::OpenGL, QEgl::Renderable);
- EGLConfig argbConfig = QEgl::defaultConfig(QInternal::Pixmap, QEgl::OpenGL,
- QEgl::Renderable | QEgl::Translucent);
-
- eglGetConfigAttrib(QEgl::display(), rgbConfig, EGL_CONFIG_ID, &rgbConfigId);
- eglGetConfigAttrib(QEgl::display(), argbConfig, EGL_CONFIG_ID, &argbConfigId);
-
- rgbContext = new QEglContext;
- rgbContext->setConfig(rgbConfig);
- rgbContext->createContext();
-
- if (!rgbContext->isValid())
- break;
-
- // If the RGB & ARGB configs are the same, use the same egl context for both:
- if (rgbConfig == argbConfig)
- argbContext = rgbContext;
-
- // Otherwise, create a separate context to be used for ARGB pixmaps:
- if (!argbContext) {
- argbContext = new QEglContext;
- argbContext->setConfig(argbConfig);
- bool success = argbContext->createContext(rgbContext);
- if (!success) {
- qWarning("QX11GLPixmapData - RGB & ARGB contexts aren't shared");
- success = argbContext->createContext();
- if (!success)
- argbContext = rgbContext; // Might work, worth a shot at least.
- }
- }
-
- if (!argbContext->isValid())
- break;
-
- // Create the pixmap which will be used to create the egl surface for the share QGLContext
- QX11PixmapData *rgbPixmapData = new QX11PixmapData(QPixmapData::PixmapType);
- rgbPixmapData->resize(8, 8);
- rgbPixmapData->fill(Qt::red);
- sharePixmap = new QPixmap(rgbPixmapData);
- EGLSurface sharePixmapSurface = QEgl::createSurface(sharePixmap, rgbConfig);
- rgbPixmapData->gl_surface = (void*)sharePixmapSurface;
-
- // Create the actual QGLContext which will be used for sharing
- sharedQGLContext = new QGLContext(QX11GLPixmapData::glFormat());
- sharedQGLContext->d_func()->eglContext = rgbContext;
- sharedQGLContext->d_func()->eglSurface = sharePixmapSurface;
- sharedQGLContext->d_func()->valid = true;
- qt_glformat_from_eglconfig(sharedQGLContext->d_func()->glFormat, rgbConfig);
-
-
- valid = rgbContext->makeCurrent(sharePixmapSurface);
-
- // If the ARGB & RGB configs are different, check ARGB works too:
- if (argbConfig != rgbConfig) {
- QX11PixmapData *argbPixmapData = new QX11PixmapData(QPixmapData::PixmapType);
- argbPixmapData->resize(8, 8);
- argbPixmapData->fill(Qt::transparent); // Force ARGB
- QPixmap argbPixmap(argbPixmapData); // destroys pixmap data when goes out of scope
- EGLSurface argbPixmapSurface = QEgl::createSurface(&argbPixmap, argbConfig);
- valid = argbContext->makeCurrent(argbPixmapSurface);
- argbContext->doneCurrent();
- eglDestroySurface(QEgl::display(), argbPixmapSurface);
- argbPixmapData->gl_surface = 0;
- }
-
- if (!valid) {
- qWarning() << "Unable to make pixmap surface current:" << QEgl::errorString();
- break;
- }
-
- // The pixmap surface destruction hooks are installed by QGLTextureCache, so we
- // must make sure this is instanciated:
- QGLTextureCache::instance();
- } while(0);
-
- if (!valid)
- cleanup();
- else
- qDebug("Using QX11GLPixmapData with EGL config %d for ARGB and config %d for RGB", argbConfigId, rgbConfigId);
-
- }
-
- ~QX11GLSharedContexts() {
- cleanup();
- }
-
- void cleanup() {
- if (sharedQGLContext) {
- delete sharedQGLContext;
- sharedQGLContext = 0;
- }
- if (argbContext && argbContext != rgbContext)
- delete argbContext;
- argbContext = 0;
-
- if (rgbContext) {
- delete rgbContext;
- rgbContext = 0;
- }
-
- // Deleting the QPixmap will fire the pixmap destruction cleanup hooks which in turn
- // will destroy the egl surface:
- if (sharePixmap) {
- delete sharePixmap;
- sharePixmap = 0;
- }
- }
-
- bool isValid() { return valid;}
-
- // On 16bpp systems, RGB & ARGB pixmaps are different bit-depths and therefore need
- // different contexts:
- QEglContext *rgbContext;
- QEglContext *argbContext;
-
- // The share context wraps the rgbContext and is used as the master of the context share
- // group. As all other contexts will have the same egl context (or a shared one if rgb != argb)
- // all QGLContexts will actually be sharing and can be in the same context group.
- QGLContext *sharedQGLContext;
-private:
- QPixmap *sharePixmap;
- bool valid;
-};
-
-static void qt_cleanup_x11gl_share_contexts();
-
-Q_GLOBAL_STATIC_WITH_INITIALIZER(QX11GLSharedContexts, qt_x11gl_share_contexts,
- {
- qAddPostRoutine(qt_cleanup_x11gl_share_contexts);
- })
-
-static void qt_cleanup_x11gl_share_contexts()
-{
- qt_x11gl_share_contexts()->cleanup();
-}
-
-
-QX11GLSharedContexts* QX11GLPixmapData::sharedContexts()
-{
- return qt_x11gl_share_contexts();
-}
-
-bool QX11GLPixmapData::hasX11GLPixmaps()
-{
- static bool checkedForX11GLPixmaps = false;
- static bool haveX11GLPixmaps = false;
-
- if (checkedForX11GLPixmaps)
- return haveX11GLPixmaps;
-
- haveX11GLPixmaps = qt_x11gl_share_contexts()->isValid();
- checkedForX11GLPixmaps = true;
-
- return haveX11GLPixmaps;
-}
-
-QX11GLPixmapData::QX11GLPixmapData()
- : QX11PixmapData(QPixmapData::PixmapType),
- ctx(0)
-{
-}
-
-QX11GLPixmapData::~QX11GLPixmapData()
-{
- if (ctx)
- delete ctx;
-}
-
-
-void QX11GLPixmapData::fill(const QColor &color)
-{
- if (ctx) {
- ctx->makeCurrent();
- glFinish();
- eglWaitClient();
- }
-
- QX11PixmapData::fill(color);
- XSync(X11->display, False);
-
- if (ctx) {
- ctx->makeCurrent();
- eglWaitNative(EGL_CORE_NATIVE_ENGINE);
- }
-}
-
-void QX11GLPixmapData::copy(const QPixmapData *data, const QRect &rect)
-{
- if (ctx) {
- ctx->makeCurrent();
- glFinish();
- eglWaitClient();
- }
-
- QX11PixmapData::copy(data, rect);
- XSync(X11->display, False);
-
- if (ctx) {
- ctx->makeCurrent();
- eglWaitNative(EGL_CORE_NATIVE_ENGINE);
- }
-}
-
-bool QX11GLPixmapData::scroll(int dx, int dy, const QRect &rect)
-{
- if (ctx) {
- ctx->makeCurrent();
- glFinish();
- eglWaitClient();
- }
-
- bool success = QX11PixmapData::scroll(dx, dy, rect);
- XSync(X11->display, False);
-
- if (ctx) {
- ctx->makeCurrent();
- eglWaitNative(EGL_CORE_NATIVE_ENGINE);
- }
-
- return success;
-}
-
-#if !defined(QT_OPENGL_ES_1)
-Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_pixmap_2_engine)
-#endif
-
-#ifndef QT_OPENGL_ES_2
-Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_pixmap_engine)
-#endif
-
-
-QPaintEngine* QX11GLPixmapData::paintEngine() const
-{
- // We need to create the context before beginPaint - do it here:
- if (!ctx) {
- ctx = new QGLContext(glFormat());
- Q_ASSERT(ctx->d_func()->eglContext == 0);
- ctx->d_func()->eglContext = hasAlphaChannel() ? sharedContexts()->argbContext : sharedContexts()->rgbContext;
-
- // While we use a separate QGLContext for each pixmap, the underlying QEglContext is
- // the same. So we must use a "fake" QGLContext and fool the texture cache into thinking
- // each pixmap's QGLContext is sharing with this central one. The only place this is
- // going to fail is where we the underlying EGL RGB and ARGB contexts aren't sharing.
- ctx->d_func()->sharing = true;
- QGLContextGroup::addShare(ctx, sharedContexts()->sharedQGLContext);
-
- // Update the glFormat for the QGLContext:
- qt_glformat_from_eglconfig(ctx->d_func()->glFormat, ctx->d_func()->eglContext->config());
- }
-
- QPaintEngine* engine;
-
-#if defined(QT_OPENGL_ES_1)
- engine = qt_gl_pixmap_engine();
-#elif defined(QT_OPENGL_ES_2)
- engine = qt_gl_pixmap_2_engine();
-#else
- if (qt_gl_preferGL2Engine())
- engine = qt_gl_pixmap_2_engine();
- else
- engine = qt_gl_pixmap_engine();
-#endif
-
-
-
- // Support multiple painters on multiple pixmaps simultaniously
- if (engine->isActive()) {
- qWarning("Pixmap paint engine already active");
-
-#if defined(QT_OPENGL_ES_1)
- engine = new QOpenGLPaintEngine;
-#elif defined(QT_OPENGL_ES_2)
- engine = new QGL2PaintEngineEx;
-#else
- if (qt_gl_preferGL2Engine())
- engine = new QGL2PaintEngineEx;
- else
- engine = new QOpenGLPaintEngine;
-#endif
-
- engine->setAutoDestruct(true);
- return engine;
- }
-
- return engine;
-}
-
-void QX11GLPixmapData::beginPaint()
-{
-// qDebug("QX11GLPixmapData::beginPaint()");
- // TODO: Check to see if the surface is renderable
- if ((EGLSurface)gl_surface == EGL_NO_SURFACE) {
- QPixmap tmpPixmap(this);
- EGLConfig cfg = ctx->d_func()->eglContext->config();
- Q_ASSERT(cfg != QEGL_NO_CONFIG);
-
-// qDebug("QX11GLPixmapData - using EGL Config ID %d", ctx->d_func()->eglContext->configAttrib(EGL_CONFIG_ID));
- EGLSurface surface = QEgl::createSurface(&tmpPixmap, cfg);
- if (surface == EGL_NO_SURFACE) {
- qWarning() << "Error creating EGL surface for pixmap:" << QEgl::errorString();
- return;
- }
- gl_surface = (void*)surface;
- ctx->d_func()->eglSurface = surface;
- ctx->d_func()->valid = true;
- }
- QGLPaintDevice::beginPaint();
-}
-
-QGLContext* QX11GLPixmapData::context() const
-{
- return ctx;
-}
-
-QSize QX11GLPixmapData::size() const
-{
- return QSize(w, h);
-}
-
-
-QGLFormat QX11GLPixmapData::glFormat()
-{
- return QGLFormat::defaultFormat(); //###
-}
-
-QT_END_NAMESPACE
diff --git a/src/opengl/qpixmapdata_x11gl_p.h b/src/opengl/qpixmapdata_x11gl_p.h
deleted file mode 100644
index 0a6c4e8f2f..0000000000
--- a/src/opengl/qpixmapdata_x11gl_p.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPIXMAPDATA_X11GL_P_H
-#define QPIXMAPDATA_X11GL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qpixmapdata_p.h>
-#include <private/qpixmap_x11_p.h>
-#include <private/qglpaintdevice_p.h>
-
-#include <qgl.h>
-
-#ifndef QT_NO_EGL
-#include <QtGui/private/qeglcontext_p.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QX11GLSharedContexts;
-
-class QX11GLPixmapData : public QX11PixmapData, public QGLPaintDevice
-{
-public:
- QX11GLPixmapData();
- virtual ~QX11GLPixmapData();
-
- // Re-implemented from QX11PixmapData:
- void fill(const QColor &color);
- void copy(const QPixmapData *data, const QRect &rect);
- bool scroll(int dx, int dy, const QRect &rect);
-
- // Re-implemented from QGLPaintDevice
- QPaintEngine* paintEngine() const; // Also re-implements QX11PixmapData::paintEngine
- void beginPaint();
- QGLContext* context() const;
- QSize size() const;
-
- static bool hasX11GLPixmaps();
- static QGLFormat glFormat();
- static QX11GLSharedContexts* sharedContexts();
-
-private:
- mutable QGLContext* ctx;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QPIXMAPDATA_X11GL_P_H
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
deleted file mode 100644
index 4f00908b9d..0000000000
--- a/src/opengl/qwindowsurface_gl.cpp
+++ /dev/null
@@ -1,1174 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui/QApplication>
-#include <QtGui/QColormap>
-#include <QtGui/QDesktopWidget>
-#include <QtGui/QPaintDevice>
-#include <QtGui/QWidget>
-
-#include <qglframebufferobject.h>
-#include <qglpixelbuffer.h>
-#include <qcolormap.h>
-#include <qdesktopwidget.h>
-#include <private/qwidget_p.h>
-#include "qdebug.h"
-
-#ifdef Q_WS_X11
-#include <private/qt_x11_p.h>
-#include <qx11info_x11.h>
-
-#ifndef QT_OPENGL_ES
-#include <GL/glx.h>
-#include <X11/Xlib.h>
-#endif
-#endif //Q_WS_X11
-
-#include <private/qglextensions_p.h>
-#include <private/qwindowsurface_gl_p.h>
-
-#include <private/qgl_p.h>
-
-#include <private/qglpixelbuffer_p.h>
-#include <private/qgraphicssystem_gl_p.h>
-
-#include <private/qpaintengineex_opengl2_p.h>
-#include <private/qpixmapdata_gl_p.h>
-
-#ifndef QT_OPENGL_ES_2
-#include <private/qpaintengine_opengl_p.h>
-#endif
-
-#ifndef GLX_ARB_multisample
-#define GLX_SAMPLE_BUFFERS_ARB 100000
-#define GLX_SAMPLES_ARB 100001
-#endif
-
-#ifndef QT_NO_EGL
-#include <private/qeglcontext_p.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-//
-// QGLGraphicsSystem
-//
-#ifdef Q_WS_WIN
-extern Q_GUI_EXPORT bool qt_win_owndc_required;
-#endif
-QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL)
- : QGraphicsSystem(), m_useX11GL(useX11GL)
-{
-#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
- // only override the system defaults if the user hasn't already
- // picked a visual
- if (X11->visual == 0 && X11->visual_id == -1 && X11->visual_class == -1) {
- // find a double buffered, RGBA visual that supports OpenGL
- // and set that as the default visual for windows in Qt
- int i = 0;
- int spec[16];
- spec[i++] = GLX_RGBA;
- spec[i++] = GLX_DOUBLEBUFFER;
-
- if (!qgetenv("QT_GL_SWAPBUFFER_PRESERVE").isNull()) {
- spec[i++] = GLX_DEPTH_SIZE;
- spec[i++] = 8;
- spec[i++] = GLX_STENCIL_SIZE;
- spec[i++] = 8;
- spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
- spec[i++] = 1;
- spec[i++] = GLX_SAMPLES_ARB;
- spec[i++] = 4;
- }
-
- spec[i++] = XNone;
-
- XVisualInfo *vi = glXChooseVisual(X11->display, X11->defaultScreen, spec);
- if (vi) {
- X11->visual_id = vi->visualid;
- X11->visual_class = vi->c_class;
-
- QGLFormat format;
- int res;
- glXGetConfig(X11->display, vi, GLX_LEVEL, &res);
- format.setPlane(res);
- glXGetConfig(X11->display, vi, GLX_DOUBLEBUFFER, &res);
- format.setDoubleBuffer(res);
- glXGetConfig(X11->display, vi, GLX_DEPTH_SIZE, &res);
- format.setDepth(res);
- if (format.depth())
- format.setDepthBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_RGBA, &res);
- format.setRgba(res);
- glXGetConfig(X11->display, vi, GLX_RED_SIZE, &res);
- format.setRedBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_GREEN_SIZE, &res);
- format.setGreenBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_BLUE_SIZE, &res);
- format.setBlueBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_ALPHA_SIZE, &res);
- format.setAlpha(res);
- if (format.alpha())
- format.setAlphaBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_ACCUM_RED_SIZE, &res);
- format.setAccum(res);
- if (format.accum())
- format.setAccumBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_STENCIL_SIZE, &res);
- format.setStencil(res);
- if (format.stencil())
- format.setStencilBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_STEREO, &res);
- format.setStereo(res);
- glXGetConfig(X11->display, vi, GLX_SAMPLE_BUFFERS_ARB, &res);
- format.setSampleBuffers(res);
- if (format.sampleBuffers()) {
- glXGetConfig(X11->display, vi, GLX_SAMPLES_ARB, &res);
- format.setSamples(res);
- }
-
- QGLWindowSurface::surfaceFormat = format;
- XFree(vi);
-
- printf("using visual class %x, id %x\n", X11->visual_class, X11->visual_id);
- }
- }
-#elif defined(Q_WS_WIN)
- QGLWindowSurface::surfaceFormat.setDoubleBuffer(true);
-
- qt_win_owndc_required = true;
-#endif
-}
-
-static void qt_cleanup_gl_share_widget();
-
-//
-// QGLWindowSurface
-//
-class QGLGlobalShareWidget
-{
-public:
- QGLGlobalShareWidget() : firstPixmap(0), widgetRefCount(0), widget(0), initializing(false) {
- // ### FIXME - readd the post routine if the qApp is recreated
- qAddPostRoutine(qt_cleanup_gl_share_widget);
- created = true;
- }
-
- QGLWidget *shareWidget() {
- if (!initializing && !widget && !cleanedUp) {
- initializing = true;
- widget = new QGLWidget(QGLFormat(QGL::SingleBuffer | QGL::NoDepthBuffer | QGL::NoStencilBuffer));
- widget->resize(1, 1);
-
- // We don't need this internal widget to appear in QApplication::topLevelWidgets()
- if (QWidgetPrivate::allWidgets)
- QWidgetPrivate::allWidgets->remove(widget);
- initializing = false;
- }
- return widget;
- }
-
- // destroys the share widget and prevents recreation
- void cleanup() {
- QGLWidget *w = widget;
- cleanedUp = true;
- widget = 0;
- delete w;
- }
-
- // destroys the share widget, but allows it to be recreated later on
- void destroy() {
- if (cleanedUp)
- return;
-
- QGLWidget *w = widget;
-
- // prevent potential recursions
- cleanedUp = true;
- widget = 0;
- delete w;
- cleanedUp = false;
- }
-
- static bool cleanedUp;
- static bool created;
-
- QGLPixmapData *firstPixmap;
- int widgetRefCount;
-
-private:
- QGLWidget *widget;
- bool initializing;
-};
-
-bool QGLGlobalShareWidget::cleanedUp = false;
-bool QGLGlobalShareWidget::created = false;
-
-Q_GLOBAL_STATIC(QGLGlobalShareWidget, _qt_gl_share_widget)
-
-static void qt_cleanup_gl_share_widget()
-{
- if (QGLGlobalShareWidget::created)
- _qt_gl_share_widget()->cleanup();
-}
-
-QGLWidget* qt_gl_share_widget()
-{
- if (QGLGlobalShareWidget::cleanedUp)
- return 0;
- return _qt_gl_share_widget()->shareWidget();
-}
-
-void qt_destroy_gl_share_widget()
-{
- if (QGLGlobalShareWidget::created)
- _qt_gl_share_widget()->destroy();
-}
-
-const QGLContext *qt_gl_share_context()
-{
- QGLWidget *widget = qt_gl_share_widget();
- if (widget)
- return widget->context();
- return 0;
-}
-
-#ifdef QGL_USE_TEXTURE_POOL
-void qt_gl_register_pixmap(QGLPixmapData *pd)
-{
- QGLGlobalShareWidget *shared = _qt_gl_share_widget();
- pd->next = shared->firstPixmap;
- pd->prev = 0;
- if (shared->firstPixmap)
- shared->firstPixmap->prev = pd;
- shared->firstPixmap = pd;
-}
-
-void qt_gl_unregister_pixmap(QGLPixmapData *pd)
-{
- if (pd->next)
- pd->next->prev = pd->prev;
- if (pd->prev) {
- pd->prev->next = pd->next;
- } else {
- QGLGlobalShareWidget *shared = _qt_gl_share_widget();
- if (shared)
- shared->firstPixmap = pd->next;
- }
-}
-
-void qt_gl_hibernate_pixmaps()
-{
- QGLGlobalShareWidget *shared = _qt_gl_share_widget();
-
- // Scan all QGLPixmapData objects in the system and hibernate them.
- QGLPixmapData *pd = shared->firstPixmap;
- while (pd != 0) {
- pd->hibernate();
- pd = pd->next;
- }
-}
-#endif
-
-struct QGLWindowSurfacePrivate
-{
- QGLFramebufferObject *fbo;
- QGLPixelBuffer *pb;
- GLuint tex_id;
- GLuint pb_tex_id;
-
- int tried_fbo : 1;
- int tried_pb : 1;
- int destructive_swap_buffers : 1;
- int geometry_updated : 1;
- int did_paint : 1;
-
- QGLContext *ctx;
-
- QList<QGLContext **> contexts;
-
- QRegion paintedRegion;
- QSize size;
-
- QSize textureSize;
-
- QList<QImage> buffers;
- QGLWindowSurfaceGLPaintDevice glDevice;
- QGLWindowSurface* q_ptr;
-
- bool swap_region_support;
-};
-
-QGLFormat QGLWindowSurface::surfaceFormat;
-QGLWindowSurface::SwapMode QGLWindowSurface::swapBehavior = QGLWindowSurface::AutomaticSwap;
-
-void QGLWindowSurfaceGLPaintDevice::endPaint()
-{
- glFlush();
- QGLPaintDevice::endPaint();
-}
-
-QSize QGLWindowSurfaceGLPaintDevice::size() const
-{
- return d->size;
-}
-
-QGLContext* QGLWindowSurfaceGLPaintDevice::context() const
-{
- return d->ctx;
-}
-
-
-int QGLWindowSurfaceGLPaintDevice::metric(PaintDeviceMetric m) const
-{
- return qt_paint_device_metric(d->q_ptr->window(), m);
-}
-
-QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const
-{
- return qt_qgl_paint_engine();
-}
-
-QGLWindowSurface::QGLWindowSurface(QWidget *window)
- : QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate)
-{
-// Q_ASSERT(window->isTopLevel());
- d_ptr->pb = 0;
- d_ptr->fbo = 0;
- d_ptr->ctx = 0;
- d_ptr->tex_id = 0;
-#if defined (QT_OPENGL_ES_2)
- d_ptr->tried_fbo = true;
- d_ptr->tried_pb = true;
-#else
- d_ptr->tried_fbo = false;
- d_ptr->tried_pb = false;
-#endif
- d_ptr->destructive_swap_buffers = qgetenv("QT_GL_SWAPBUFFER_PRESERVE").isNull();
- d_ptr->glDevice.d = d_ptr;
- d_ptr->q_ptr = this;
- d_ptr->geometry_updated = false;
- d_ptr->did_paint = false;
- d_ptr->swap_region_support = false;
-}
-
-QGLWindowSurface::~QGLWindowSurface()
-{
- if (d_ptr->ctx)
- glDeleteTextures(1, &d_ptr->tex_id);
-#ifndef Q_WS_QPA // Dont delete the contexts. Destroying the window does that for us
- foreach(QGLContext **ctx, d_ptr->contexts) {
- delete *ctx;
- *ctx = 0;
- }
-#endif
- delete d_ptr->pb;
- delete d_ptr->fbo;
- delete d_ptr;
-
- if (QGLGlobalShareWidget::cleanedUp)
- return;
-
- --(_qt_gl_share_widget()->widgetRefCount);
-
-#ifdef QGL_USE_TEXTURE_POOL
- if (_qt_gl_share_widget()->widgetRefCount <= 0) {
- // All of the widget window surfaces have been destroyed
- // but we still have GL pixmaps active. Ask them to hibernate
- // to free up GPU resources until a widget is shown again.
- // This may eventually cause the EGLContext to be destroyed
- // because nothing in the system needs a context, which will
- // free up even more GPU resources.
- qt_gl_hibernate_pixmaps();
-
- // Destroy the context if necessary.
- if (!qt_gl_share_widget()->context()->isSharing())
- qt_destroy_gl_share_widget();
- }
-#endif // QGL_USE_TEXTURE_POOL
-}
-
-void QGLWindowSurface::deleted(QObject *object)
-{
- QWidget *widget = qobject_cast<QWidget *>(object);
- if (widget) {
- if (widget == window()) {
- // Make sure that the fbo is destroyed before destroying its context.
- delete d_ptr->fbo;
- d_ptr->fbo = 0;
- }
-
-#ifndef Q_WS_QPA //no need to specifically delete the QGLContext as it will be deleted by QWidget
- QWidgetPrivate *widgetPrivate = widget->d_func();
- if (widgetPrivate->extraData()) {
- union { QGLContext **ctxPtrPtr; void **voidPtrPtr; };
- voidPtrPtr = &widgetPrivate->extraData()->glContext;
- int index = d_ptr->contexts.indexOf(ctxPtrPtr);
- if (index != -1) {
- delete *ctxPtrPtr;
- *ctxPtrPtr = 0;
- d_ptr->contexts.removeAt(index);
- }
- }
-#endif
- }
-}
-
-void QGLWindowSurface::hijackWindow(QWidget *widget)
-{
- QWidgetPrivate *widgetPrivate = widget->d_func();
- widgetPrivate->createExtra();
- if (widgetPrivate->extraData()->glContext)
- return;
-
- QGLContext *ctx = NULL;
-
- // For translucent top-level widgets we need alpha in the format.
- if (widget->testAttribute(Qt::WA_TranslucentBackground)) {
- QGLFormat modFormat(surfaceFormat);
- modFormat.setSampleBuffers(false);
- modFormat.setSamples(0);
- modFormat.setAlpha(true);
- ctx = new QGLContext(modFormat, widget);
- } else
- ctx = new QGLContext(surfaceFormat, widget);
-
- ctx->create(qt_gl_share_context());
-
- if (widget != qt_gl_share_widget())
- ++(_qt_gl_share_widget()->widgetRefCount);
-
-#ifndef QT_NO_EGL
- static bool checkedForNOKSwapRegion = false;
- static bool haveNOKSwapRegion = false;
-
- if (!checkedForNOKSwapRegion) {
- haveNOKSwapRegion = QEgl::hasExtension("EGL_NOK_swap_region2");
- checkedForNOKSwapRegion = true;
-
- if (haveNOKSwapRegion)
- qDebug() << "Found EGL_NOK_swap_region2 extension. Using partial updates.";
- }
-
- d_ptr->destructive_swap_buffers = true;
- if (ctx->d_func()->eglContext->configAttrib(EGL_SURFACE_TYPE)&EGL_SWAP_BEHAVIOR_PRESERVED_BIT) {
- EGLint swapBehavior;
- if (eglQuerySurface(ctx->d_func()->eglContext->display(), ctx->d_func()->eglSurface
- , EGL_SWAP_BEHAVIOR, &swapBehavior)) {
- d_ptr->destructive_swap_buffers = (swapBehavior != EGL_BUFFER_PRESERVED);
- }
- }
-
- d_ptr->swap_region_support = haveNOKSwapRegion;
-#endif
-
- widgetPrivate->extraData()->glContext = ctx;
-
- union { QGLContext **ctxPtrPtr; void **voidPtrPtr; };
-
- connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(deleted(QObject*)));
-
- voidPtrPtr = &widgetPrivate->extraData()->glContext;
- d_ptr->contexts << ctxPtrPtr;
-#ifndef Q_OS_SYMBIAN
- qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size();
-#endif
-}
-
-QGLContext *QGLWindowSurface::context() const
-{
- return d_ptr->ctx;
-}
-
-QPaintDevice *QGLWindowSurface::paintDevice()
-{
- updateGeometry();
-
- if (d_ptr->pb)
- return d_ptr->pb;
-
- if (d_ptr->ctx)
- return &d_ptr->glDevice;
-
- QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext);
- ctx->makeCurrent();
-
- Q_ASSERT(d_ptr->fbo);
- return d_ptr->fbo;
-}
-
-static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, const QRectF &src = QRectF());
-
-void QGLWindowSurface::beginPaint(const QRegion &)
-{
- d_ptr->did_paint = true;
- updateGeometry();
-
- int clearFlags = 0;
-
- QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext);
-
- if (!ctx)
- return;
-
- if (ctx->d_func()->workaround_needsFullClearOnEveryFrame)
- clearFlags = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
- else if (ctx->format().alpha())
- clearFlags = GL_COLOR_BUFFER_BIT;
-
- if (clearFlags) {
- if (d_ptr->fbo)
- d_ptr->fbo->bind();
-
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glClear(clearFlags);
-
- if (d_ptr->fbo)
- d_ptr->fbo->release();
- }
-}
-
-void QGLWindowSurface::endPaint(const QRegion &rgn)
-{
- if (context())
- d_ptr->paintedRegion |= rgn;
-
- d_ptr->buffers.clear();
-}
-
-static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport, const QSize &texSize, const QRect &targetRect, const QRect &sourceRect)
-{
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_SCISSOR_TEST);
- glDisable(GL_BLEND);
-
- glViewport(0, 0, viewport.width(), viewport.height());
-
- QGLShaderProgram *blitProgram =
- QGLEngineSharedShaders::shadersForContext(ctx)->blitProgram();
- blitProgram->bind();
- blitProgram->setUniformValue("imageTexture", 0 /*QT_IMAGE_TEXTURE_UNIT*/);
-
- // The shader manager's blit program does not multiply the
- // vertices by the pmv matrix, so we need to do the effect
- // of the orthographic projection here ourselves.
- QRectF r;
- qreal w = viewport.width();
- qreal h = viewport.height();
- r.setLeft((targetRect.left() / w) * 2.0f - 1.0f);
- if (targetRect.right() == (viewport.width() - 1))
- r.setRight(1.0f);
- else
- r.setRight((targetRect.right() / w) * 2.0f - 1.0f);
- r.setBottom((targetRect.top() / h) * 2.0f - 1.0f);
- if (targetRect.bottom() == (viewport.height() - 1))
- r.setTop(1.0f);
- else
- r.setTop((targetRect.bottom() / w) * 2.0f - 1.0f);
-
- drawTexture(r, texture, texSize, sourceRect);
-}
-
-
-void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
-{
- //### Find out why d_ptr->geometry_updated isn't always false.
- // flush() should not be called when d_ptr->geometry_updated is true. It assumes that either
- // d_ptr->fbo or d_ptr->pb is allocated and has the correct size.
- if (d_ptr->geometry_updated)
- return;
-
- // did_paint is set to true in ::beginPaint. ::beginPaint means that we
- // at least cleared the background (= painted something). In EGL API it's a
- // mistake to call swapBuffers if nothing was painted unless
- // EGL_BUFFER_PRESERVED is set. This check protects the flush func from
- // being executed if it's for nothing.
- if (!d_ptr->destructive_swap_buffers && !d_ptr->did_paint)
- return;
-
-#ifdef Q_OS_SYMBIAN
- if (window() != widget) {
- // For performance reasons we don't support
- // flushing native child widgets on Symbian.
- // It breaks overlapping native child widget
- // rendering in some cases but we prefer performance.
- return;
- }
-#endif
-
-
- QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget();
- Q_ASSERT(parent);
-
-#if !defined(Q_WS_QPA)
- if (!geometry().isValid())
- return;
-#else
- if (!size().isValid())
- return;
-#endif
-
- // Needed to support native child-widgets...
- hijackWindow(parent);
-
- QRect br = rgn.boundingRect().translated(offset);
- br = br.intersected(window()->rect());
- QPoint wOffset = qt_qwidget_data(parent)->wrect.topLeft();
- QRect rect = br.translated(-offset - wOffset);
-
- const GLenum target = GL_TEXTURE_2D;
- Q_UNUSED(target);
-
- if (QGLWindowSurface::swapBehavior == QGLWindowSurface::KillSwap)
- return;
-
- if (context()) {
- context()->makeCurrent();
-
- if (context()->format().doubleBuffer()) {
-#if !defined(QT_OPENGL_ES_2)
- if (d_ptr->destructive_swap_buffers) {
- glBindTexture(target, d_ptr->tex_id);
-
- QVector<QRect> rects = d_ptr->paintedRegion.rects();
- for (int i = 0; i < rects.size(); ++i) {
- QRect br = rects.at(i);
- if (br.isEmpty())
- continue;
-
- const uint bottom = window()->height() - (br.y() + br.height());
- glCopyTexSubImage2D(target, 0, br.x(), bottom, br.x(), bottom, br.width(), br.height());
- }
-
- glBindTexture(target, 0);
-
- QRegion dirtyRegion = QRegion(window()->rect()) - d_ptr->paintedRegion;
-
- if (!dirtyRegion.isEmpty()) {
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-#ifndef QT_OPENGL_ES
- glOrtho(0, window()->width(), window()->height(), 0, -999999, 999999);
-#else
- glOrthof(0, window()->width(), window()->height(), 0, -999999, 999999);
-#endif
- glViewport(0, 0, window()->width(), window()->height());
-
- QVector<QRect> rects = dirtyRegion.rects();
- glColor4f(1, 1, 1, 1);
- for (int i = 0; i < rects.size(); ++i) {
- QRect rect = rects.at(i);
- if (rect.isEmpty())
- continue;
-
- drawTexture(rect, d_ptr->tex_id, window()->size(), rect);
- }
- }
- }
-#endif
- bool doingPartialUpdate = false;
- if (d_ptr->swap_region_support) {
- if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AutomaticSwap)
- doingPartialUpdate = br.width() * br.height() < parent->geometry().width() * parent->geometry().height() * 0.2;
- else if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AlwaysPartialSwap)
- doingPartialUpdate = true;
- }
-
- QGLContext *ctx = reinterpret_cast<QGLContext *>(parent->d_func()->extraData()->glContext);
- if (widget != window()) {
- if (initializeOffscreenTexture(window()->size()))
- qWarning() << "QGLWindowSurface: Flushing to native child widget, may lead to significant performance loss";
- glBindTexture(target, d_ptr->tex_id);
-
- const uint bottom = window()->height() - (br.y() + br.height());
- glCopyTexSubImage2D(target, 0, br.x(), bottom, br.x(), bottom, br.width(), br.height());
-
- glBindTexture(target, 0);
-
- ctx->makeCurrent();
- if (doingPartialUpdate)
- blitTexture(ctx, d_ptr->tex_id, parent->size(), window()->size(), rect, br);
- else
- blitTexture(ctx, d_ptr->tex_id, parent->size(), window()->size(), parent->rect(), parent->rect().translated(offset + wOffset));
- }
-
- if (doingPartialUpdate)
- ctx->d_func()->swapRegion(br);
- else
- ctx->swapBuffers();
-
- d_ptr->paintedRegion = QRegion();
- } else {
- glFlush();
- }
- return;
- }
-
- QGLContext *previous_ctx = const_cast<QGLContext *>(QGLContext::currentContext());
- QGLContext *ctx = reinterpret_cast<QGLContext *>(parent->d_func()->extraData()->glContext);
-
- // QPainter::end() should have unbound the fbo, otherwise something is very wrong...
- Q_ASSERT(!d_ptr->fbo || !d_ptr->fbo->isBound());
-
- if (ctx != previous_ctx) {
- ctx->makeCurrent();
- }
-
- QSize size = widget->rect().size();
- if (d_ptr->destructive_swap_buffers && ctx->format().doubleBuffer()) {
- rect = parent->rect();
- br = rect.translated(wOffset + offset);
- size = parent->size();
- }
-
- glDisable(GL_SCISSOR_TEST);
-
- if (d_ptr->fbo && (QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit)) {
- const int h = d_ptr->fbo->height();
-
- const int sx0 = br.left();
- const int sx1 = br.left() + br.width();
- const int sy0 = h - (br.top() + br.height());
- const int sy1 = h - br.top();
-
- const int tx0 = rect.left();
- const int tx1 = rect.left() + rect.width();
- const int ty0 = parent->height() - (rect.top() + rect.height());
- const int ty1 = parent->height() - rect.top();
-
- if (window() == parent || d_ptr->fbo->format().samples() <= 1) {
- if (ctx->d_ptr->current_fbo != 0)
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0);
-
- glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, d_ptr->fbo->handle());
-
- glBlitFramebufferEXT(sx0, sy0, sx1, sy1,
- tx0, ty0, tx1, ty1,
- GL_COLOR_BUFFER_BIT,
- GL_NEAREST);
-
- glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, 0);
- } else {
- // can't do sub-region blits with multisample FBOs
- QGLFramebufferObject *temp = qgl_fbo_pool()->acquire(d_ptr->fbo->size(), QGLFramebufferObjectFormat());
-
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, temp->handle());
- glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, d_ptr->fbo->handle());
-
- glBlitFramebufferEXT(0, 0, d_ptr->fbo->width(), d_ptr->fbo->height(),
- 0, 0, d_ptr->fbo->width(), d_ptr->fbo->height(),
- GL_COLOR_BUFFER_BIT,
- GL_NEAREST);
-
- glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, temp->handle());
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0);
-
- glBlitFramebufferEXT(sx0, sy0, sx1, sy1,
- tx0, ty0, tx1, ty1,
- GL_COLOR_BUFFER_BIT,
- GL_NEAREST);
-
- glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, 0);
-
- qgl_fbo_pool()->release(temp);
- }
-
- ctx->d_ptr->current_fbo = 0;
- }
-#if !defined(QT_OPENGL_ES_2)
- else {
- GLuint texture;
- if (d_ptr->fbo) {
- texture = d_ptr->fbo->texture();
- } else {
- d_ptr->pb->makeCurrent();
- glBindTexture(target, d_ptr->pb_tex_id);
- const uint bottom = window()->height() - (br.y() + br.height());
- glCopyTexSubImage2D(target, 0, br.x(), bottom, br.x(), bottom, br.width(), br.height());
- texture = d_ptr->pb_tex_id;
- glBindTexture(target, 0);
- }
-
- glDisable(GL_DEPTH_TEST);
-
- if (d_ptr->fbo) {
- d_ptr->fbo->release();
- } else {
- ctx->makeCurrent();
- }
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-#ifndef QT_OPENGL_ES
- glOrtho(0, size.width(), size.height(), 0, -999999, 999999);
-#else
- glOrthof(0, size.width(), size.height(), 0, -999999, 999999);
-#endif
- glViewport(0, 0, size.width(), size.height());
-
- glColor4f(1, 1, 1, 1);
- drawTexture(rect, texture, window()->size(), br);
-
- if (d_ptr->fbo)
- d_ptr->fbo->bind();
- }
-#else
- // OpenGL/ES 2.0 version of the fbo blit.
- else if (d_ptr->fbo) {
- Q_UNUSED(target);
-
- if (d_ptr->fbo->isBound())
- d_ptr->fbo->release();
-
- blitTexture(ctx, d_ptr->fbo->texture(), size, window()->size(), rect, br);
- }
-#endif
-
- if (ctx->format().doubleBuffer())
- ctx->swapBuffers();
- else
- glFlush();
-
- d_ptr->did_paint = false;
-}
-
-
-#if !defined(Q_WS_QPA)
-void QGLWindowSurface::setGeometry(const QRect &rect)
-{
- QWindowSurface::setGeometry(rect);
- d_ptr->geometry_updated = true;
-}
-#else
-void QGLWindowSurface::resize(const QSize &size)
-{
- QWindowSurface::resize(size);
- d_ptr->geometry_updated = true;
-}
-#endif
-
-void QGLWindowSurface::updateGeometry() {
- if (!d_ptr->geometry_updated)
- return;
- d_ptr->geometry_updated = false;
-
- bool hijack(true);
- QWidgetPrivate *wd = window()->d_func();
- if (wd->extraData() && wd->extraData()->glContext) {
-#ifdef Q_OS_SYMBIAN // Symbian needs to recreate the context when native window size changes
- if (d_ptr->size != geometry().size()) {
- if (window() != qt_gl_share_widget())
- --(_qt_gl_share_widget()->widgetRefCount);
-
- delete wd->extraData()->glContext;
- wd->extraData()->glContext = 0;
- d_ptr->ctx = 0;
- }
- else
-#endif
- {
- hijack = false; // we already have gl context for widget
- }
- }
-
- if (hijack)
- hijackWindow(window());
-
- QGLContext *ctx = reinterpret_cast<QGLContext *>(wd->extraData()->glContext);
-
-#ifdef Q_WS_MAC
- ctx->updatePaintDevice();
-#endif
-
- QSize surfSize = geometry().size();
-
- if (surfSize.width() <= 0 || surfSize.height() <= 0)
- return;
-
- if (d_ptr->size == surfSize)
- return;
-
- d_ptr->size = surfSize;
-
- if (d_ptr->ctx) {
-#ifndef QT_OPENGL_ES_2
- if (d_ptr->destructive_swap_buffers)
- initializeOffscreenTexture(surfSize);
-#endif
- return;
- }
-
- const GLenum target = GL_TEXTURE_2D;
- if (d_ptr->destructive_swap_buffers
- && (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject)
- && (d_ptr->fbo || !d_ptr->tried_fbo)
- && qt_gl_preferGL2Engine())
- {
- d_ptr->tried_fbo = true;
- ctx->d_ptr->internal_context = true;
- ctx->makeCurrent();
- delete d_ptr->fbo;
-
- QGLFramebufferObjectFormat format;
- format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
- format.setInternalTextureFormat(GLenum(GL_RGBA));
- format.setTextureTarget(target);
-
- if (QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit)
- format.setSamples(8);
-
- d_ptr->fbo = new QGLFramebufferObject(surfSize, format);
-
- if (d_ptr->fbo->isValid()) {
- qDebug() << "Created Window Surface FBO" << surfSize
- << "with samples" << d_ptr->fbo->format().samples();
- return;
- } else {
- qDebug() << "QGLWindowSurface: Failed to create valid FBO, falling back";
- delete d_ptr->fbo;
- d_ptr->fbo = 0;
- }
- }
-
-#if !defined(QT_OPENGL_ES_2) && !defined(Q_WS_QPA) //QPA doesn't support pixelbuffers
- if (d_ptr->destructive_swap_buffers && (d_ptr->pb || !d_ptr->tried_pb)) {
- d_ptr->tried_pb = true;
-
- if (d_ptr->pb) {
- d_ptr->pb->makeCurrent();
- glDeleteTextures(1, &d_ptr->pb_tex_id);
- }
-
- delete d_ptr->pb;
-
- d_ptr->pb = new QGLPixelBuffer(surfSize.width(), surfSize.height(),
- QGLFormat(QGL::SampleBuffers | QGL::StencilBuffer | QGL::DepthBuffer),
- qt_gl_share_widget());
-
- if (d_ptr->pb->isValid()) {
- qDebug() << "Created Window Surface Pixelbuffer, Sample buffers:" << d_ptr->pb->format().sampleBuffers();
- d_ptr->pb->makeCurrent();
-
- glGenTextures(1, &d_ptr->pb_tex_id);
- glBindTexture(target, d_ptr->pb_tex_id);
- glTexImage2D(target, 0, GL_RGBA, surfSize.width(), surfSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
-
- glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glBindTexture(target, 0);
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, d_ptr->pb->width(), d_ptr->pb->height(), 0, -999999, 999999);
-
- d_ptr->pb->d_ptr->qctx->d_func()->internal_context = true;
- return;
- } else {
- qDebug() << "QGLWindowSurface: Failed to create valid pixelbuffer, falling back";
- delete d_ptr->pb;
- d_ptr->pb = 0;
- }
- }
-#endif // !defined(QT_OPENGL_ES_2) !defined(Q_WS_QPA)
-
- ctx->makeCurrent();
-
-#ifndef QT_OPENGL_ES_2
- if (d_ptr->destructive_swap_buffers)
- initializeOffscreenTexture(surfSize);
-#endif
-#ifndef Q_OS_SYMBIAN
- qDebug() << "QGLWindowSurface: Using plain widget as window surface" << this;
-#endif
- d_ptr->ctx = ctx;
- d_ptr->ctx->d_ptr->internal_context = true;
-}
-
-bool QGLWindowSurface::initializeOffscreenTexture(const QSize &size)
-{
- if (size == d_ptr->textureSize)
- return false;
-
- glGenTextures(1, &d_ptr->tex_id);
- glBindTexture(GL_TEXTURE_2D, d_ptr->tex_id);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size.width(), size.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
-
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glBindTexture(GL_TEXTURE_2D, 0);
-
- d_ptr->textureSize = size;
- return true;
-}
-
-bool QGLWindowSurface::scroll(const QRegion &area, int dx, int dy)
-{
- // this code randomly fails currently for unknown reasons
- return false;
-
- if (!d_ptr->pb)
- return false;
-
- d_ptr->pb->makeCurrent();
-
- QRect br = area.boundingRect();
-
-#if 0
- // ## workaround driver issue (scrolling by these deltas is unbearably slow for some reason)
- // ## maybe we should use glCopyTexSubImage insteadk
- if (dx == 1 || dx == -1 || dy == 1 || dy == -1 || dy == 2)
- return false;
-
- glRasterPos2i(br.x() + dx, br.y() + br.height() + dy);
- glCopyPixels(br.x(), d_ptr->pb->height() - (br.y() + br.height()), br.width(), br.height(), GL_COLOR);
- return true;
-#endif
-
- const GLenum target = GL_TEXTURE_2D;
-
- glBindTexture(target, d_ptr->tex_id);
- glCopyTexImage2D(target, 0, GL_RGBA, br.x(), d_ptr->pb->height() - (br.y() + br.height()), br.width(), br.height(), 0);
- glBindTexture(target, 0);
-
- drawTexture(br.translated(dx, dy), d_ptr->tex_id, window()->size());
-
- return true;
-}
-
-static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, const QRectF &br)
-{
- const GLenum target = GL_TEXTURE_2D;
- QRectF src = br.isEmpty()
- ? QRectF(QPointF(), texSize)
- : QRectF(QPointF(br.x(), texSize.height() - br.bottom()), br.size());
-
- if (target == GL_TEXTURE_2D) {
- qreal width = texSize.width();
- qreal height = texSize.height();
-
- src.setLeft(src.left() / width);
- src.setRight(src.right() / width);
- src.setTop(src.top() / height);
- src.setBottom(src.bottom() / height);
- }
-
- const GLfloat tx1 = src.left();
- const GLfloat tx2 = src.right();
- const GLfloat ty1 = src.top();
- const GLfloat ty2 = src.bottom();
-
- GLfloat texCoordArray[4*2] = {
- tx1, ty2, tx2, ty2, tx2, ty1, tx1, ty1
- };
-
- GLfloat vertexArray[4*2];
- extern void qt_add_rect_to_array(const QRectF &r, GLfloat *array); // qpaintengine_opengl.cpp
- qt_add_rect_to_array(rect, vertexArray);
-
-#if !defined(QT_OPENGL_ES_2)
- glVertexPointer(2, GL_FLOAT, 0, vertexArray);
- glTexCoordPointer(2, GL_FLOAT, 0, texCoordArray);
-
- glBindTexture(target, tex_id);
- glEnable(target);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-
- glDisable(target);
- glBindTexture(target, 0);
-#else
- glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexArray);
- glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, texCoordArray);
-
- glBindTexture(target, tex_id);
-
- glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
- glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
- glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
-
- glBindTexture(target, 0);
-#endif
-}
-
-QImage *QGLWindowSurface::buffer(const QWidget *widget)
-{
- QImage image;
-
- if (d_ptr->pb)
- image = d_ptr->pb->toImage();
- else if (d_ptr->fbo)
- image = d_ptr->fbo->toImage();
-
- if (image.isNull())
- return 0;
-
- QRect rect = widget->rect();
- rect.translate(widget->mapTo(widget->window(), QPoint()));
-
- QImage subImage = image.copy(rect);
- d_ptr->buffers << subImage;
- return &d_ptr->buffers.last();
-}
-
-QWindowSurface::WindowSurfaceFeatures QGLWindowSurface::features() const
-{
- WindowSurfaceFeatures features = 0;
- if (!d_ptr->destructive_swap_buffers || d_ptr->swap_region_support)
- features |= PartialUpdates;
- if (!d_ptr->destructive_swap_buffers)
- features |= PreservedContents;
- return features;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h
deleted file mode 100644
index 91d1f9e245..0000000000
--- a/src/opengl/qwindowsurface_gl_p.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSURFACE_GL_P_H
-#define QWINDOWSURFACE_GL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qglobal.h>
-#include <qgl.h>
-#include <private/qwindowsurface_p.h>
-#include <private/qglpaintdevice_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QPaintDevice;
-class QPoint;
-class QRegion;
-class QWidget;
-struct QGLWindowSurfacePrivate;
-
-Q_OPENGL_EXPORT QGLWidget* qt_gl_share_widget();
-Q_OPENGL_EXPORT void qt_destroy_gl_share_widget();
-
-class QGLWindowSurfaceGLPaintDevice : public QGLPaintDevice
-{
-public:
- QPaintEngine* paintEngine() const;
- void endPaint();
- QSize size() const;
- int metric(PaintDeviceMetric m) const;
- QGLContext* context() const;
- QGLWindowSurfacePrivate* d;
-};
-
-class Q_OPENGL_EXPORT QGLWindowSurface : public QObject, public QWindowSurface // , public QPaintDevice
-{
- Q_OBJECT
-public:
- QGLWindowSurface(QWidget *window);
- ~QGLWindowSurface();
-
- QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
-
-#if !defined(Q_WS_QPA)
- void setGeometry(const QRect &rect);
-#else
- virtual void resize(const QSize &size);
-#endif
-
- void updateGeometry();
- bool scroll(const QRegion &area, int dx, int dy);
-
- void beginPaint(const QRegion &region);
- void endPaint(const QRegion &region);
-
- QImage *buffer(const QWidget *widget);
-
- WindowSurfaceFeatures features() const;
-
- QGLContext *context() const;
-
- static QGLFormat surfaceFormat;
-
- enum SwapMode { AutomaticSwap, AlwaysFullSwap, AlwaysPartialSwap, KillSwap };
- static SwapMode swapBehavior;
-
-private slots:
- void deleted(QObject *object);
-
-private:
- void hijackWindow(QWidget *widget);
- bool initializeOffscreenTexture(const QSize &size);
-
- QGLWindowSurfacePrivate *d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSURFACE_GL_P_H
-
diff --git a/src/opengl/qwindowsurface_x11gl.cpp b/src/opengl/qwindowsurface_x11gl.cpp
deleted file mode 100644
index bec0ea7587..0000000000
--- a/src/opengl/qwindowsurface_x11gl.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QTime>
-#include <QDebug>
-
-#include <private/qt_x11_p.h>
-#include <private/qimagepixmapcleanuphooks_p.h>
-
-#include "qwindowsurface_x11gl_p.h"
-#include "qpixmapdata_x11gl_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QX11GLWindowSurface::QX11GLWindowSurface(QWidget* window)
- : QWindowSurface(window), m_windowGC(0), m_pixmapGC(0), m_window(window)
-{
-}
-
-QX11GLWindowSurface::~QX11GLWindowSurface()
-{
- if (m_windowGC)
- XFree(m_windowGC);
- if (m_pixmapGC)
- XFree(m_pixmapGC);
-}
-
-QPaintDevice *QX11GLWindowSurface::paintDevice()
-{
- return &m_backBuffer;
-}
-
-extern void *qt_getClipRects(const QRegion &r, int &num); // in qpaintengine_x11.cpp
-
-void QX11GLWindowSurface::flush(QWidget *widget, const QRegion &widgetRegion, const QPoint &offset)
-{
- // We don't need to know the widget which initiated the flush. Instead we just use the offset
- // to translate the widgetRegion:
- Q_UNUSED(widget);
-
- if (m_backBuffer.isNull()) {
- qDebug("QX11GLWindowSurface::flush() - backBuffer is null, not flushing anything");
- return;
- }
-
- Q_ASSERT(window()->size() != m_backBuffer.size());
-
- // Wait for all GL rendering to the back buffer pixmap to complete before trying to
- // copy it to the window. We do this by making sure the pixmap's context is current
- // and then call eglWaitClient. The EGL 1.4 spec says eglWaitClient doesn't have to
- // block, just that "All rendering calls...are guaranteed to be executed before native
- // rendering calls". This makes it potentially less expensive than glFinish.
- QGLContext* ctx = static_cast<QX11GLPixmapData*>(m_backBuffer.data_ptr().data())->context();
- if (QGLContext::currentContext() != ctx && ctx && ctx->isValid())
- ctx->makeCurrent();
- eglWaitClient();
-
- if (m_windowGC == 0) {
- XGCValues attribs;
- attribs.graphics_exposures = False;
- m_windowGC = XCreateGC(X11->display, m_window->handle(), GCGraphicsExposures, &attribs);
- }
-
- int rectCount;
- XRectangle *rects = (XRectangle *)qt_getClipRects(widgetRegion, rectCount);
- if (rectCount <= 0)
- return;
-
- XSetClipRectangles(X11->display, m_windowGC, 0, 0, rects, rectCount, YXBanded);
-
- QRect dirtyRect = widgetRegion.boundingRect().translated(-offset);
- XCopyArea(X11->display, m_backBuffer.handle(), m_window->handle(), m_windowGC,
- dirtyRect.x(), dirtyRect.y(), dirtyRect.width(), dirtyRect.height(),
- dirtyRect.x(), dirtyRect.y());
-
- // Make sure the blit of the update from the back buffer to the window completes
- // before allowing rendering to start again to the back buffer. Otherwise the GPU
- // might start rendering to the back buffer again while the blit takes place.
- eglWaitNative(EGL_CORE_NATIVE_ENGINE);
-}
-
-void QX11GLWindowSurface::setGeometry(const QRect &rect)
-{
- if (rect.width() > m_backBuffer.size().width() || rect.height() > m_backBuffer.size().height()) {
- QX11GLPixmapData *pd = new QX11GLPixmapData;
- QSize newSize = rect.size();
- pd->resize(newSize.width(), newSize.height());
- m_backBuffer = QPixmap(pd);
- if (window()->testAttribute(Qt::WA_TranslucentBackground))
- m_backBuffer.fill(Qt::transparent);
- if (m_pixmapGC) {
- XFreeGC(X11->display, m_pixmapGC);
- m_pixmapGC = 0;
- }
- }
-
- QWindowSurface::setGeometry(rect);
-}
-
-bool QX11GLWindowSurface::scroll(const QRegion &area, int dx, int dy)
-{
- if (m_backBuffer.isNull())
- return false;
-
- Q_ASSERT(m_backBuffer.data_ptr()->classId() == QPixmapData::X11Class);
-
- // Make sure all GL rendering is complete before starting the scroll operation:
- QGLContext* ctx = static_cast<QX11GLPixmapData*>(m_backBuffer.data_ptr().data())->context();
- if (QGLContext::currentContext() != ctx && ctx && ctx->isValid())
- ctx->makeCurrent();
- eglWaitClient();
-
- if (!m_pixmapGC)
- m_pixmapGC = XCreateGC(X11->display, m_backBuffer.handle(), 0, 0);
-
- foreach (const QRect& rect, area.rects()) {
- XCopyArea(X11->display, m_backBuffer.handle(), m_backBuffer.handle(), m_pixmapGC,
- rect.x(), rect.y(), rect.width(), rect.height(),
- rect.x()+dx, rect.y()+dy);
- }
-
- // Make sure the scroll operation is complete before allowing GL rendering to resume
- eglWaitNative(EGL_CORE_NATIVE_ENGINE);
-
- return true;
-}
-
-
-QPixmap QX11GLWindowSurface::grabWidget(const QWidget *widget, const QRect& rect) const
-{
- if (!widget || m_backBuffer.isNull())
- return QPixmap();
-
- QRect srcRect;
-
- // make sure the rect is inside the widget & clip to widget's rect
- if (!rect.isEmpty())
- srcRect = rect & widget->rect();
- else
- srcRect = widget->rect();
-
- if (srcRect.isEmpty())
- return QPixmap();
-
- // If it's a child widget we have to translate the coordinates
- if (widget != window())
- srcRect.translate(widget->mapTo(window(), QPoint(0, 0)));
-
- QPixmap::x11SetDefaultScreen(widget->x11Info().screen());
-
- QX11PixmapData *pmd = new QX11PixmapData(QPixmapData::PixmapType);
- pmd->resize(srcRect.width(), srcRect.height());
- QPixmap px(pmd);
-
- GC tmpGc = XCreateGC(X11->display, m_backBuffer.handle(), 0, 0);
-
- // Make sure all GL rendering is complete before copying the window
- QGLContext* ctx = static_cast<QX11GLPixmapData*>(m_backBuffer.pixmapData())->context();
- if (QGLContext::currentContext() != ctx && ctx && ctx->isValid())
- ctx->makeCurrent();
- eglWaitClient();
-
- // Copy srcRect from the backing store to the new pixmap
- XSetGraphicsExposures(X11->display, tmpGc, False);
- XCopyArea(X11->display, m_backBuffer.handle(), px.handle(), tmpGc,
- srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height(), 0, 0);
- XFreeGC(X11->display, tmpGc);
-
- // Wait until the copy has finised before allowing more rendering into the back buffer
- eglWaitNative(EGL_CORE_NATIVE_ENGINE);
-
- return px;
-}
-
-QT_END_NAMESPACE
diff --git a/src/opengl/qwindowsurface_x11gl_p.h b/src/opengl/qwindowsurface_x11gl_p.h
deleted file mode 100644
index 737997b879..0000000000
--- a/src/opengl/qwindowsurface_x11gl_p.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSURFACE_X11GL_P_H
-#define QWINDOWSURFACE_X11GL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qwindowsurface_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QX11GLWindowSurface : public QWindowSurface
-{
-public:
- QX11GLWindowSurface(QWidget* window);
- virtual ~QX11GLWindowSurface();
-
- // Inherreted from QWindowSurface
- QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- void setGeometry(const QRect &rect);
- bool scroll(const QRegion &area, int dx, int dy);
- QPixmap grabWidget(const QWidget *widget, const QRect& rectangle = QRect()) const;
-
-private:
- GC m_windowGC;
- GC m_pixmapGC;
- QPixmap m_backBuffer;
- QWidget *m_window;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSURFACE_X11GL_P_H