summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp25
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h3
-rw-r--r--src/opengl/opengl.pro4
-rw-r--r--src/opengl/qgl.cpp23
-rw-r--r--src/opengl/qgl_p.h4
-rw-r--r--src/opengl/qgl_qws.cpp3
-rw-r--r--src/opengl/qglframebufferobject.cpp4
-rw-r--r--src/opengl/qglframebufferobject_p.h2
-rw-r--r--src/opengl/qglpaintdevice_p.h2
-rw-r--r--src/opengl/qglpaintdevice_qws.cpp96
-rw-r--r--src/opengl/qglpaintdevice_qws_p.h86
-rw-r--r--src/opengl/qglwindowsurface_qws.cpp1
-rw-r--r--src/opengl/qpaintengine_opengl.cpp1
-rw-r--r--src/opengl/qwindowsurface_gl.cpp14
14 files changed, 34 insertions, 234 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index d7ce604..13efbda 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1625,7 +1625,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
const QSize sz = d->device->size();
d->width = sz.width();
d->height = sz.height();
- d->last_created_state = 0;
d->mode = BrushDrawingMode;
d->brushTextureDirty = true;
d->brushUniformsDirty = true;
@@ -2023,27 +2022,32 @@ void QGL2PaintEngineEx::setState(QPainterState *new_state)
QPaintEngineEx::setState(s);
- if (s == d->last_created_state) {
- d->last_created_state = 0;
+ if (s->isNew) {
+ // Newly created state object. The call to setState()
+ // will either be followed by a call to begin(), or we are
+ // setting the state as part of a save().
+ s->isNew = false;
return;
}
- if (old_state == s || s->renderHintsChanged)
+ // Setting the state as part of a restore().
+
+ if (old_state == s || old_state->renderHintsChanged)
renderHintsChanged();
- if (old_state == s || s->matrixChanged) {
+ if (old_state == s || old_state->matrixChanged) {
d->matrixDirty = true;
d->simpleShaderMatrixUniformDirty = true;
d->shaderMatrixUniformDirty = true;
}
- if (old_state == s || s->compositionModeChanged)
+ if (old_state == s || old_state->compositionModeChanged)
d->compositionModeDirty = true;
- if (old_state == s || s->opacityChanged)
+ if (old_state == s || old_state->opacityChanged)
d->opacityUniformDirty = true;
- if (old_state == s || s->clipChanged) {
+ if (old_state == s || old_state->clipChanged) {
if (old_state && old_state != s && old_state->canRestoreClip) {
d->updateClipScissorTest();
glDepthFunc(GL_LEQUAL);
@@ -2055,8 +2059,6 @@ void QGL2PaintEngineEx::setState(QPainterState *new_state)
QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const
{
- Q_D(const QGL2PaintEngineEx);
-
if (orig)
const_cast<QGL2PaintEngineEx *>(this)->ensureActive();
@@ -2072,7 +2074,6 @@ QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const
s->renderHintsChanged = false;
s->clipChanged = false;
- d->last_created_state = s;
return s;
}
@@ -2085,6 +2086,7 @@ void QGL2PaintEngineEx::setRenderTextActive(bool active)
QOpenGL2PaintEngineState::QOpenGL2PaintEngineState(QOpenGL2PaintEngineState &other)
: QPainterState(other)
{
+ isNew = true;
needsClipBufferClear = other.needsClipBufferClear;
clipTestEnabled = other.clipTestEnabled;
currentClip = other.currentClip;
@@ -2094,6 +2096,7 @@ QOpenGL2PaintEngineState::QOpenGL2PaintEngineState(QOpenGL2PaintEngineState &oth
QOpenGL2PaintEngineState::QOpenGL2PaintEngineState()
{
+ isNew = true;
needsClipBufferClear = true;
clipTestEnabled = false;
canRestoreClip = true;
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index 46be398..5704a04 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -82,6 +82,7 @@ public:
QOpenGL2PaintEngineState();
~QOpenGL2PaintEngineState();
+ uint isNew : 1;
uint needsClipBufferClear : 1;
uint clipTestEnabled : 1;
uint canRestoreClip : 1;
@@ -212,8 +213,6 @@ public:
EngineMode mode;
QFontEngineGlyphCache::Type glyphCacheType;
- mutable QOpenGL2PaintEngineState *last_created_state;
-
// Dirty flags
bool matrixDirty; // Implies matrix uniforms are also dirty
bool compositionModeDirty;
diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro
index d434725..e561932 100644
--- a/src/opengl/opengl.pro
+++ b/src/opengl/opengl.pro
@@ -126,14 +126,12 @@ wince*: {
embedded {
SOURCES += qgl_qws.cpp \
- qglpaintdevice_qws.cpp \
qglpixelbuffer_egl.cpp \
qglscreen_qws.cpp \
qglwindowsurface_qws.cpp \
qgl_egl.cpp
- HEADERS += qglpaintdevice_qws_p.h \
- qglscreen_qws.h \
+ HEADERS += qglscreen_qws.h \
qglwindowsurface_qws_p.h \
qgl_egl_p.h
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index a8b136d..39f04d4 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -76,7 +76,6 @@
#endif
#ifdef Q_WS_QWS
-#include <private/qglpaintdevice_qws_p.h>
#include <private/qglwindowsurface_qws_p.h>
#endif
@@ -4743,16 +4742,19 @@ Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_2_engine)
Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_engine)
#endif
-#ifdef Q_WS_QWS
Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine()
{
-#if !defined(QT_OPENGL_ES_2)
+#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL)
return qt_gl_engine();
+#elif defined(QT_OPENGL_ES_2)
+ return qt_gl_2_engine();
#else
- return 0; // XXX
+ if (qt_gl_preferGL2Engine())
+ return qt_gl_2_engine();
+ else
+ return qt_gl_engine();
#endif
}
-#endif
/*!
\internal
@@ -4762,16 +4764,7 @@ Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine()
*/
QPaintEngine *QGLWidget::paintEngine() const
{
-#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL)
- return qt_gl_engine();
-#elif defined(QT_OPENGL_ES_2)
- return qt_gl_2_engine();
-#else
- if (qt_gl_preferGL2Engine())
- return qt_gl_2_engine();
- else
- return qt_gl_engine();
-#endif
+ return qt_qgl_paint_engine();
}
#ifdef QT3_SUPPORT
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 8d4f673..129e7f7 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -505,9 +505,7 @@ private:
};
-#ifdef Q_WS_QWS
-extern QPaintEngine* qt_qgl_paint_engine();
-#endif
+extern Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine();
bool qt_gl_preferGL2Engine();
diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp
index bb23ace..5e59975 100644
--- a/src/opengl/qgl_qws.cpp
+++ b/src/opengl/qgl_qws.cpp
@@ -73,7 +73,8 @@ static QGLScreen *glScreenForDevice(QPaintDevice *device)
screenNumber = 0;
screen = screen->subScreens()[screenNumber];
}
- while (screen->classId() == QScreen::ProxyClass) {
+ while (screen->classId() == QScreen::ProxyClass ||
+ screen->classId() == QScreen::TransformedClass) {
screen = static_cast<QProxyScreen *>(screen)->screen();
}
if (screen->classId() == QScreen::GLClass)
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index 4fb8629..7374594 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -468,6 +468,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz,
QT_CHECK_GLERROR();
valid = checkFramebufferStatus();
+ glBindTexture(target, 0);
color_buffer = 0;
} else {
@@ -836,7 +837,8 @@ QGLFramebufferObject::~QGLFramebufferObject()
if (isValid() && ctx) {
QGLShareContextScope scope(ctx);
- glDeleteTextures(1, &d->texture);
+ if (d->texture)
+ glDeleteTextures(1, &d->texture);
if (d->color_buffer)
glDeleteRenderbuffers(1, &d->color_buffer);
if (d->depth_stencil_buffer)
diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h
index 43d4a41..122c42e 100644
--- a/src/opengl/qglframebufferobject_p.h
+++ b/src/opengl/qglframebufferobject_p.h
@@ -127,7 +127,7 @@ private:
class QGLFramebufferObjectPrivate
{
public:
- QGLFramebufferObjectPrivate() : fbo_guard(0), depth_stencil_buffer(0), valid(false), previous_fbo(0), engine(0) {}
+ QGLFramebufferObjectPrivate() : fbo_guard(0), texture(0), depth_stencil_buffer(0), color_buffer(0), valid(false), previous_fbo(0), engine(0) {}
~QGLFramebufferObjectPrivate() {}
void init(QGLFramebufferObject *q, const QSize& sz,
diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h
index 1e7ba8d..63ba5da 100644
--- a/src/opengl/qglpaintdevice_p.h
+++ b/src/opengl/qglpaintdevice_p.h
@@ -60,7 +60,7 @@
QT_BEGIN_NAMESPACE
-class QGLPaintDevice : public QPaintDevice
+class Q_OPENGL_EXPORT QGLPaintDevice : public QPaintDevice
{
public:
QGLPaintDevice();
diff --git a/src/opengl/qglpaintdevice_qws.cpp b/src/opengl/qglpaintdevice_qws.cpp
deleted file mode 100644
index 600efa6..0000000
--- a/src/opengl/qglpaintdevice_qws.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 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$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qglpaintdevice_qws_p.h>
-#include <private/qgl_p.h>
-#include <private/qpaintengine_opengl_p.h>
-#include <private/qglwindowsurface_qws_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWSGLPaintDevicePrivate
-{
-public:
- QWidget *widget;
-};
-
-class QMetricAccessor : public QWidget {
-public:
- int metric(PaintDeviceMetric m) {
- return QWidget::metric(m);
- }
-};
-
-QWSGLPaintDevice::QWSGLPaintDevice(QWidget *widget) :
- d_ptr(new QWSGLPaintDevicePrivate)
-{
- Q_D(QWSGLPaintDevice);
- d->widget = widget;
-}
-
-QWSGLPaintDevice::~QWSGLPaintDevice()
-{
-}
-
-QPaintEngine* QWSGLPaintDevice::paintEngine() const
-{
-#if !defined(QT_OPENGL_ES_2)
- return qt_qgl_paint_engine();
-#else
- return 0; // XXX
-#endif
-}
-
-int QWSGLPaintDevice::metric(PaintDeviceMetric m) const
-{
- Q_D(const QWSGLPaintDevice);
- Q_ASSERT(d->widget);
-
- return ((QMetricAccessor *) d->widget)->metric(m);
-}
-
-QWSGLWindowSurface* QWSGLPaintDevice::windowSurface() const
-{
- Q_D(const QWSGLPaintDevice);
- return static_cast<QWSGLWindowSurface*>(d->widget->windowSurface());
-}
-
-QT_END_NAMESPACE
diff --git a/src/opengl/qglpaintdevice_qws_p.h b/src/opengl/qglpaintdevice_qws_p.h
deleted file mode 100644
index 6dc9d31..0000000
--- a/src/opengl/qglpaintdevice_qws_p.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 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$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSGLPAINTDEVICE_GL_P_H
-#define QWSGLPAINTDEVICE_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 QGLWindowSurface class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qscopedpointer.h>
-#include <QPaintDevice>
-
-QT_BEGIN_NAMESPACE
-
-class QWidget;
-class QWSGLWindowSurface;
-class QWSGLPaintDevicePrivate;
-
-class Q_OPENGL_EXPORT QWSGLPaintDevice : public QPaintDevice
-{
- Q_DECLARE_PRIVATE(QWSGLPaintDevice)
-public:
- QWSGLPaintDevice(QWidget *widget);
- ~QWSGLPaintDevice();
-
- QPaintEngine *paintEngine() const;
-
- int metric(PaintDeviceMetric m) const;
-
- QWSGLWindowSurface *windowSurface() const;
-
-private:
- friend class QWSGLWindowSurface;
- QScopedPointer<QWSGLPaintDevicePrivate> d_ptr;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QWSGLPAINTDEVICE_GL_P_H
diff --git a/src/opengl/qglwindowsurface_qws.cpp b/src/opengl/qglwindowsurface_qws.cpp
index 6bf3257..5041cb9 100644
--- a/src/opengl/qglwindowsurface_qws.cpp
+++ b/src/opengl/qglwindowsurface_qws.cpp
@@ -43,7 +43,6 @@
#include <QtGui/QWidget>
#include <QtOpenGL/QGLWidget>
#include "private/qglwindowsurface_qws_p.h"
-#include "private/qglpaintdevice_qws_p.h"
#include "private/qpaintengine_opengl_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index 1a586d3..80628a2 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -66,7 +66,6 @@
#include "util/fragmentprograms_p.h"
#ifdef Q_WS_QWS
-#include "private/qglpaintdevice_qws_p.h"
#include "private/qglwindowsurface_qws_p.h"
#include "qwsmanager_qws.h"
#include "private/qwsmanager_p.h"
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index e6afed8..2816eca 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -280,22 +280,12 @@ QGLContext* QGLWindowSurfaceGLPaintDevice::context() const
int QGLWindowSurfaceGLPaintDevice::metric(PaintDeviceMetric m) const
{
- return d->q_ptr->window()->metric(m);
+ return qt_paint_device_metric(d->q_ptr->window(), m);
}
-Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_window_surface_2_engine)
-
-#if !defined (QT_OPENGL_ES_2)
-Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_window_surface_engine)
-#endif
-
QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const
{
-#if !defined(QT_OPENGL_ES_2)
- if (!qt_gl_preferGL2Engine())
- return qt_gl_window_surface_engine();
-#endif
- return qt_gl_window_surface_2_engine();
+ return qt_qgl_paint_engine();
}
QGLWindowSurface::QGLWindowSurface(QWidget *window)