Small improvments to FadingNode and IconItem

* trigger an update after the animation finished as the IconItem needs to
  switch to SVGTextureNode again
* Don't connect needlessly to a lambda slot
* FadingMaterialShader had the texture bind swapped
* Fix virtual method hidden warning in FadingMaterialShader
* Use dynamic_cast instead of static_cast to convert to SVGTextureNode
  or FadingNode.

REVIEW: 118251
This commit is contained in:
Martin Gräßlin 2014-05-22 07:53:55 +02:00
parent 167c628665
commit 0d61746784
2 changed files with 10 additions and 10 deletions

View File

@ -37,7 +37,8 @@ public:
virtual const char* fragmentShader() const;
virtual const char* vertexShader() const;
virtual void updateState(const FadingMaterialState* newState, const FadingMaterialState* oldState);
using QSGSimpleMaterialShader<FadingMaterialState>::updateState;
virtual void updateState(const FadingMaterialState* newState, const FadingMaterialState* oldState) override;
virtual QList<QByteArray> attributes() const;
virtual void initialize();
@ -73,8 +74,8 @@ const char* FadingMaterialShader::fragmentShader() const
"void main() {"
"lowp vec4 tex1 = texture2D(u_target, v_coord);"
"lowp vec4 tex2 = texture2D(u_src, v_coord);"
"gl_FragColor.rgb = mix(tex1.rgb, tex2.rgb, u_transitionProgress);"
"gl_FragColor.a = mix(tex1.a, tex2.a, u_transitionProgress) * qt_Opacity;"
"gl_FragColor.rgb = mix(tex2.rgb, tex1.rgb, u_transitionProgress);"
"gl_FragColor.a = mix(tex2.a, tex1.a, u_transitionProgress) * qt_Opacity;"
"}";
}
@ -83,14 +84,14 @@ void FadingMaterialShader::updateState(const FadingMaterialState* newState, cons
{
if (!oldState || oldState->source != newState->source) {
glFuncs->glActiveTexture(GL_TEXTURE1);
newState->target->bind();
newState->source->bind();
// reset the active texture back to 0 after we changed it to something else
glFuncs->glActiveTexture(GL_TEXTURE0);
}
if (!oldState || oldState->target != newState->target) {
glFuncs->glActiveTexture(GL_TEXTURE0);
newState->source->bind();
newState->target->bind();
}
if (!oldState || oldState->progress != newState->progress) {

View File

@ -45,9 +45,7 @@ IconItem::IconItem(QQuickItem *parent)
{
m_loadPixmapTimer.setSingleShot(true);
m_loadPixmapTimer.setInterval(150);
connect(&m_loadPixmapTimer, &QTimer::timeout, [ = ]() {
loadPixmap();
});
connect(&m_loadPixmapTimer, &QTimer::timeout, this, &IconItem::loadPixmap);
m_animation = new QPropertyAnimation(this);
connect(m_animation, SIGNAL(valueChanged(QVariant)),
@ -217,7 +215,7 @@ QSGNode* IconItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *update
}
if (m_animation->state() == QAbstractAnimation::Running) {
FadingNode *animatingNode = static_cast<FadingNode*>(oldNode);
FadingNode *animatingNode = dynamic_cast<FadingNode*>(oldNode);
if (!animatingNode || m_textureChanged) {
delete oldNode;
@ -242,7 +240,7 @@ QSGNode* IconItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *update
return animatingNode;
} else {
Plasma::SVGTextureNode *textureNode = static_cast<Plasma::SVGTextureNode*>(oldNode);
Plasma::SVGTextureNode *textureNode = dynamic_cast<Plasma::SVGTextureNode*>(oldNode);
if (!textureNode || m_textureChanged) {
delete oldNode;
@ -274,6 +272,7 @@ void IconItem::animationFinished()
{
m_oldIconPixmap = QPixmap();
m_textureChanged = true;
update();
}
int IconItem::adjustedSize(int size)