diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2011-08-22 11:55:51 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-24 04:23:40 +0200 |
commit | 2d0477537e1a0c06572ef24736ce13d7f56350e6 (patch) | |
tree | f6ceba1a3f43a9a5f2926de27d2dee9eb90306e2 /src/declarative/particles/qsgimageparticle.cpp | |
parent | cd3ae498bfac3cf98f6386f17596d1ec5ed08110 (diff) |
Initial entryEffect support for ImageParticle
Implementation for tabled and above is different, coming in a later
commit.
Change-Id: I7ad16a173521bdcef4ddb68f594be7c942ddb505
Reviewed-on: http://codereview.qt.nokia.com/3280
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'src/declarative/particles/qsgimageparticle.cpp')
-rw-r--r-- | src/declarative/particles/qsgimageparticle.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/declarative/particles/qsgimageparticle.cpp b/src/declarative/particles/qsgimageparticle.cpp index 7a4654112a..aac07b912a 100644 --- a/src/declarative/particles/qsgimageparticle.cpp +++ b/src/declarative/particles/qsgimageparticle.cpp @@ -78,6 +78,7 @@ class ImageMaterialData QSGTexture *opacitytable; qreal timestamp; + qreal entry; qreal framecount; qreal animcount; }; @@ -120,6 +121,7 @@ public: program()->setUniformValue("opacitytable", 3); glFuncs = QGLContext::currentContext()->functions(); m_timestamp_id = program()->uniformLocation("timestamp"); + m_entry_id = program()->uniformLocation("entry"); } void updateState(const TabledMaterialData* d, const TabledMaterialData*) { @@ -139,8 +141,10 @@ public: program()->setUniformValue(m_timestamp_id, (float) d->timestamp); program()->setUniformValue("framecount", (float) 1); program()->setUniformValue("animcount", (float) 1); + program()->setUniformValue(m_entry_id, (float) d->entry); } + int m_entry_id; int m_timestamp_id; QByteArray m_vertex_code; QByteArray m_fragment_code; @@ -181,6 +185,7 @@ public: program()->setUniformValue("texture", 0); glFuncs = QGLContext::currentContext()->functions(); m_timestamp_id = program()->uniformLocation("timestamp"); + m_entry_id = program()->uniformLocation("entry"); } void updateState(const DeformableMaterialData* d, const DeformableMaterialData*) { @@ -188,8 +193,10 @@ public: d->texture->bind(); program()->setUniformValue(m_timestamp_id, (float) d->timestamp); + program()->setUniformValue(m_entry_id, (float) d->entry); } + int m_entry_id; int m_timestamp_id; QByteArray m_vertex_code; QByteArray m_fragment_code; @@ -235,6 +242,7 @@ public: m_timestamp_id = program()->uniformLocation("timestamp"); m_framecount_id = program()->uniformLocation("framecount"); m_animcount_id = program()->uniformLocation("animcount"); + m_entry_id = program()->uniformLocation("entry"); } void updateState(const SpriteMaterialData* d, const SpriteMaterialData*) { @@ -254,11 +262,13 @@ public: program()->setUniformValue(m_timestamp_id, (float) d->timestamp); program()->setUniformValue(m_framecount_id, (float) d->framecount); program()->setUniformValue(m_animcount_id, (float) d->animcount); + program()->setUniformValue(m_entry_id, (float) d->entry); } int m_timestamp_id; int m_framecount_id; int m_animcount_id; + int m_entry_id; QByteArray m_vertex_code; QByteArray m_fragment_code; QGLFunctions* glFuncs; @@ -313,6 +323,7 @@ public: program()->setUniformValue("texture", 0); glFuncs = QGLContext::currentContext()->functions(); m_timestamp_id = program()->uniformLocation("timestamp"); + m_entry_id = program()->uniformLocation("entry"); } void updateState(const ColoredMaterialData* d, const ColoredMaterialData*) { @@ -320,9 +331,11 @@ public: d->texture->bind(); program()->setUniformValue(m_timestamp_id, (float) d->timestamp); + program()->setUniformValue(m_entry_id, (float) d->entry); } int m_timestamp_id; + int m_entry_id; QByteArray m_vertex_code; QByteArray m_fragment_code; QGLFunctions* glFuncs; @@ -377,6 +390,7 @@ public: program()->setUniformValue("texture", 0); glFuncs = QGLContext::currentContext()->functions(); m_timestamp_id = program()->uniformLocation("timestamp"); + m_entry_id = program()->uniformLocation("entry"); } void updateState(const SimpleMaterialData* d, const SimpleMaterialData*) { @@ -384,9 +398,11 @@ public: d->texture->bind(); program()->setUniformValue(m_timestamp_id, (float) d->timestamp); + program()->setUniformValue(m_entry_id, (float) d->entry); } int m_timestamp_id; + int m_entry_id; QByteArray m_vertex_code; QByteArray m_fragment_code; QGLFunctions* glFuncs; @@ -463,6 +479,21 @@ public: /*! \qmlproperty list<Sprite> QtQuick.Particles2::ImageParticle::sprites */ +/*! + \qmlproperty EntryEffect QtQuick.Particles2::ImageParticle::entryEffect + + This property provides basic and cheap entrance and exit effects for the particles. + For fine-grained control, see sizeTable and opacityTable. + + Acceptable values are + \list + \o None: Particles just appear and disappear. + \o Fade: Particles fade in from 0. opacity at the start of their life, and fade out to 0. at the end. + \o Scale: Particles scale in from 0 size at the start of their life, and scale back to 0 at the end. + \endlist + + Default value is Fade. +*/ QSGImageParticle::QSGImageParticle(QSGItem* parent) @@ -488,6 +519,7 @@ QSGImageParticle::QSGImageParticle(QSGItem* parent) , perfLevel(Unknown) , m_lastLevel(Unknown) , m_debugMode(false) + , m_entryEffect(Fade) { setFlag(ItemHasContents); m_debugMode = qmlParticlesDebug(); @@ -690,6 +722,16 @@ void QSGImageParticle::setBloat(bool arg) reset(); } +void QSGImageParticle::setEntryEffect(EntryEffect arg) +{ + if (m_entryEffect != arg) { + m_entryEffect = arg; + if (m_material) + getState<ImageMaterialData>(m_material)->entry = (qreal) m_entryEffect; + emit entryEffectChanged(arg); + } +} + void QSGImageParticle::reset() { QSGParticlePainter::reset(); @@ -859,6 +901,7 @@ QSGGeometryNode* QSGImageParticle::buildParticleNodes() m_material = SimpleMaterial::createMaterial(); getState<ImageMaterialData>(m_material)->texture = sceneGraphEngine()->createTextureFromImage(image); getState<ImageMaterialData>(m_material)->texture->setFiltering(QSGTexture::Linear); + getState<ImageMaterialData>(m_material)->entry = (qreal) m_entryEffect; m_material->setFlag(QSGMaterial::Blending); } |