From f0f632c7c1043f9c8097b4677f0a9eae01f916d2 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Sun, 11 Mar 2018 23:15:38 +0000 Subject: Fix non-integer scale factors with Text native rendering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-67007 Change-Id: Id32cc14ea1bc258cfc139a859ccae014f5893563 Reviewed-by: Morten Johan Sørvig --- src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index dc473a6640..ce706d76f7 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -71,9 +71,9 @@ static inline QVector4D qsg_premultiply(const QVector4D &c, float globalOpacity) return QVector4D(c.x() * o, c.y() * o, c.z() * o, o); } -static inline int qsg_device_pixel_ratio(QOpenGLContext *ctx) +static inline qreal qsg_device_pixel_ratio(QOpenGLContext *ctx) { - int devicePixelRatio = 1; + qreal devicePixelRatio = 1; if (ctx->surface()->surfaceClass() == QSurface::Window) { QWindow *w = static_cast(ctx->surface()); if (QQuickWindow *qw = qobject_cast(w)) -- cgit v1.2.3 From bb9dd912baae3aa537d5775d0829bed3baa5877d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Thu, 16 Nov 2017 15:54:58 +0100 Subject: Correct logging of swap time in software render loop The conversion from nanoseconds to milliseconds wrongly divided the swap time by 10 million instead of 1 million. Change-Id: Id2b1594fbf7abafabfeae790c7083ad1cf4064a0 Reviewed-by: Andy Nichols --- src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp index 423f5f7321..b400473128 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp @@ -195,7 +195,7 @@ void QSGSoftwareRenderLoop::renderWindow(QQuickWindow *window, bool isNewExpose) int(polishTime / 1000000), int((syncTime - polishTime) / 1000000), int((renderTime - syncTime) / 1000000), - int((swapTime - renderTime) / 10000000), + int((swapTime - renderTime) / 1000000), int(lastFrameTime.msecsTo(QTime::currentTime()))); lastFrameTime = QTime::currentTime(); } -- cgit v1.2.3 From 839f09c65523fb5c419b62e078f72bb39285449a Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 28 Mar 2018 00:24:56 +0100 Subject: Avoid marking hidden windows as updatePending in Gui render loop Since eeb320bbd8763f3e72f79369cc3908e999a0da3c the GL context only deletes textures when all windows with pending updates have finished rendering. renderWindow will not process any window that is not visible. This leaves a logic bug that we can have the updatePending flag set but never cleared. If we have two windows, this leaves the other window still updating normally, but lastDirtyWindow will always be false and we never call endSync. This results in an effective memory leak of all textures. This patch resets the flag on hide() a move that can be considered safe given the show() method will reset this flag anyway. Change-Id: Iab0171716e27e31077a66b5e36a00bf28a2e7a8c Reviewed-by: Kai Uwe Broulik Reviewed-by: Qt CI Bot Reviewed-by: Dominik Holland Reviewed-by: Aleix Pol Reviewed-by: Andy Nichols --- src/quick/scenegraph/qsgrenderloop.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 60f3538662..2eaed497ef 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -305,6 +305,8 @@ void QSGGuiThreadRenderLoop::hide(QQuickWindow *window) { QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window); cd->fireAboutToStop(); + if (m_windows.contains(window)) + m_windows[window].updatePending = false; } void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window) @@ -494,7 +496,8 @@ QImage QSGGuiThreadRenderLoop::grab(QQuickWindow *window) void QSGGuiThreadRenderLoop::maybeUpdate(QQuickWindow *window) { - if (!m_windows.contains(window)) + QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window); + if (!cd->isRenderable() || !m_windows.contains(window)) return; m_windows[window].updatePending = true; -- cgit v1.2.3 From 10c56615d1418c155648e2a150b45b6cb768b33e Mon Sep 17 00:00:00 2001 From: Jan Marker Date: Sun, 8 Apr 2018 17:40:36 +0200 Subject: Make QSGLayer::grab work correctly in software renderer Fix three separate issues: 1. It was possible that the QSGSoftwarePixmapRenderer's background image's rectangle was set to a non-normalized rectangle. That would have led to the damage area detection creating an empty QRegion for the damage area and QQuickItem::grabToImage would grab an empty image. 2. The QSGSoftwarePixmapRenderer was rendering the image vertically mirrored compared to what its equivalent in the OpenGL backend was doing. Therefore QSGLayer::grab was vertically mirrored, too, so QQuickItem::grabToImage would grab a mirrored image, too. Additionally QSGSoftwareInternalImageNode (used by QQuickShaderEffectSource) now has to mirror its internal texture if that one is a QSGSoftwareLayer. 3. QSGSoftwareInternalImageNode (used by QQuickShaderEffectSource) was not updating correctly when mirroring (with the fix for 2 also in case of a QSGSoftwareLayer as texture). Related to QTBUG-63185 and QTBUG-65975. Change-Id: I0d0ead7fb1c839a8ff427ff7881d8a881e538409 Reviewed-by: Eirik Aavitsland Reviewed-by: Andy Nichols --- .../adaptations/software/qsgsoftwareinternalimagenode.cpp | 14 +++++++++++--- .../adaptations/software/qsgsoftwareinternalimagenode_p.h | 1 + .../scenegraph/adaptations/software/qsgsoftwarelayer.cpp | 4 ++-- .../adaptations/software/qsgsoftwarepixmaprenderer.cpp | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp index 3b0f3c48ff..aa83709b72 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp @@ -320,6 +320,7 @@ QSGSoftwareInternalImageNode::QSGSoftwareInternalImageNode() , m_subSourceRect(0, 0, 1, 1) , m_texture(nullptr) , m_mirror(false) + , m_textureIsLayer(false) , m_smooth(true) , m_tileHorizontal(false) , m_tileVertical(false) @@ -366,6 +367,7 @@ void QSGSoftwareInternalImageNode::setTexture(QSGTexture *texture) { m_texture = texture; m_cachedMirroredPixmapIsDirty = true; + m_textureIsLayer = static_cast(qobject_cast(texture)); markDirty(DirtyMaterial); } @@ -415,8 +417,13 @@ void QSGSoftwareInternalImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrap void QSGSoftwareInternalImageNode::update() { if (m_cachedMirroredPixmapIsDirty) { - if (m_mirror) { - m_cachedMirroredPixmap = pixmap().transformed(QTransform(-1, 0, 0, 1, 0, 0)); + if (m_mirror || m_textureIsLayer) { + QTransform transform( + (m_mirror ? -1 : 1), 0, + 0 , (m_textureIsLayer ? -1 :1), + 0 , 0 + ); + m_cachedMirroredPixmap = pixmap().transformed(transform); } else { //Cleanup cached pixmap if necessary if (!m_cachedMirroredPixmap.isNull()) @@ -436,6 +443,7 @@ void QSGSoftwareInternalImageNode::preprocess() } if (doDirty) markDirty(DirtyMaterial); + m_cachedMirroredPixmapIsDirty = doDirty; } static Qt::TileRule getTileRule(qreal factor) @@ -454,7 +462,7 @@ void QSGSoftwareInternalImageNode::paint(QPainter *painter) { painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth); - const QPixmap &pm = m_mirror ? m_cachedMirroredPixmap : pixmap(); + const QPixmap &pm = m_mirror || m_textureIsLayer ? m_cachedMirroredPixmap : pixmap(); if (m_innerTargetRect != m_targetRect) { // border image diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h index 5c95eb064a..b80bacbaa0 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h @@ -136,6 +136,7 @@ private: QPixmap m_cachedMirroredPixmap; bool m_mirror; + bool m_textureIsLayer; bool m_smooth; bool m_tileHorizontal; bool m_tileVertical; diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarelayer.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarelayer.cpp index b4301451d8..70378d2950 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarelayer.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarelayer.cpp @@ -240,9 +240,9 @@ void QSGSoftwareLayer::grab() m_renderer->setDeviceRect(m_size); m_renderer->setViewportRect(m_size); QRect mirrored(m_mirrorHorizontal ? m_rect.right() * m_device_pixel_ratio : m_rect.left() * m_device_pixel_ratio, - m_mirrorVertical ? m_rect.top() * m_device_pixel_ratio : m_rect.bottom() * m_device_pixel_ratio, + m_mirrorVertical ? m_rect.bottom() * m_device_pixel_ratio : m_rect.top() * m_device_pixel_ratio, m_mirrorHorizontal ? -m_rect.width() * m_device_pixel_ratio : m_rect.width() * m_device_pixel_ratio, - m_mirrorVertical ? m_rect.height() * m_device_pixel_ratio : -m_rect.height() * m_device_pixel_ratio); + m_mirrorVertical ? -m_rect.height() * m_device_pixel_ratio : m_rect.height() * m_device_pixel_ratio); m_renderer->setProjectionRect(mirrored); m_renderer->setClearColor(Qt::transparent); diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaprenderer.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaprenderer.cpp index 303f98c801..bb4afc8301 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaprenderer.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaprenderer.cpp @@ -79,7 +79,7 @@ void QSGSoftwarePixmapRenderer::render(QPaintDevice *target) QElapsedTimer renderTimer; // Setup background item - setBackgroundRect(m_projectionRect); + setBackgroundRect(m_projectionRect.normalized()); setBackgroundColor(clearColor()); renderTimer.start(); -- cgit v1.2.3