From 6c27d2fc7d6640f83500307a63a002f7a7711e93 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com> Date: Tue, 27 Oct 2015 13:02:28 +0200 Subject: [PATCH] Fix drawbuffer size limiting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The canvas size itself shouldn't be limited by maximum possible viewport size, but instead the draw buffer size should be limited. Removing width and height properties should not be a problem, as they were undocumented overloads of QQuickItem properties with same name. Change-Id: Ie5a4e65fbb877a8321e6b2e131c8b268b518218b Task-number: QTBUG-48526 Reviewed-by: Tomi Korpipää <tomi.korpipaa@theqtcompany.com> Reviewed-by: Pasi Keränen <pasi.keranen@digia.com> --- src/imports/qtcanvas3d/canvas3d.cpp | 66 ----------------------- src/imports/qtcanvas3d/canvas3d_p.h | 8 --- src/imports/qtcanvas3d/canvasrenderer.cpp | 4 ++ 3 files changed, 4 insertions(+), 74 deletions(-) diff --git a/src/imports/qtcanvas3d/canvas3d.cpp b/src/imports/qtcanvas3d/canvas3d.cpp index 08892ad..825644d 100644 --- a/src/imports/qtcanvas3d/canvas3d.cpp +++ b/src/imports/qtcanvas3d/canvas3d.cpp @@ -108,8 +108,6 @@ Canvas::Canvas(QQuickItem *parent): connect(this, &Canvas::needRender, this, &Canvas::queueNextRender, Qt::QueuedConnection); connect(this, &QQuickItem::widthChanged, this, &Canvas::queueResizeGL, Qt::DirectConnection); connect(this, &QQuickItem::heightChanged, this, &Canvas::queueResizeGL, Qt::DirectConnection); - connect(this, &QQuickItem::widthChanged, this, &Canvas::widthChanged, Qt::DirectConnection); - connect(this, &QQuickItem::heightChanged, this, &Canvas::heightChanged, Qt::DirectConnection); setAntialiasing(false); // Set contents to false in case we are in qml designer to make component look nice @@ -163,53 +161,6 @@ Canvas::~Canvas() m_renderer->destroy(); } -/*! - * Override QQuickItem's setWidth to be able to limit the maximum canvas size to maximum viewport - * dimensions. - */ -void Canvas::setWidth(int width) -{ - int newWidth = width; - int maxWidth = m_maxSize.width(); - if (maxWidth && width > maxWidth) { - qCDebug(canvas3drendering).nospace() << "Canvas3D::" << __FUNCTION__ - << "():" - << "Maximum width exceeded. Limiting to " - << maxWidth; - newWidth = maxWidth; - } - QQuickItem::setWidth(qreal(newWidth)); -} - -int Canvas::width() -{ - return int(QQuickItem::width()); -} - -/*! - * Override QQuickItem's setHeight to be able to limit the maximum canvas size to maximum viewport - * dimensions. - */ -void Canvas::setHeight(int height) -{ - int newHeight = height; - int maxHeight = m_maxSize.height(); - if (maxHeight && height > maxHeight) { - qCDebug(canvas3drendering).nospace() << "Canvas3D::" << __FUNCTION__ - << "():" - << "Maximum height exceeded. Limiting to " - << maxHeight; - newHeight = maxHeight; - } - - QQuickItem::setHeight(qreal(newHeight)); -} - -int Canvas::height() -{ - return int(QQuickItem::height()); -} - /*! * \qmlproperty RenderTarget Canvas3D::renderTarget * Specifies how the rendering should be done. @@ -436,23 +387,6 @@ QJSValue Canvas::getContext(const QString &type, const QVariantMap &options) m_context3D.data(), &CanvasContext::handleTextureIdResolved, Qt::QueuedConnection); - // Verify that width and height are not initially too large, in case width and height - // were set before getting GL_MAX_VIEWPORT_DIMS - if (width() > m_maxSize.width()) { - qCDebug(canvas3drendering).nospace() << "Canvas3D::" << __FUNCTION__ - << "():" - << "Maximum width exceeded. Limiting to " - << m_maxSize.width(); - QQuickItem::setWidth(m_maxSize.width()); - } - if (height() > m_maxSize.height()) { - qCDebug(canvas3drendering).nospace() << "Canvas3D::" << __FUNCTION__ - << "():" - << "Maximum height exceeded. Limiting to " - << m_maxSize.height(); - QQuickItem::setHeight(m_maxSize.height()); - } - m_context3D->setCanvas(this); m_context3D->setDevicePixelRatio(m_devicePixelRatio); m_context3D->setContextAttributes(m_contextAttribs); diff --git a/src/imports/qtcanvas3d/canvas3d_p.h b/src/imports/qtcanvas3d/canvas3d_p.h index 3ee5049..14b6afa 100644 --- a/src/imports/qtcanvas3d/canvas3d_p.h +++ b/src/imports/qtcanvas3d/canvas3d_p.h @@ -89,8 +89,6 @@ class QT_CANVAS3D_EXPORT Canvas : public QQuickItem Q_PROPERTY(float devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged) Q_PROPERTY(uint fps READ fps NOTIFY fpsChanged) Q_PROPERTY(QSize pixelSize READ pixelSize WRITE setPixelSize NOTIFY pixelSizeChanged) - Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) - Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) Q_PROPERTY(RenderTarget renderTarget READ renderTarget WRITE setRenderTarget NOTIFY renderTargetChanged REVISION 1) Q_PROPERTY(bool renderOnDemand READ renderOnDemand WRITE setRenderOnDemand NOTIFY renderOnDemandChanged REVISION 1) @@ -116,10 +114,6 @@ public: float devicePixelRatio(); QSize pixelSize(); void setPixelSize(QSize pixelSize); - void setWidth(int width); - int width(); - void setHeight(int height); - int height(); void setRenderTarget(RenderTarget target); RenderTarget renderTarget() const; void setRenderOnDemand(bool enable); @@ -151,8 +145,6 @@ signals: void contextChanged(CanvasContext *context); void fpsChanged(uint fps); void pixelSizeChanged(QSize pixelSize); - void widthChanged(); - void heightChanged(); void renderTargetChanged(); void renderOnDemandChanged(); void contextLost(); diff --git a/src/imports/qtcanvas3d/canvasrenderer.cpp b/src/imports/qtcanvas3d/canvasrenderer.cpp index f2e13e4..c2b4e19 100644 --- a/src/imports/qtcanvas3d/canvasrenderer.cpp +++ b/src/imports/qtcanvas3d/canvasrenderer.cpp @@ -178,6 +178,10 @@ void CanvasRenderer::init(QQuickWindow *window, const CanvasContextAttributes &c maxSize.setHeight(viewportDims[1]); // Set the size + if (maxSize.width() < m_initializedSize.width()) + m_initializedSize.setWidth(maxSize.width()); + if (maxSize.height() < m_initializedSize.height()) + m_initializedSize.setHeight(maxSize.height()); setFboSize(m_initializedSize); m_forceViewportRect = QRect(0, 0, m_fboSize.width(), m_fboSize.height()); glScissor(0, 0, m_fboSize.width(), m_fboSize.height()); -- GitLab