aboutsummaryrefslogtreecommitdiffstats
path: root/softwarecontext
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-08-25 14:43:59 +0200
committerLars Knoll <lars.knoll@digia.com>2014-08-25 16:25:22 +0300
commitdf23e7804f41ae55598d07d8f36d321a9774ade6 (patch)
treef34ce945a50cab5232395199ae612c3f72f26fda /softwarecontext
parentd3477f8decddb40cc3a64b1e647239dd3579ea16 (diff)
Add support for rendering QSGSimpleTextureNode's
With this change, Canvas works correctly, at least in Image mode. Change-Id: I6641c07b031870dad3c7f9f50ece163724ad429a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'softwarecontext')
-rw-r--r--softwarecontext/context.cpp2
-rw-r--r--softwarecontext/renderingvisitor.cpp27
2 files changed, 20 insertions, 9 deletions
diff --git a/softwarecontext/context.cpp b/softwarecontext/context.cpp
index 1a8b07b1b4..6b72bbfaad 100644
--- a/softwarecontext/context.cpp
+++ b/softwarecontext/context.cpp
@@ -190,7 +190,7 @@ QSGTexture *RenderContext::createTexture(const QImage &image) const
QSGTexture *RenderContext::createTextureNoAtlas(const QImage &image) const
{
- return QSGRenderContext::createTextureNoAtlas(image);
+ return new PixmapTexture(image);
}
QSGRenderer *RenderContext::createRenderer()
diff --git a/softwarecontext/renderingvisitor.cpp b/softwarecontext/renderingvisitor.cpp
index 247c4b7c3b..869ca6d49e 100644
--- a/softwarecontext/renderingvisitor.cpp
+++ b/softwarecontext/renderingvisitor.cpp
@@ -24,8 +24,11 @@
#include "glyphnode.h"
#include "ninepatchnode.h"
#include "painternode.h"
+#include "pixmaptexture.h"
#include <QtQuick/QSGSimpleRectNode>
+#include <QtQuick/qsgsimpletexturenode.h>
+#include <private/qsgtexture_p.h>
RenderingVisitor::RenderingVisitor(QPainter *painter)
: painter(painter)
@@ -59,22 +62,30 @@ void RenderingVisitor::endVisit(QSGClipNode *)
bool RenderingVisitor::visit(QSGGeometryNode *node)
{
- //Check for QSGSimpleRect
- QSGSimpleRectNode *rectNode = 0;
- rectNode = dynamic_cast<QSGSimpleRectNode *>(node);
- if (rectNode) {
+ if (QSGSimpleRectNode *rectNode = dynamic_cast<QSGSimpleRectNode *>(node)) {
if (!rectNode->material()->flags() & QSGMaterial::Blending)
painter->setCompositionMode(QPainter::CompositionMode_Source);
painter->fillRect(rectNode->rect(), rectNode->color());
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
+ } else if (QSGSimpleTextureNode *tn = dynamic_cast<QSGSimpleTextureNode *>(node)) {
+ QSGTexture *texture = tn->texture();
+ if (PixmapTexture *pt = dynamic_cast<PixmapTexture *>(texture)) {
+ const QPixmap &pm = pt->pixmap();
+ painter->drawPixmap(tn->rect(), pm, QRectF(0, 0, pm.width(), pm.height()));
+ } else if (QSGPlainTexture *pt = dynamic_cast<QSGPlainTexture *>(texture)) {
+ const QImage &im = pt->image();
+ painter->drawImage(tn->rect(), im, QRectF(0, 0, im.width(), im.height()));
+ } else {
+ Q_UNREACHABLE();
+ }
+ } else {
+ Q_UNREACHABLE();
}
-
return true;
}
-void RenderingVisitor::endVisit(QSGGeometryNode *node)
+void RenderingVisitor::endVisit(QSGGeometryNode *)
{
-
}
bool RenderingVisitor::visit(QSGOpacityNode *node)
@@ -89,7 +100,7 @@ bool RenderingVisitor::visit(QSGOpacityNode *node)
return true;
}
-void RenderingVisitor::endVisit(QSGOpacityNode *node)
+void RenderingVisitor::endVisit(QSGOpacityNode *)
{
painter->restore();
}