diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-22 15:04:42 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-22 15:32:19 +0200 |
commit | 07782f48f4318a7261f1b0ddcd686b19ec812e36 (patch) | |
tree | 3fa2aa3a1170ad7ebaf5b1641cdce19a941ca480 /src/quickwidgets/qquickwidget.cpp | |
parent | 50fcdfd705c2ad9560641986bf4152b017ee8bb6 (diff) | |
parent | f15a90e5d10465e66698209a5d88f1e63ae336fa (diff) |
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
src/qml/qml/qqmlbinding.cpp
src/qml/jsruntime/qv4arraybuffer.cpp
src/qml/jsruntime/qv4functionobject.cpp
Change-Id: Ic752e9dfd69b282093651c9234c110a49762f06d
Diffstat (limited to 'src/quickwidgets/qquickwidget.cpp')
-rw-r--r-- | src/quickwidgets/qquickwidget.cpp | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 29577b856d..5dd439fdd0 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -630,6 +630,22 @@ void QQuickWidgetPrivate::updateSize() } } +/*! + \internal + + Update the position of the offscreen window, so it matches the position of the QQuickWidget. + */ +void QQuickWidgetPrivate::updatePosition() +{ + Q_Q(QQuickWidget); + if (offscreenWindow == 0) + return; + + const QPoint &pos = q->mapToGlobal(QPoint(0, 0)); + if (offscreenWindow->position() != pos) + offscreenWindow->setPosition(pos); +} + QSize QQuickWidgetPrivate::rootObjectSize() const { QSize rootObjectSize(0,0); @@ -746,6 +762,16 @@ void QQuickWidget::createFramebufferObject() format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); format.setSamples(samples); + // The default framebuffer for normal windows have sRGB support on OS X which leads to the Qt Quick text item + // utilizing sRGB blending. To get identical results with QQuickWidget we have to have our framebuffer backed + // by an sRGB texture. +#ifdef Q_OS_OSX + if (context->hasExtension("GL_ARB_framebuffer_sRGB") + && context->hasExtension("GL_EXT_texture_sRGB") + && context->hasExtension("GL_EXT_texture_sRGB_decode")) + format.setInternalTextureFormat(GL_SRGB8_ALPHA8_EXT); +#endif + const QSize fboSize = size() * devicePixelRatio(); // Could be a simple hide - show, in which case the previous fbo is just fine. @@ -754,7 +780,22 @@ void QQuickWidget::createFramebufferObject() d->fbo = new QOpenGLFramebufferObject(fboSize, format); } - d->offscreenWindow->setGeometry(0, 0, width(), height()); + // When compositing in the backingstore, sampling the sRGB texture would perform an + // sRGB-linear conversion which is not what we want when the final framebuffer (the window's) + // is sRGB too. Disable the conversion. +#ifdef Q_OS_OSX + if (format.internalTextureFormat() == GL_SRGB8_ALPHA8_EXT) { + QOpenGLFunctions *funcs = context->functions(); + funcs->glBindTexture(GL_TEXTURE_2D, d->fbo->texture()); + funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); + } +#endif + + // Even though this is just an offscreen window we should set the position on it, as it might be + // useful for an item to know the actual position of the scene. + // Note: The position will be update when we get a move event (see: updatePosition()). + const QPoint &globalPos = mapToGlobal(QPoint(0, 0)); + d->offscreenWindow->setGeometry(globalPos.x(), globalPos.y(), width(), height()); d->offscreenWindow->setRenderTarget(d->fbo); if (samples > 0) @@ -1108,6 +1149,10 @@ bool QQuickWidget::event(QEvent *e) } break; + case QEvent::Move: + d->updatePosition(); + break; + default: break; } |