Avoid breaking BC with new virtuals in QOpenGLPaintDevice
Task-number: QTBUG-41046 Change-Id: Iab628d2d6811d528e2cc513b6f8a74baa628541d Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
This commit is contained in:
parent
a4ac4b3263
commit
6d1c4c8862
@ -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 \
|
||||
|
@ -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.
|
||||
|
||||
@ -151,6 +135,14 @@ QOpenGLPaintDevice::QOpenGLPaintDevice(int width, int height)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QOpenGLPaintDevice::QOpenGLPaintDevice(QOpenGLPaintDevicePrivate *dd)
|
||||
: d_ptr(dd)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the QOpenGLPaintDevice.
|
||||
*/
|
||||
@ -350,17 +342,6 @@ bool QOpenGLPaintDevice::paintFlipped() const
|
||||
return d_ptr->flipped;
|
||||
}
|
||||
|
||||
/*!
|
||||
This virtual method is called when starting to paint.
|
||||
|
||||
The default implementation does nothing.
|
||||
|
||||
\sa endPaint()
|
||||
*/
|
||||
void QOpenGLPaintDevice::beginPaint()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
This virtual method is provided as a callback to allow re-binding a target
|
||||
frame buffer object or context when different QOpenGLPaintDevice instances
|
||||
@ -375,15 +356,4 @@ void QOpenGLPaintDevice::ensureActiveTarget()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
This virtual method is called when the painting has finished.
|
||||
|
||||
The default implementation does nothing.
|
||||
|
||||
\sa beginPaint()
|
||||
*/
|
||||
void QOpenGLPaintDevice::endPaint()
|
||||
{
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -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; }
|
||||
@ -73,9 +73,7 @@ public:
|
||||
void setPaintFlipped(bool flipped);
|
||||
bool paintFlipped() const;
|
||||
|
||||
virtual void beginPaint();
|
||||
virtual void ensureActiveTarget();
|
||||
virtual void endPaint();
|
||||
|
||||
protected:
|
||||
int metric(QPaintDevice::PaintDeviceMetric metric) const;
|
||||
|
81
src/gui/opengl/qopenglpaintdevice_p.h
Normal file
81
src/gui/opengl/qopenglpaintdevice_p.h
Normal file
@ -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
|
@ -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,7 +1995,7 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev)
|
||||
d->ctx = QOpenGLContext::currentContext();
|
||||
d->ctx->d_func()->active_engine = this;
|
||||
|
||||
d->device->beginPaint();
|
||||
QOpenGLPaintDevicePrivate::get(d->device)->beginPaint();
|
||||
|
||||
d->funcs.initializeOpenGLFunctions();
|
||||
|
||||
@ -2046,7 +2047,7 @@ bool QOpenGL2PaintEngineEx::end()
|
||||
{
|
||||
Q_D(QOpenGL2PaintEngineEx);
|
||||
|
||||
d->device->endPaint();
|
||||
QOpenGLPaintDevicePrivate::get(d->device)->endPaint();
|
||||
|
||||
QOpenGLContext *ctx = d->ctx;
|
||||
d->funcs.glUseProgram(0);
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
#include <QtGui/private/qopenglextensions_p.h>
|
||||
#include <QtGui/private/qfont_p.h>
|
||||
#include <QtGui/private/qopenglpaintdevice_p.h>
|
||||
#include <QtWidgets/private/qwidget_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -454,15 +455,24 @@ QT_BEGIN_NAMESPACE
|
||||
due to resizing the widget.
|
||||
*/
|
||||
|
||||
class QOpenGLWidgetPaintDevicePrivate : public QOpenGLPaintDevicePrivate
|
||||
{
|
||||
public:
|
||||
QOpenGLWidgetPaintDevicePrivate(QOpenGLWidget *widget)
|
||||
: QOpenGLPaintDevicePrivate(QSize()),
|
||||
w(widget) { }
|
||||
|
||||
void beginPaint() Q_DECL_OVERRIDE;
|
||||
|
||||
QOpenGLWidget *w;
|
||||
};
|
||||
|
||||
class QOpenGLWidgetPaintDevice : public QOpenGLPaintDevice
|
||||
{
|
||||
public:
|
||||
QOpenGLWidgetPaintDevice(QOpenGLWidget *widget) : w(widget) { }
|
||||
void beginPaint() Q_DECL_OVERRIDE;
|
||||
QOpenGLWidgetPaintDevice(QOpenGLWidget *widget)
|
||||
: QOpenGLPaintDevice(new QOpenGLWidgetPaintDevicePrivate(widget)) { }
|
||||
void ensureActiveTarget() Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
QOpenGLWidget *w;
|
||||
};
|
||||
|
||||
class QOpenGLWidgetPrivate : public QWidgetPrivate
|
||||
@ -518,7 +528,7 @@ public:
|
||||
bool flushPending;
|
||||
};
|
||||
|
||||
void QOpenGLWidgetPaintDevice::beginPaint()
|
||||
void QOpenGLWidgetPaintDevicePrivate::beginPaint()
|
||||
{
|
||||
// NB! autoFillBackground is and must be false by default. Otherwise we would clear on
|
||||
// every QPainter begin() which is not desirable. This is only for legacy use cases,
|
||||
@ -539,19 +549,20 @@ void QOpenGLWidgetPaintDevice::beginPaint()
|
||||
|
||||
void QOpenGLWidgetPaintDevice::ensureActiveTarget()
|
||||
{
|
||||
QOpenGLWidgetPrivate *d = static_cast<QOpenGLWidgetPrivate *>(QWidgetPrivate::get(w));
|
||||
if (!d->initialized)
|
||||
QOpenGLWidgetPaintDevicePrivate *d = static_cast<QOpenGLWidgetPaintDevicePrivate *>(d_ptr.data());
|
||||
QOpenGLWidgetPrivate *wd = static_cast<QOpenGLWidgetPrivate *>(QWidgetPrivate::get(d->w));
|
||||
if (!wd->initialized)
|
||||
return;
|
||||
|
||||
if (QOpenGLContext::currentContext() != d->context)
|
||||
w->makeCurrent();
|
||||
if (QOpenGLContext::currentContext() != wd->context)
|
||||
d->w->makeCurrent();
|
||||
else
|
||||
d->fbo->bind();
|
||||
wd->fbo->bind();
|
||||
|
||||
// When used as a viewport, drawing is done via opening a QPainter on the widget
|
||||
// without going through paintEvent(). We will have to make sure a glFlush() is done
|
||||
// before the texture is accessed also in this case.
|
||||
d->flushPending = true;
|
||||
wd->flushPending = true;
|
||||
}
|
||||
|
||||
GLuint QOpenGLWidgetPrivate::textureId() const
|
||||
|
Loading…
Reference in New Issue
Block a user