summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@digia.com>2014-08-26 15:29:05 +0200
committerAndy Nichols <andy.nichols@digia.com>2014-08-27 14:05:18 +0300
commit13f28b3c7abda7faac661fdc2500562ab81aa86d (patch)
tree5b058ef72553dda1023fc916f6020ffd5b2df6fe
parentdf23e7804f41ae55598d07d8f36d321a9774ade6 (diff)
Update PainterNode now that QQuickPaintedItem is a texture provider
We now have to return an QSGTexture, which in practice for software context does not mean a whole lot. In this cause it would generally be used for ShaderEffects which we don't support anyway. Change-Id: I63c17327aa541ac853d124daba28e1a512d11ea2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--softwarecontext/painternode.cpp11
-rw-r--r--softwarecontext/painternode.h3
-rw-r--r--softwarecontext/pixmaptexture.cpp5
-rw-r--r--softwarecontext/pixmaptexture.h1
4 files changed, 20 insertions, 0 deletions
diff --git a/softwarecontext/painternode.cpp b/softwarecontext/painternode.cpp
index 714368b675..bf5ec5f202 100644
--- a/softwarecontext/painternode.cpp
+++ b/softwarecontext/painternode.cpp
@@ -18,6 +18,7 @@
**
****************************************************************************/
#include "painternode.h"
+#include "pixmaptexture.h"
#include <qmath.h>
PainterNode::PainterNode(QQuickPaintedItem *item)
@@ -25,6 +26,7 @@ PainterNode::PainterNode(QQuickPaintedItem *item)
, m_preferredRenderTarget(QQuickPaintedItem::Image)
, m_actualRenderTarget(QQuickPaintedItem::Image)
, m_item(item)
+ , m_texture(0)
, m_dirtyContents(false)
, m_opaquePainting(false)
, m_linear_filtering(false)
@@ -41,6 +43,11 @@ PainterNode::PainterNode(QQuickPaintedItem *item)
setGeometry((QSGGeometry*)1);
}
+PainterNode::~PainterNode()
+{
+ delete m_texture;
+}
+
void PainterNode::setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target)
{
if (m_preferredRenderTarget == target)
@@ -132,6 +139,10 @@ void PainterNode::update()
m_pixmap = QPixmap(m_size);
if (!m_opaquePainting)
m_pixmap.fill(Qt::transparent);
+
+ if (m_texture)
+ delete m_texture;
+ m_texture = new PixmapTexture(m_pixmap);
}
if (m_dirtyContents)
diff --git a/softwarecontext/painternode.h b/softwarecontext/painternode.h
index 046ae93d15..db0d03e28a 100644
--- a/softwarecontext/painternode.h
+++ b/softwarecontext/painternode.h
@@ -29,6 +29,7 @@ class PainterNode : public QSGPainterNode
{
public:
PainterNode(QQuickPaintedItem *item);
+ ~PainterNode();
void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target);
@@ -60,6 +61,7 @@ public:
QImage toImage() const;
void update();
+ QSGTexture *texture() const { return m_texture; }
void paint(QPainter *painter);
@@ -73,6 +75,7 @@ private:
QQuickPaintedItem *m_item;
QPixmap m_pixmap;
+ QSGTexture *m_texture;
QSize m_size;
bool m_dirtyContents;
diff --git a/softwarecontext/pixmaptexture.cpp b/softwarecontext/pixmaptexture.cpp
index 25fb41a880..d3dd747a9e 100644
--- a/softwarecontext/pixmaptexture.cpp
+++ b/softwarecontext/pixmaptexture.cpp
@@ -24,6 +24,11 @@ PixmapTexture::PixmapTexture(const QImage &image)
{
}
+PixmapTexture::PixmapTexture(const QPixmap &pixmap)
+ : m_pixmap(pixmap)
+{
+}
+
int PixmapTexture::textureId() const
{
diff --git a/softwarecontext/pixmaptexture.h b/softwarecontext/pixmaptexture.h
index 9337376f41..c3ee09dfe1 100644
--- a/softwarecontext/pixmaptexture.h
+++ b/softwarecontext/pixmaptexture.h
@@ -27,6 +27,7 @@ class PixmapTexture : public QSGTexture
Q_OBJECT
public:
PixmapTexture(const QImage &image);
+ PixmapTexture(const QPixmap &pixmap);
virtual int textureId() const;
virtual QSize textureSize() const;