[vlc-commits] skins2: fix buttons and checkbox artefacts with animated images

Erwan Tulou git at videolan.org
Thu Sep 4 14:29:03 CEST 2014


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Wed Sep  3 23:31:43 2014 +0200| [1c101b97678e5e7a34a062916b24fe0b9366a316] | committer: Erwan Tulou

skins2: fix buttons and checkbox artefacts with animated images

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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1c101b97678e5e7a34a062916b24fe0b9366a316
---

 modules/gui/skins2/controls/ctrl_button.cpp   |    3 +++
 modules/gui/skins2/controls/ctrl_checkbox.cpp |    3 +++
 modules/gui/skins2/src/anim_bitmap.cpp        |    7 +++++++
 modules/gui/skins2/src/anim_bitmap.hpp        |    3 +++
 4 files changed, 16 insertions(+)

diff --git a/modules/gui/skins2/controls/ctrl_button.cpp b/modules/gui/skins2/controls/ctrl_button.cpp
index 0530bbb..06a2944 100644
--- a/modules/gui/skins2/controls/ctrl_button.cpp
+++ b/modules/gui/skins2/controls/ctrl_button.cpp
@@ -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;
 
diff --git a/modules/gui/skins2/controls/ctrl_checkbox.cpp b/modules/gui/skins2/controls/ctrl_checkbox.cpp
index 31f35fe..4b06572 100644
--- a/modules/gui/skins2/controls/ctrl_checkbox.cpp
+++ b/modules/gui/skins2/controls/ctrl_checkbox.cpp
@@ -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;
 
diff --git a/modules/gui/skins2/src/anim_bitmap.cpp b/modules/gui/skins2/src/anim_bitmap.cpp
index 0ac5ac4..b01b16d 100644
--- a/modules/gui/skins2/src/anim_bitmap.cpp
+++ b/modules/gui/skins2/src/anim_bitmap.cpp
@@ -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;
+}
diff --git a/modules/gui/skins2/src/anim_bitmap.hpp b/modules/gui/skins2/src/anim_bitmap.hpp
index eea3de9..6825544 100644
--- a/modules/gui/skins2/src/anim_bitmap.hpp
+++ b/modules/gui/skins2/src/anim_bitmap.hpp
@@ -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;



More information about the vlc-commits mailing list