[vlc-devel] commit: skins2: optimize refresh (Erwan Tulou )

git version control git at videolan.org
Sat Dec 26 23:19:48 CET 2009


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sat Dec 26 21:31:06 2009 +0100| [ce4bddf30723ccff2bbea8015e738339c207003c] | committer: Erwan Tulou 

skins2: optimize refresh

skins2 manages a cache for building layouts. Yet, on each redraw/expose,
it rebuilds the whole layout. This patch avoids these unnecessary rebuilds.
It results in dramatic improvement, especially on Linux, where refresh was a real issue.

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

 modules/gui/skins2/src/generic_layout.cpp |   31 +++++++++++++++++-----------
 modules/gui/skins2/src/top_window.cpp     |    8 +++---
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/modules/gui/skins2/src/generic_layout.cpp b/modules/gui/skins2/src/generic_layout.cpp
index ff695ae..97bb03c 100644
--- a/modules/gui/skins2/src/generic_layout.cpp
+++ b/modules/gui/skins2/src/generic_layout.cpp
@@ -234,17 +234,7 @@ void GenericLayout::refreshRect( int x, int y, int width, int height )
         if( y + height > m_rect.getHeight() )
             height = m_rect.getHeight() - y;
 
-        // Refresh the window... but do not paint on a visible video control!
-        if( !m_pVideoCtrlSet.size() )
-        {
-            // No video control, we can safely repaint the rectangle
-            pWindow->refresh( x, y, width, height );
-        }
-        else
-        {
-            // video control(s) present, we need more calculations
-            computeRefresh( x, y, width, height );
-        }
+        computeRefresh( x, y, width, height );
     }
 }
 
@@ -280,9 +270,23 @@ public:
 
 void GenericLayout::computeRefresh( int x, int y, int width, int height )
 {
+    TopWindow *pWindow = getWindow();
+
+#ifndef WIN32
+
+    pWindow->refresh( x, y, width, height );
+
+#else
+
+    if( !m_pVideoCtrlSet.size() )
+    {
+        // No video control, we can safely repaint the rectangle
+        pWindow->refresh( x, y, width, height );
+        return;
+    }
+
     int w = width;
     int h = height;
-    TopWindow *pWindow = getWindow();
 
     set<int> x_set;
     set<int> y_set;
@@ -355,6 +359,9 @@ void GenericLayout::computeRefresh( int x, int y, int width, int height )
                 pWindow->refresh( x0, y0, w0 ,h0 );
         }
     }
+
+#endif
+
 }
 
 
diff --git a/modules/gui/skins2/src/top_window.cpp b/modules/gui/skins2/src/top_window.cpp
index b7f791b..1b355eb 100644
--- a/modules/gui/skins2/src/top_window.cpp
+++ b/modules/gui/skins2/src/top_window.cpp
@@ -82,10 +82,10 @@ void TopWindow::processEvent( EvtRefresh &rEvtRefresh )
     }
     else
     {
-        m_pActiveLayout->refreshRect( rEvtRefresh.getXStart(),
-                                      rEvtRefresh.getYStart(),
-                                      rEvtRefresh.getWidth(),
-                                      rEvtRefresh.getHeight() );
+        m_pActiveLayout->computeRefresh( rEvtRefresh.getXStart(),
+                                         rEvtRefresh.getYStart(),
+                                         rEvtRefresh.getWidth(),
+                                         rEvtRefresh.getHeight() );
     }
 }
 




More information about the vlc-devel mailing list