summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-20 19:12:23 +0200
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-20 19:12:25 +0200
commit3361fcbc28be96262d22fd2b024c85fbcbc61462 (patch)
tree48976f337b3885971dc1976b9a27cec5e7dfa2ec /src/gui/opengl
parentdc612acdc6577594c8f61345cea2de549d7aae34 (diff)
parent5e342f6f041208d142d97202f61179d7163eb773 (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Diffstat (limited to 'src/gui/opengl')
-rw-r--r--src/gui/opengl/opengl.pri1
-rw-r--r--src/gui/opengl/qopenglpaintdevice.cpp31
-rw-r--r--src/gui/opengl/qopenglpaintdevice.h2
-rw-r--r--src/gui/opengl/qopenglpaintdevice_p.h81
-rw-r--r--src/gui/opengl/qopenglpaintengine.cpp5
5 files changed, 101 insertions, 19 deletions
diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri
index f82401c973..adf5428c49 100644
--- a/src/gui/opengl/opengl.pri
+++ b/src/gui/opengl/opengl.pri
@@ -11,6 +11,7 @@ contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles2) {
opengl/qopenglframebufferobject.h \
opengl/qopenglframebufferobject_p.h \
opengl/qopenglpaintdevice.h \
+ opengl/qopenglpaintdevice_p.h \
opengl/qopenglbuffer.h \
opengl/qopenglshaderprogram.h \
opengl/qopenglextensions_p.h \
diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp
index 59bca6efdf..e908fd8e91 100644
--- a/src/gui/opengl/qopenglpaintdevice.cpp
+++ b/src/gui/opengl/qopenglpaintdevice.cpp
@@ -35,6 +35,7 @@
#include <qpaintengine.h>
#include <qthreadstorage.h>
+#include <private/qopenglpaintdevice_p.h>
#include <private/qobject_p.h>
#include <private/qopenglcontext_p.h>
#include <private/qopenglframebufferobject_p.h>
@@ -98,23 +99,6 @@ QT_BEGIN_NAMESPACE
*/
-class QOpenGLPaintDevicePrivate
-{
-public:
- QOpenGLPaintDevicePrivate(const QSize &size);
-
- QSize size;
- QOpenGLContext *ctx;
-
- qreal dpmx;
- qreal dpmy;
- qreal devicePixelRatio;
-
- bool flipped;
-
- QPaintEngine *engine;
-};
-
/*!
Constructs a QOpenGLPaintDevice.
@@ -152,6 +136,14 @@ QOpenGLPaintDevice::QOpenGLPaintDevice(int width, int height)
}
/*!
+ \internal
+ */
+QOpenGLPaintDevice::QOpenGLPaintDevice(QOpenGLPaintDevicePrivate *dd)
+ : d_ptr(dd)
+{
+}
+
+/*!
Destroys the QOpenGLPaintDevice.
*/
@@ -355,7 +347,10 @@ bool QOpenGLPaintDevice::paintFlipped() const
frame buffer object or context when different QOpenGLPaintDevice instances
are issuing draw calls alternately.
- QPainter::beginNativePainting will also trigger this method.
+ \l{QPainter::beginNativePainting()}{beginNativePainting()} will also trigger
+ this method.
+
+ The default implementation does nothing.
*/
void QOpenGLPaintDevice::ensureActiveTarget()
{
diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h
index e1be9b525d..dda3bfe43f 100644
--- a/src/gui/opengl/qopenglpaintdevice.h
+++ b/src/gui/opengl/qopenglpaintdevice.h
@@ -44,7 +44,6 @@
QT_BEGIN_NAMESPACE
-
class QOpenGLPaintDevicePrivate;
class Q_GUI_EXPORT QOpenGLPaintDevice : public QPaintDevice
@@ -54,6 +53,7 @@ public:
QOpenGLPaintDevice();
explicit QOpenGLPaintDevice(const QSize &size);
QOpenGLPaintDevice(int width, int height);
+ QOpenGLPaintDevice(QOpenGLPaintDevicePrivate *dd);
virtual ~QOpenGLPaintDevice();
int devType() const { return QInternal::OpenGL; }
diff --git a/src/gui/opengl/qopenglpaintdevice_p.h b/src/gui/opengl/qopenglpaintdevice_p.h
new file mode 100644
index 0000000000..0b01129a84
--- /dev/null
+++ b/src/gui/opengl/qopenglpaintdevice_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOPENGL_PAINTDEVICE_P_H
+#define QOPENGL_PAINTDEVICE_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 Qt OpenGL classes. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qopenglpaintdevice.h>
+
+QT_BEGIN_NAMESPACE
+
+class QOpenGLContext;
+class QPaintEngine;
+
+class Q_GUI_EXPORT QOpenGLPaintDevicePrivate
+{
+public:
+ QOpenGLPaintDevicePrivate(const QSize &size);
+ virtual ~QOpenGLPaintDevicePrivate() { }
+
+ static QOpenGLPaintDevicePrivate *get(QOpenGLPaintDevice *dev) { return dev->d_func(); }
+
+ virtual void beginPaint() { }
+ virtual void endPaint() { }
+
+public:
+ QSize size;
+ QOpenGLContext *ctx;
+
+ qreal dpmx;
+ qreal dpmy;
+ qreal devicePixelRatio;
+
+ bool flipped;
+
+ QPaintEngine *engine;
+};
+
+QT_END_NAMESPACE
+
+#endif // QOPENGL_PAINTDEVICE_P_H
diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp
index 21bc4a95e8..c490726359 100644
--- a/src/gui/opengl/qopenglpaintengine.cpp
+++ b/src/gui/opengl/qopenglpaintengine.cpp
@@ -59,6 +59,7 @@
#include "qopenglgradientcache_p.h"
#include "qopengltexturecache_p.h"
#include "qopenglpaintengine_p.h"
+#include "qopenglpaintdevice_p.h"
#include <string.h> //for memcpy
#include <qmath.h>
@@ -1994,6 +1995,8 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev)
d->ctx = QOpenGLContext::currentContext();
d->ctx->d_func()->active_engine = this;
+ QOpenGLPaintDevicePrivate::get(d->device)->beginPaint();
+
d->funcs.initializeOpenGLFunctions();
for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
@@ -2044,6 +2047,8 @@ bool QOpenGL2PaintEngineEx::end()
{
Q_D(QOpenGL2PaintEngineEx);
+ QOpenGLPaintDevicePrivate::get(d->device)->endPaint();
+
QOpenGLContext *ctx = d->ctx;
d->funcs.glUseProgram(0);
d->transferMode(BrushDrawingMode);