diff options
author | Paul Olav Tvete <paul.tvete@qt.io> | 2020-06-09 11:31:58 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-06-11 22:23:46 +0200 |
commit | 66056aba7b47c147b4cf9fd70a855dd15b8a9eb6 (patch) | |
tree | 91dc8d5e96d49abdc84d913d4b83725e04e88d26 /src/quick/scenegraph/util | |
parent | 212c2bffbb041aee0e3c9a7f0551ef151ed2d3ad (diff) |
Remove FBO path from painternode/context2d
Task-number: QTBUG-84623
Change-Id: Icef7ab7460799b989f4e122be3f8d5cab98382e4
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/quick/scenegraph/util')
-rw-r--r-- | src/quick/scenegraph/util/qsgdefaultpainternode.cpp | 176 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgdefaultpainternode_p.h | 8 |
2 files changed, 17 insertions, 167 deletions
diff --git a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp index f0bcc82993..83bdc42687 100644 --- a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp +++ b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp @@ -43,10 +43,6 @@ #include <QtQuick/private/qsgdefaultrendercontext_p.h> #include <QtQuick/private/qsgcontext_p.h> -#include <private/qopenglextensions_p.h> -#include <qopenglframebufferobject.h> -#include <qopenglfunctions.h> -#include <qopenglpaintdevice.h> #include <qmath.h> #include <qpainter.h> @@ -74,11 +70,8 @@ QSGDefaultPainterNode::QSGDefaultPainterNode(QQuickPaintedItem *item) , m_preferredRenderTarget(QQuickPaintedItem::Image) , m_actualRenderTarget(QQuickPaintedItem::Image) , m_item(item) - , m_fbo(nullptr) - , m_multisampledFbo(nullptr) , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4) , m_texture(nullptr) - , m_gl_device(nullptr) , m_fillColor(Qt::transparent) , m_contentsScale(1.0) , m_dirtyContents(false) @@ -86,7 +79,6 @@ QSGDefaultPainterNode::QSGDefaultPainterNode(QQuickPaintedItem *item) , m_linear_filtering(false) , m_mipmapping(false) , m_smoothPainting(false) - , m_extensionsChecked(false) , m_multisamplingSupported(false) , m_fastFBOResizing(false) , m_dirtyGeometry(false) @@ -107,9 +99,6 @@ QSGDefaultPainterNode::QSGDefaultPainterNode(QQuickPaintedItem *item) QSGDefaultPainterNode::~QSGDefaultPainterNode() { delete m_texture; - delete m_fbo; - delete m_multisampledFbo; - delete m_gl_device; } void QSGDefaultPainterNode::paint() @@ -117,24 +106,10 @@ void QSGDefaultPainterNode::paint() QRect dirtyRect = m_dirtyRect.isNull() ? QRect(0, 0, m_size.width(), m_size.height()) : m_dirtyRect; QPainter painter; - if (m_actualRenderTarget == QQuickPaintedItem::Image) { - if (m_image.isNull()) - return; - painter.begin(&m_image); - } else { - Q_ASSERT(!m_context->rhi()); - if (!m_gl_device) { - m_gl_device = new QOpenGLPaintDevice(m_fboSize); - m_gl_device->setPaintFlipped(true); - } - - if (m_multisampledFbo) - m_multisampledFbo->bind(); - else - m_fbo->bind(); - - painter.begin(m_gl_device); - } + Q_ASSERT(m_actualRenderTarget == QQuickPaintedItem::Image); + if (m_image.isNull()) + return; + painter.begin(&m_image); if (m_smoothPainting) { painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); @@ -174,17 +149,8 @@ void QSGDefaultPainterNode::paint() m_item->paint(&painter); painter.end(); - if (m_actualRenderTarget == QQuickPaintedItem::Image) { - m_texture->setImage(m_image); - m_texture->setDirtyRect(dirtyTextureRect); - } else if (m_multisampledFbo) { - QOpenGLFramebufferObject::blitFramebuffer(m_fbo, dirtyTextureRect, m_multisampledFbo, dirtyTextureRect); - } - - if (m_multisampledFbo) - m_multisampledFbo->release(); - else if (m_fbo) - m_fbo->release(); + m_texture->setImage(m_image); + m_texture->setDirtyRect(dirtyTextureRect); m_dirtyRect = QRect(); } @@ -218,11 +184,7 @@ void QSGDefaultPainterNode::updateTexture() void QSGDefaultPainterNode::updateGeometry() { - QRectF source; - if (m_actualRenderTarget == QQuickPaintedItem::Image) - source = QRectF(0, 0, 1, 1); - else - source = QRectF(0, 0, qreal(m_textureSize.width()) / m_fboSize.width(), qreal(m_textureSize.height()) / m_fboSize.height()); + QRectF source(0, 0, 1, 1); QRectF dest(0, 0, m_size.width(), m_size.height()); if (m_actualRenderTarget == QQuickPaintedItem::InvertedYFramebufferObject) dest = QRectF(QPointF(0, m_size.height()), QPointF(m_size.width(), 0)); @@ -234,112 +196,24 @@ void QSGDefaultPainterNode::updateGeometry() void QSGDefaultPainterNode::updateRenderTarget() { - if (!m_extensionsChecked && !m_context->rhi()) { - QOpenGLExtensions *e = static_cast<QOpenGLExtensions *>(QOpenGLContext::currentContext()->functions()); - m_multisamplingSupported = e->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample) - && e->hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit); - m_extensionsChecked = true; - } - m_dirtyContents = true; - QQuickPaintedItem::RenderTarget oldTarget = m_actualRenderTarget; - if (m_preferredRenderTarget == QQuickPaintedItem::Image) { - m_actualRenderTarget = QQuickPaintedItem::Image; - } else { - // Image is the only option when there is no multisample framebuffer - // support and smooth painting is wanted, and when using the RHI. The - // latter may change in the future. - if ((!m_multisamplingSupported && m_smoothPainting) || m_context->rhi()) - m_actualRenderTarget = QQuickPaintedItem::Image; - else - m_actualRenderTarget = m_preferredRenderTarget; - } - if (oldTarget != m_actualRenderTarget) { - m_image = QImage(); - delete m_fbo; - delete m_multisampledFbo; - delete m_gl_device; - m_fbo = m_multisampledFbo = nullptr; - m_gl_device = nullptr; - } - - if (m_actualRenderTarget == QQuickPaintedItem::FramebufferObject || - m_actualRenderTarget == QQuickPaintedItem::InvertedYFramebufferObject) - { - Q_ASSERT(!m_context->rhi()); - // ### glpurge - const QOpenGLContext *ctx = nullptr; // m_context->openglContext(); - if (m_fbo && !m_dirtyGeometry && (!ctx->format().samples() || !m_multisamplingSupported)) - return; - - if (m_fboSize.isEmpty()) - updateFBOSize(); - - delete m_fbo; - delete m_multisampledFbo; - m_fbo = m_multisampledFbo = nullptr; - if (m_gl_device) - m_gl_device->setSize(m_fboSize); - - if (m_smoothPainting && ctx->format().samples() && m_multisamplingSupported) { - { - QOpenGLFramebufferObjectFormat format; - format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); - format.setSamples(8); - m_multisampledFbo = new QOpenGLFramebufferObject(m_fboSize, format); - } - { - QOpenGLFramebufferObjectFormat format; - format.setAttachment(QOpenGLFramebufferObject::NoAttachment); - m_fbo = new QOpenGLFramebufferObject(m_fboSize, format); - } - } else { - QOpenGLFramebufferObjectFormat format; - format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); - m_fbo = new QOpenGLFramebufferObject(m_fboSize, format); - } - } else { - if (!m_image.isNull() && !m_dirtyGeometry) - return; + m_actualRenderTarget = QQuickPaintedItem::Image; + if (!m_image.isNull() && !m_dirtyGeometry) + return; - m_image = QImage(m_textureSize, QImage::Format_ARGB32_Premultiplied); - m_image.fill(Qt::transparent); - } + m_image = QImage(m_textureSize, QImage::Format_ARGB32_Premultiplied); + m_image.fill(Qt::transparent); QSGPainterTexture *texture = new QSGPainterTexture; - if (m_actualRenderTarget == QQuickPaintedItem::Image) { - texture->setOwnsTexture(true); - texture->setTextureSize(m_textureSize); - } else { - // ### glpurge - //texture->setTextureId(m_fbo->texture()); - texture->setOwnsTexture(false); - texture->setTextureSize(m_fboSize); - } - + texture->setOwnsTexture(true); + texture->setTextureSize(m_textureSize); if (m_texture) delete m_texture; m_texture = texture; } -void QSGDefaultPainterNode::updateFBOSize() -{ - int fboWidth; - int fboHeight; - if (m_fastFBOResizing) { - fboWidth = qMax(QT_MINIMUM_DYNAMIC_FBO_SIZE, qNextPowerOfTwo(m_textureSize.width() - 1)); - fboHeight = qMax(QT_MINIMUM_DYNAMIC_FBO_SIZE, qNextPowerOfTwo(m_textureSize.height() - 1)); - } else { - QSize minimumFBOSize = m_context->sceneGraphContext()->minimumFBOSize(); - fboWidth = qMax(minimumFBOSize.width(), m_textureSize.width()); - fboHeight = qMax(minimumFBOSize.height(), m_textureSize.height()); - } - - m_fboSize = QSize(fboWidth, fboHeight); -} - void QSGDefaultPainterNode::setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target) { if (m_preferredRenderTarget == target) @@ -367,12 +241,7 @@ void QSGDefaultPainterNode::setTextureSize(const QSize &size) return; m_textureSize = size; - updateFBOSize(); - - if (m_fbo) - m_dirtyRenderTarget = m_fbo->size() != m_fboSize || m_dirtyRenderTarget; - else - m_dirtyRenderTarget = true; + m_dirtyRenderTarget = true; m_dirtyGeometry = true; m_dirtyTexture = true; } @@ -453,23 +322,12 @@ void QSGDefaultPainterNode::setFastFBOResizing(bool fastResizing) return; m_fastFBOResizing = fastResizing; - updateFBOSize(); - - if ((m_preferredRenderTarget == QQuickPaintedItem::FramebufferObject - || m_preferredRenderTarget == QQuickPaintedItem::InvertedYFramebufferObject) - && (!m_fbo || (m_fbo && m_fbo->size() != m_fboSize))) { - m_dirtyRenderTarget = true; - m_dirtyGeometry = true; - m_dirtyTexture = true; - } } QImage QSGDefaultPainterNode::toImage() const { - if (m_actualRenderTarget == QQuickPaintedItem::Image) - return m_image; - else - return m_fbo->toImage(); + Q_ASSERT(m_actualRenderTarget == QQuickPaintedItem::Image); + return m_image; } QT_END_NAMESPACE diff --git a/src/quick/scenegraph/util/qsgdefaultpainternode_p.h b/src/quick/scenegraph/util/qsgdefaultpainternode_p.h index c02fdec40b..9ea97ad1ed 100644 --- a/src/quick/scenegraph/util/qsgdefaultpainternode_p.h +++ b/src/quick/scenegraph/util/qsgdefaultpainternode_p.h @@ -61,8 +61,6 @@ QT_BEGIN_NAMESPACE -class QOpenGLFramebufferObject; -class QOpenGLPaintDevice; class QSGDefaultRenderContext; class Q_QUICK_PRIVATE_EXPORT QSGPainterTexture : public QSGPlainTexture @@ -126,7 +124,6 @@ private: void updateTexture(); void updateGeometry(); void updateRenderTarget(); - void updateFBOSize(); QSGDefaultRenderContext *m_context; @@ -135,18 +132,14 @@ private: QQuickPaintedItem *m_item; - QOpenGLFramebufferObject *m_fbo; - QOpenGLFramebufferObject *m_multisampledFbo; QImage m_image; QSGOpaqueTextureMaterial m_material; QSGTextureMaterial m_materialO; QSGGeometry m_geometry; QSGPainterTexture *m_texture; - QOpenGLPaintDevice *m_gl_device; QSize m_size; - QSize m_fboSize; QSize m_textureSize; QRect m_dirtyRect; QColor m_fillColor; @@ -157,7 +150,6 @@ private: bool m_linear_filtering : 1; bool m_mipmapping : 1; bool m_smoothPainting : 1; - bool m_extensionsChecked : 1; bool m_multisamplingSupported : 1; bool m_fastFBOResizing : 1; bool m_dirtyGeometry : 1; |