aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/scenegraph/util/qsgpainternode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/scenegraph/util/qsgpainternode.cpp')
-rw-r--r--src/declarative/scenegraph/util/qsgpainternode.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/declarative/scenegraph/util/qsgpainternode.cpp b/src/declarative/scenegraph/util/qsgpainternode.cpp
index 5d548792c6..fb35467ce2 100644
--- a/src/declarative/scenegraph/util/qsgpainternode.cpp
+++ b/src/declarative/scenegraph/util/qsgpainternode.cpp
@@ -42,6 +42,7 @@
#include "qsgpainternode_p.h"
#include "qsgpainteditem.h"
+#include <private/qsgpainteditem_p.h>
#include <private/qsgcontext_p.h>
#include <private/qopenglextensions_p.h>
#include <qopenglframebufferobject.h>
@@ -52,7 +53,7 @@
QT_BEGIN_NAMESPACE
-#define QT_MINIMUM_FBO_SIZE 64
+#define QT_MINIMUM_DYNAMIC_FBO_SIZE 64
static inline int qt_next_power_of_two(int v)
{
@@ -122,12 +123,15 @@ QSGPainterNode::QSGPainterNode(QSGPaintedItem *item)
, m_smoothPainting(false)
, m_extensionsChecked(false)
, m_multisamplingSupported(false)
+ , m_fastFBOResizing(false)
, m_fillColor(Qt::transparent)
, m_contentsScale(1.0)
, m_dirtyGeometry(false)
, m_dirtyRenderTarget(false)
, m_dirtyTexture(false)
{
+ m_context = static_cast<QSGPaintedItemPrivate *>(QObjectPrivate::get(item))->sceneGraphContext();
+
setMaterial(&m_materialO);
setOpaqueMaterial(&m_material);
setGeometry(&m_geometry);
@@ -268,7 +272,7 @@ void QSGPainterNode::updateRenderTarget()
}
if (m_actualRenderTarget == QSGPaintedItem::FramebufferObject) {
- QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ const QOpenGLContext *ctx = m_context->glContext();
if (m_fbo && !m_dirtyGeometry && (!ctx->format().samples() || !m_multisamplingSupported))
return;
@@ -323,8 +327,17 @@ void QSGPainterNode::updateRenderTarget()
void QSGPainterNode::updateFBOSize()
{
- int fboWidth = qMax(QT_MINIMUM_FBO_SIZE, qt_next_power_of_two(m_size.width()));
- int fboHeight = qMax(QT_MINIMUM_FBO_SIZE, qt_next_power_of_two(m_size.height()));
+ int fboWidth;
+ int fboHeight;
+ if (m_fastFBOResizing) {
+ fboWidth = qMax(QT_MINIMUM_DYNAMIC_FBO_SIZE, qt_next_power_of_two(m_size.width()));
+ fboHeight = qMax(QT_MINIMUM_DYNAMIC_FBO_SIZE, qt_next_power_of_two(m_size.height()));
+ } else {
+ QSize minimumFBOSize = m_context->minimumFBOSize();
+ fboWidth = qMax(minimumFBOSize.width(), m_size.width());
+ fboHeight = qMax(minimumFBOSize.height(), m_size.height());
+ }
+
m_fboSize = QSize(fboWidth, fboHeight);
}
@@ -426,6 +439,11 @@ void QSGPainterNode::setContentsScale(qreal s)
markDirty(DirtyMaterial);
}
+void QSGPainterNode::setFastFBOResizing(bool dynamic)
+{
+ m_fastFBOResizing = dynamic;
+}
+
QImage QSGPainterNode::toImage() const
{
if (m_actualRenderTarget == QSGPaintedItem::Image)