From 13f28b3c7abda7faac661fdc2500562ab81aa86d Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Tue, 26 Aug 2014 15:29:05 +0200 Subject: 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 --- softwarecontext/painternode.cpp | 11 +++++++++++ softwarecontext/painternode.h | 3 +++ softwarecontext/pixmaptexture.cpp | 5 +++++ softwarecontext/pixmaptexture.h | 1 + 4 files changed, 20 insertions(+) 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 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; -- cgit v1.2.3