[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [plasma-framework] src/declarativeimports/core: Small improvments to FadingNode and IconItem
From:       Martin_Gräßlin <mgraesslin () kde ! org>
Date:       2014-06-11 5:59:37
Message-ID: E1WubZR-00073g-Dg () scm ! kde ! org
[Download RAW message or body]

Git commit 0d61746784629cb9f6b8c67e06a7ff49b5dc8732 by Martin Gräßlin.
Committed on 22/05/2014 at 05:53.
Pushed by graesslin into branch 'master'.

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

M  +6    -5    src/declarativeimports/core/fadingnode.cpp
M  +4    -5    src/declarativeimports/core/iconitem.cpp

http://commits.kde.org/plasma-framework/0d61746784629cb9f6b8c67e06a7ff49b5dc8732

diff --git a/src/declarativeimports/core/fadingnode.cpp \
b/src/declarativeimports/core/fadingnode.cpp index 207eff3..0c41ec1 100644
--- a/src/declarativeimports/core/fadingnode.cpp
+++ b/src/declarativeimports/core/fadingnode.cpp
@@ -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) {
diff --git a/src/declarativeimports/core/iconitem.cpp \
b/src/declarativeimports/core/iconitem.cpp index 384017d..cdb442d 100644
--- a/src/declarativeimports/core/iconitem.cpp
+++ b/src/declarativeimports/core/iconitem.cpp
@@ -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)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic