summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@live.com>2014-02-03 14:38:33 -0600
committerGunnar Sletta <gunnar.sletta@jollamobile.com>2014-02-05 15:57:14 +0100
commit41c6700014614ba30982840cefef8df0178fa7ba (patch)
tree2148ec80d966b2144a392e9c5f19faa90de94f39
parent96fff79274a3ff0922fdc2e253725bbe832866de (diff)
Make nonpreservedtexture work with Qt 5.2.
Change-Id: I2a51af6833f2d651e5a3b456197594f722fac741 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
-rw-r--r--customcontext/context.h4
-rw-r--r--customcontext/customcontext.pro19
-rw-r--r--customcontext/texture/nonpreservedtexture.cpp15
3 files changed, 25 insertions, 13 deletions
diff --git a/customcontext/context.h b/customcontext/context.h
index 9169eb5..f975fd4 100644
--- a/customcontext/context.h
+++ b/customcontext/context.h
@@ -148,13 +148,13 @@ private:
bool m_threadUploadTexture;
#endif
+#endif // Qt < 5.2.0
+
#ifdef CUSTOMCONTEXT_NONPRESERVEDTEXTURE
bool m_nonPreservedTexture;
friend class NonPreservedTextureFactory;
#endif
-#endif // Qt < 5.2.0
-
#ifdef CUSTOMCONTEXT_ANIMATIONDRIVER
bool m_animationDriver;
#endif
diff --git a/customcontext/customcontext.pro b/customcontext/customcontext.pro
index aae5660..a60ac0b 100644
--- a/customcontext/customcontext.pro
+++ b/customcontext/customcontext.pro
@@ -75,19 +75,20 @@ dither:{
} else {
message("mactexture ...............: no")
}
+}
- nonpreservedtexture:{
- message("nonpreservedtexture ......: yes")
- DEFINES += CUSTOMCONTEXT_NONPRESERVEDTEXTURE
- SOURCES += texture/nonpreservedtexture.cpp
- HEADERS += texture/nonpreservedtexture.h
- INCLUDEPATH += texture
- } else {
- message("nonpreservedtexture ......: no")
- }
+nonpreservedtexture:{
+ message("nonpreservedtexture ......: yes")
+ DEFINES += CUSTOMCONTEXT_NONPRESERVEDTEXTURE
+ SOURCES += texture/nonpreservedtexture.cpp
+ HEADERS += texture/nonpreservedtexture.h
+ INCLUDEPATH += texture
+} else {
+ message("nonpreservedtexture ......: no")
}
+
############################################################
#
# Animation Drivers
diff --git a/customcontext/texture/nonpreservedtexture.cpp b/customcontext/texture/nonpreservedtexture.cpp
index 004e90b..94dba64 100644
--- a/customcontext/texture/nonpreservedtexture.cpp
+++ b/customcontext/texture/nonpreservedtexture.cpp
@@ -2,6 +2,7 @@
#include "context.h"
#include <private/qsgtexture_p.h>
+#include <private/qquickwindow_p.h>
namespace CustomContext {
@@ -22,20 +23,30 @@ NonPreservedTextureFactory::NonPreservedTextureFactory(const QImage &image, Cont
m_byteCount = m_image.byteCount();
}
-QSGTexture *NonPreservedTextureFactory::createTexture(QQuickWindow *) const
+QSGTexture *NonPreservedTextureFactory::createTexture(QQuickWindow *window) const
{
+#if QT_VERSION >= 0x050200
+ Q_ASSERT(window);
+ QSGRenderContext *renderContext = static_cast<QQuickWindowPrivate *>(QObjectPrivate::get(window))->context;
+ Q_ASSERT(renderContext);
+ QSGTexture *texture = renderContext->createTexture(m_image);
+ m_image = QImage(); // remove the reference to the QImage
+ return texture;
+#else
+ Q_UNUSED(window);
#ifdef CUSTOMCONTEXT_ATLASTEXTURE
if (m_context->m_atlasTexture) {
QSGTexture *atlasedTexture = m_context->m_atlasManager.create(m_image);
if (atlasedTexture)
return atlasedTexture;
}
-#endif
+#endif //CUSTOMCONTEXT_ATLASTEXTURE
QSGPlainTexture *t = new QSGPlainTexture();
t->setImage(m_image);
m_image = QImage();
return t;
+#endif //QT_VERSION
}
} // end of namespace