diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-06-03 13:49:51 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-06-22 13:11:14 +0000 |
commit | 65c877f40e965c368fe6e7ed730242461b5824b7 (patch) | |
tree | f23a8b64b5e3530ba5714ce1a0339302e5336ae8 /src/quick/scenegraph/qsgdefaultcontext.cpp | |
parent | 702c4247d74ffb7e4fb1aaca96d70f4591203ba2 (diff) |
Add cross-backend simple rect, texture, and ninepatch nodes
QSGSimpleRectNode is deprecated -> use
QSGRectangleNode via QQuickWindow::createRectangleNode() instead.
QSGSimpleTextureNode is deprecated -> use
QSGImageNode via QQuickWindow::createImageNode() instead.
The OpenGL version of the simple rectangle node is switched over to
the vertex color material instead of flat, to allow for better batching.
Use the same concept for nine patch nodes. The "style" node from Quick Controls 1
is now QSGNinePatchNode in order to provide a proper cross-backend solution which
is already necessary due to the software backend, but now generalize it to apply
to the accelerated backends with proper materials as well. QC can now simply call
createNinePatchNode() without further ado.
Also fixes a bug with the D3D12 texture material not enabling blending
when needed.
When it comes to the internal class names, QSGRectangleNode and
QSGImageNode get the Internal prefix in the adaptation layer in order to
differentiate from the public API. This involves quite a lot of renaming,
but results in a nice and clean public API.
Change-Id: Iddf9f9412377843ea6d652bcf25e68d1d74659ea
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultcontext.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgdefaultcontext.cpp | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/src/quick/scenegraph/qsgdefaultcontext.cpp b/src/quick/scenegraph/qsgdefaultcontext.cpp index f9978e816c..a33f4b174f 100644 --- a/src/quick/scenegraph/qsgdefaultcontext.cpp +++ b/src/quick/scenegraph/qsgdefaultcontext.cpp @@ -40,8 +40,8 @@ #include "qsgdefaultcontext_p.h" #include <QtQuick/private/qsgdistancefieldutil_p.h> -#include <QtQuick/private/qsgdefaultrectanglenode_p.h> -#include <QtQuick/private/qsgdefaultimagenode_p.h> +#include <QtQuick/private/qsgdefaultinternalrectanglenode_p.h> +#include <QtQuick/private/qsgdefaultinternalimagenode_p.h> #include <QtQuick/private/qsgdefaultpainternode_p.h> #include <QtQuick/private/qsgdefaultglyphnode_p.h> #include <QtQuick/private/qsgdistancefieldglyphnode_p.h> @@ -49,6 +49,9 @@ #include <QtQuick/private/qsgrenderloop_p.h> #include <QtQuick/private/qsgdefaultlayer_p.h> #include <QtQuick/private/qsgdefaultrendercontext_p.h> +#include <QtQuick/private/qsgdefaultrectanglenode_p.h> +#include <QtQuick/private/qsgdefaultimagenode_p.h> +#include <QtQuick/private/qsgdefaultninepatchnode_p.h> #include <QtGui/QOpenGLContext> #include <QtGui/QOpenGLFramebufferObject> @@ -60,13 +63,13 @@ QT_BEGIN_NAMESPACE namespace QSGMultisampleAntialiasing { - class ImageNode : public QSGDefaultImageNode { + class ImageNode : public QSGDefaultInternalImageNode { public: void setAntialiasing(bool) { } }; - class RectangleNode : public QSGDefaultRectangleNode { + class RectangleNode : public QSGDefaultInternalRectangleNode { public: void setAntialiasing(bool) { } }; @@ -170,18 +173,18 @@ QSGRenderContext *QSGDefaultContext::createRenderContext() return new QSGDefaultRenderContext(this); } -QSGRectangleNode *QSGDefaultContext::createRectangleNode() +QSGInternalRectangleNode *QSGDefaultContext::createInternalRectangleNode() { return m_antialiasingMethod == MsaaAntialiasing ? new QSGMultisampleAntialiasing::RectangleNode - : new QSGDefaultRectangleNode; + : new QSGDefaultInternalRectangleNode; } -QSGImageNode *QSGDefaultContext::createImageNode() +QSGInternalImageNode *QSGDefaultContext::createInternalImageNode() { return m_antialiasingMethod == MsaaAntialiasing ? new QSGMultisampleAntialiasing::ImageNode - : new QSGDefaultImageNode; + : new QSGDefaultInternalImageNode; } QSGPainterNode *QSGDefaultContext::createPainterNode(QQuickPaintedItem *item) @@ -200,15 +203,6 @@ QSGGlyphNode *QSGDefaultContext::createGlyphNode(QSGRenderContext *rc, bool pref } } -/*! - * Factory function for scene graph backends of the QStyle stylable elements. Returns a - * null pointer if the backend doesn't provide its own node type. - */ -QSGNinePatchNode *QSGDefaultContext::createNinePatchNode() -{ - return nullptr; -} - QSGLayer *QSGDefaultContext::createLayer(QSGRenderContext *renderContext) { return new QSGDefaultLayer(renderContext); @@ -246,6 +240,21 @@ QSGRendererInterface *QSGDefaultContext::rendererInterface(QSGRenderContext *ren return this; } +QSGRectangleNode *QSGDefaultContext::createRectangleNode() +{ + return new QSGDefaultRectangleNode; +} + +QSGImageNode *QSGDefaultContext::createImageNode() +{ + return new QSGDefaultImageNode; +} + +QSGNinePatchNode *QSGDefaultContext::createNinePatchNode() +{ + return new QSGDefaultNinePatchNode; +} + QSGRendererInterface::GraphicsApi QSGDefaultContext::graphicsApi() const { return OpenGL; |