From ebc835c2aa02f0b3dc6e4806bde03f33513d3556 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 14 Oct 2014 12:07:41 +0200 Subject: Fix QOpenGLWidget on Cocoa when used as viewport MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Having a QOpenGLWidget as a graphics view viewport was not functioning on OS X: it was showing incomplete content due to accessing the texture attached to the framebuffer object before the rendering is complete. On the normal path, when rendering is done via paintGL(), the flush was there. When used as a viewport however, this path is not used. The missing flush is now added for the other case too. For performance reasons, we will not flush on every paint engine end(). Instead, the flush is deferred until composition starts. QGLWidget also featured a weird on-by-default autoFillBackground concept. To maintain compatibility with apps that used QGLWidget as the viewport for QGraphicsView, we will now do the same for QOpenGLWidget, but only when it is used as a viewport. For regular QOpenGLWidgets autoFillBackground defaults to false, like for any other widget. The docs are extended with a small section about differences between QGLWidget and QOpenGLWidget. Task-number: QTBUG-41046 Change-Id: I42c2033fdd2ef5815783fd640fe11373761061e0 Reviewed-by: Jørgen Lind --- src/gui/opengl/qopenglpaintdevice.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/gui/opengl/qopenglpaintdevice.cpp') diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp index 59bca6efdf4..c2f3295bc30 100644 --- a/src/gui/opengl/qopenglpaintdevice.cpp +++ b/src/gui/opengl/qopenglpaintdevice.cpp @@ -350,15 +350,40 @@ 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 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() { } +/*! + This virtual method is called when the painting has finished. + + The default implementation does nothing. + + \sa beginPaint() +*/ +void QOpenGLPaintDevice::endPaint() +{ +} + QT_END_NAMESPACE -- cgit v1.2.3 From 6d1c4c8862161fd4aaffe307c7267ceeb408d8d8 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 14 Oct 2014 12:07:41 +0200 Subject: Avoid breaking BC with new virtuals in QOpenGLPaintDevice Task-number: QTBUG-41046 Change-Id: Iab628d2d6811d528e2cc513b6f8a74baa628541d Reviewed-by: Gunnar Sletta --- src/gui/opengl/qopenglpaintdevice.cpp | 48 +++++++---------------------------- 1 file changed, 9 insertions(+), 39 deletions(-) (limited to 'src/gui/opengl/qopenglpaintdevice.cpp') diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp index c2f3295bc30..e908fd8e915 100644 --- a/src/gui/opengl/qopenglpaintdevice.cpp +++ b/src/gui/opengl/qopenglpaintdevice.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -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 -- cgit v1.2.3