[vlc-devel] commit: skins2(Linux and Win): fix transparency issue at window level ( Erwan Tulou )

git version control git at videolan.org
Thu Jan 7 19:56:24 CET 2010


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Thu Jan  7 13:42:36 2010 +0100| [a2fa93d5f0b1585a12497c4baa0a1321c118998b] | committer: Erwan Tulou 

skins2(Linux and Win): fix transparency issue at window level

When refreshing a window area, the window mask must first be stripped of this
 area, because the new refresh may not result in the same mask being applied.

This patch corrects the following issues :
- an animated bitmap with transparency varying from one subimage to the next
  is now guaranteed the previous subimage won't leave any trace.
- a control that becomes invisible now means transparency is restored
 if no other controls exist for the same area (instead of an undefined and visually unpleasant area)

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

 modules/gui/skins2/src/generic_layout.cpp   |    3 +++
 modules/gui/skins2/src/os_graphics.hpp      |    3 ++-
 modules/gui/skins2/win32/win32_graphics.cpp |   17 +++++++++++++----
 modules/gui/skins2/win32/win32_graphics.hpp |    3 ++-
 modules/gui/skins2/x11/x11_graphics.cpp     |   24 ++++++++++++++++++++----
 modules/gui/skins2/x11/x11_graphics.hpp     |    3 ++-
 6 files changed, 42 insertions(+), 11 deletions(-)

diff --git a/modules/gui/skins2/src/generic_layout.cpp b/modules/gui/skins2/src/generic_layout.cpp
index 00edb2d..8b35371 100644
--- a/modules/gui/skins2/src/generic_layout.cpp
+++ b/modules/gui/skins2/src/generic_layout.cpp
@@ -205,6 +205,9 @@ void GenericLayout::refreshRect( int x, int y, int width, int height )
     if( !m_visible )
         return;
 
+    // update the transparency global mask
+    m_pImage->clear( x, y, width, height );
+
     // Draw all the controls of the layout
     list<LayeredControl>::const_iterator iter;
     list<LayeredControl>::const_iterator iterVideo = m_controlList.end();
diff --git a/modules/gui/skins2/src/os_graphics.hpp b/modules/gui/skins2/src/os_graphics.hpp
index 1a2342f..c8cf28f 100644
--- a/modules/gui/skins2/src/os_graphics.hpp
+++ b/modules/gui/skins2/src/os_graphics.hpp
@@ -40,7 +40,8 @@ public:
     virtual ~OSGraphics() { }
 
     /// Clear the graphics
-    virtual void clear() = 0;
+    virtual void clear( int xDest = 0, int yDest = 0,
+                        int width = -1, int height = -1) = 0;
 
     /// Draw another graphics on this one
     virtual void drawGraphics( const OSGraphics &rGraphics, int xSrc = 0,
diff --git a/modules/gui/skins2/win32/win32_graphics.cpp b/modules/gui/skins2/win32/win32_graphics.cpp
index 00a4f9b..bee4a09 100644
--- a/modules/gui/skins2/win32/win32_graphics.cpp
+++ b/modules/gui/skins2/win32/win32_graphics.cpp
@@ -59,11 +59,20 @@ Win32Graphics::~Win32Graphics()
 }
 
 
-void Win32Graphics::clear()
+void Win32Graphics::clear( int xDest, int yDest, int width, int height )
 {
-    // Clear the transparency mask
-    DeleteObject( m_mask );
-    m_mask = CreateRectRgn( 0, 0, 0, 0 );
+    if( width <= 0 || height <= 0 )
+    {
+        // Clear the transparency mask
+        DeleteObject( m_mask );
+        m_mask = CreateRectRgn( 0, 0, 0, 0 );
+    }
+    else
+    {
+        HRGN mask = CreateRectRgn( xDest, yDest,
+                                   xDest + width, yDest + height );
+        CombineRgn( m_mask, m_mask, mask, RGN_DIFF );
+    }
 }
 
 
diff --git a/modules/gui/skins2/win32/win32_graphics.hpp b/modules/gui/skins2/win32/win32_graphics.hpp
index aa728ad..b3cbd95 100644
--- a/modules/gui/skins2/win32/win32_graphics.hpp
+++ b/modules/gui/skins2/win32/win32_graphics.hpp
@@ -39,7 +39,8 @@ public:
     virtual ~Win32Graphics();
 
     /// Clear the graphics
-    virtual void clear();
+    virtual void clear( int xDest = 0, int yDest = 0,
+                        int width = -1, int height = -1 );
 
     /// Render a bitmap on this graphics
     virtual void drawBitmap( const GenericBitmap &rBitmap, int xSrc = 0,
diff --git a/modules/gui/skins2/x11/x11_graphics.cpp b/modules/gui/skins2/x11/x11_graphics.cpp
index e1b59cf..b3e143d 100644
--- a/modules/gui/skins2/x11/x11_graphics.cpp
+++ b/modules/gui/skins2/x11/x11_graphics.cpp
@@ -73,11 +73,27 @@ X11Graphics::~X11Graphics()
 }
 
 
-void X11Graphics::clear()
+void X11Graphics::clear( int xDest, int yDest, int width, int height )
 {
-    // Clear the transparency mask
-    XDestroyRegion( m_mask );
-    m_mask = XCreateRegion();
+    if( width <= 0 || height <= 0 )
+    {
+        // Clear the transparency mask completely
+        XDestroyRegion( m_mask );
+        m_mask = XCreateRegion();
+    }
+    else
+    {
+        // remove this area from the mask
+        XRectangle rect;
+        rect.x = xDest;
+        rect.y = yDest;
+        rect.width = width;
+        rect.height = height;
+        Region regMask = XCreateRegion();
+        XUnionRectWithRegion( &rect, regMask, regMask );
+        XSubtractRegion( m_mask, regMask, m_mask );
+        XDestroyRegion( regMask );
+    }
 }
 
 
diff --git a/modules/gui/skins2/x11/x11_graphics.hpp b/modules/gui/skins2/x11/x11_graphics.hpp
index 5e75dcf..63881d3 100644
--- a/modules/gui/skins2/x11/x11_graphics.hpp
+++ b/modules/gui/skins2/x11/x11_graphics.hpp
@@ -44,7 +44,8 @@ public:
     virtual ~X11Graphics();
 
     /// Clear the graphics
-    virtual void clear();
+    virtual void clear( int xDest = 0, int yDest = 0,
+                        int width = -1, int height = -1 );
 
     /// Draw another graphics on this one
     virtual void drawGraphics( const OSGraphics &rGraphics, int xSrc = 0,




More information about the vlc-devel mailing list