diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-10-14 12:07:41 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-10-16 21:47:29 +0200 |
commit | 6d1c4c8862161fd4aaffe307c7267ceeb408d8d8 (patch) | |
tree | 1bc2957bdb34af0ed943d3d24c47824edf70cb4a /src/widgets/kernel/qopenglwidget.cpp | |
parent | a4ac4b326318ed9034466305222280ed8d1651b5 (diff) |
Avoid breaking BC with new virtuals in QOpenGLPaintDevice
Task-number: QTBUG-41046
Change-Id: Iab628d2d6811d528e2cc513b6f8a74baa628541d
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/widgets/kernel/qopenglwidget.cpp')
-rw-r--r-- | src/widgets/kernel/qopenglwidget.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index dd8dd64470..8a4e0c8ffd 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -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,17 +455,26 @@ QT_BEGIN_NAMESPACE due to resizing the widget. */ -class QOpenGLWidgetPaintDevice : public QOpenGLPaintDevice +class QOpenGLWidgetPaintDevicePrivate : public QOpenGLPaintDevicePrivate { public: - QOpenGLWidgetPaintDevice(QOpenGLWidget *widget) : w(widget) { } + QOpenGLWidgetPaintDevicePrivate(QOpenGLWidget *widget) + : QOpenGLPaintDevicePrivate(QSize()), + w(widget) { } + void beginPaint() Q_DECL_OVERRIDE; - void ensureActiveTarget() Q_DECL_OVERRIDE; -private: QOpenGLWidget *w; }; +class QOpenGLWidgetPaintDevice : public QOpenGLPaintDevice +{ +public: + QOpenGLWidgetPaintDevice(QOpenGLWidget *widget) + : QOpenGLPaintDevice(new QOpenGLWidgetPaintDevicePrivate(widget)) { } + void ensureActiveTarget() Q_DECL_OVERRIDE; +}; + class QOpenGLWidgetPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QOpenGLWidget) @@ -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 |