From ceba0c6b9a0ac3b50f460572ba95bbbedbbaccae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Wed, 10 Jan 2018 17:00:21 +0100 Subject: QSGSoftwarePixmapRenderer: Fix incorrect background coordinates The pixmap renderer sets up QPainter's window coordinates system but still positions the background node in device coordinates. If the window rectangle is QRect(x, y, w, h) then the background rectangle will be set to QRect(0, 0, w, h). As the rendering output is clipped to the background rectangle, this means that the image will be left with transparent bands of x pixels on the right and y pixels on the bottom. Task-number: QTBUG-62867 Change-Id: I3b2c18dafda4381b0daa64f849330f51bcc743b2 Reviewed-by: Andy Nichols --- .../adaptations/software/qsgabstractsoftwarerenderer.cpp | 10 +++++----- .../adaptations/software/qsgabstractsoftwarerenderer_p.h | 4 ++-- .../adaptations/software/qsgsoftwarepixmaprenderer.cpp | 2 +- .../scenegraph/adaptations/software/qsgsoftwarerenderer.cpp | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp b/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp index 30088846a6..4cec84646e 100644 --- a/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp @@ -233,11 +233,11 @@ void QSGAbstractSoftwareRenderer::setBackgroundColor(const QColor &color) renderableNode(m_background)->markMaterialDirty(); } -void QSGAbstractSoftwareRenderer::setBackgroundSize(const QSize &size) +void QSGAbstractSoftwareRenderer::setBackgroundRect(const QRect &rect) { - if (m_background->rect().size().toSize() == size) + if (m_background->rect().toRect() == rect) return; - m_background->setRect(0.0f, 0.0f, size.width(), size.height()); + m_background->setRect(rect); renderableNode(m_background)->markGeometryDirty(); // Invalidate the whole scene when the background is resized markDirty(); @@ -248,9 +248,9 @@ QColor QSGAbstractSoftwareRenderer::backgroundColor() return m_background->color(); } -QSize QSGAbstractSoftwareRenderer::backgroundSize() +QRect QSGAbstractSoftwareRenderer::backgroundRect() { - return m_background->rect().size().toSize(); + return m_background->rect().toRect(); } void QSGAbstractSoftwareRenderer::nodeAdded(QSGNode *node) diff --git a/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer_p.h b/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer_p.h index f20c2cf977..f6594d931a 100644 --- a/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer_p.h +++ b/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer_p.h @@ -83,9 +83,9 @@ protected: QRegion optimizeRenderList(); void setBackgroundColor(const QColor &color); - void setBackgroundSize(const QSize &size); + void setBackgroundRect(const QRect &rect); QColor backgroundColor(); - QSize backgroundSize(); + QRect backgroundRect(); // only known after calling optimizeRenderList() bool isOpaque() const { return m_isOpaque; } diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaprenderer.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaprenderer.cpp index 7824e53622..a56c126541 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 - setBackgroundSize(QSize(target->width(), target->height())); + setBackgroundRect(m_projectionRect); setBackgroundColor(clearColor()); renderTimer.start(); diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp index cad826fb27..ddc7ec5d4c 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp @@ -112,7 +112,8 @@ void QSGSoftwareRenderer::render() QElapsedTimer renderTimer; setBackgroundColor(clearColor()); - setBackgroundSize(QSize(m_paintDevice->width() / m_paintDevice->devicePixelRatio(), + setBackgroundRect(QRect(0, 0, + m_paintDevice->width() / m_paintDevice->devicePixelRatio(), m_paintDevice->height() / m_paintDevice->devicePixelRatio())); // Build Renderlist -- cgit v1.2.3 From 421a1c5cae9cd17a3fefb6133b0727b29f456eff Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 19 Jan 2018 09:53:26 +0100 Subject: Remove another call to QOpenGLContext::currentContext() .. by getting the context from the readily available state. Change-Id: Ie2819a112b31e080a865c657d0fc63cd1968e7a3 Reviewed-by: Lars Knoll --- src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp index ca91e5d85f..1c88e33b10 100644 --- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp @@ -181,7 +181,7 @@ void QSGDistanceFieldTextMaterialShader::updateState(const RenderState &state, Q updateTextureScale(QVector2D(1.0 / material->textureSize().width(), 1.0 / material->textureSize().height())); - QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); + QOpenGLFunctions *funcs = state.context()->functions(); funcs->glBindTexture(GL_TEXTURE_2D, material->texture()->textureId); if (updated) { -- cgit v1.2.3 From 16cd1f8d24f011d30d3fc7baf7750700af14d9c5 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 26 Jan 2018 11:40:09 +0100 Subject: Fix uploading of compressed textures of ETC2_EAC type The call to glCompressedTexImage2D would fail since the code did not account for the fact that the ETC2_EAC scheme uses twice the number of bytes as other ETC schemes. Change-Id: I93502f5848b112cac2f798453a0d32a2c0a2a20b Reviewed-by: Laszlo Agocs --- src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp b/src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp index bb8fce046d..62066a136a 100644 --- a/src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp +++ b/src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp @@ -125,9 +125,10 @@ void QEtcTexture::bind() QOpenGLContext *ctx = QOpenGLContext::currentContext(); Q_ASSERT(ctx != 0); + const int compFactor = m_type == GL_COMPRESSED_RGBA8_ETC2_EAC ? 1 : 2; ctx->functions()->glCompressedTexImage2D(GL_TEXTURE_2D, 0, m_type, m_size.width(), m_size.height(), 0, - (m_paddedSize.width() * m_paddedSize.height()) / 2, + (m_paddedSize.width() * m_paddedSize.height()) / compFactor, m_data.data() + headerSize); #ifndef QT_NO_DEBUG -- cgit v1.2.3