]> git.sesse.net Git - vlc/commitdiff
skins2: fix buttons and checkbox artefacts with animated images
authorErwan Tulou <erwan10@videolan.org>
Wed, 3 Sep 2014 21:31:43 +0000 (23:31 +0200)
committerErwan Tulou <erwan10@videolan.org>
Thu, 4 Sep 2014 12:23:24 +0000 (14:23 +0200)
If down or over images are missing, they default to the up image. Yet, in case
of animated images, the animation gets played leading to undesirable artefacts.

This patch adds a comparison operator for animated images and do not restart the
animation if they are alike.

modules/gui/skins2/controls/ctrl_button.cpp
modules/gui/skins2/controls/ctrl_checkbox.cpp
modules/gui/skins2/src/anim_bitmap.cpp
modules/gui/skins2/src/anim_bitmap.hpp

index 0530bbbefeadf5d451cb2cc5f2dfdcd944bd7af8..06a294416320ed638862daab5b08943ba6b170d8 100644 (file)
@@ -140,6 +140,9 @@ void CtrlButton::setImage( AnimBitmap *pImg )
     if( pImg == m_pImg )
         return;
 
+    if( pImg && m_pImg && *pImg == *m_pImg )
+        return;
+
     AnimBitmap *pOldImg = m_pImg;
     m_pImg = pImg;
 
index 31f35feec59ebdcd720e58215cb9021d089cbc5d..4b065720194ebb4caa5bd98ae7b059e210ad39dc 100644 (file)
@@ -167,6 +167,9 @@ void CtrlCheckbox::setImage( AnimBitmap *pImg )
     if( pImg == m_pImgCurrent )
         return;
 
+    if( pImg && m_pImgCurrent && *pImg == *m_pImgCurrent )
+        return;
+
     AnimBitmap *pOldImg = m_pImgCurrent;
     m_pImgCurrent = pImg;
 
index 0ac5ac4fbd27d286ba3700cc72a0d291d7f35fd9..b01b16d37d0f7e149dab785304c1f635bc38cced 100644 (file)
@@ -121,3 +121,10 @@ void AnimBitmap::CmdNextFrame::execute()
     m_pParent->notify();
 }
 
+bool AnimBitmap::operator ==( const AnimBitmap& rOther ) const
+{
+    return &m_rBitmap == &rOther.m_rBitmap
+        && m_nbFrames == rOther.m_nbFrames
+        && m_frameRate == rOther.m_frameRate
+        && m_nbLoops == rOther.m_nbLoops;
+}
index eea3de9cd13a220dc5a0742a7d15f4ce5c2a08a1..6825544cf054e1d13c727badfb6a5fafdc4ceb70 100644 (file)
@@ -58,6 +58,9 @@ public:
     virtual int getWidth() const;
     virtual int getHeight() const;
 
+    /// compare two animated image
+    bool operator==( const AnimBitmap& other ) const;
+
 private:
     /// Bitmap stored
     const GenericBitmap &m_rBitmap;