]> git.sesse.net Git - vlc/commitdiff
skins2(Linux and Win): fix transparency issue at window level
authorErwan Tulou <erwan10@videolan.org>
Thu, 7 Jan 2010 12:42:36 +0000 (13:42 +0100)
committerErwan Tulou <erwan10@videolan.org>
Thu, 7 Jan 2010 18:48:03 +0000 (19:48 +0100)
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)

modules/gui/skins2/src/generic_layout.cpp
modules/gui/skins2/src/os_graphics.hpp
modules/gui/skins2/win32/win32_graphics.cpp
modules/gui/skins2/win32/win32_graphics.hpp
modules/gui/skins2/x11/x11_graphics.cpp
modules/gui/skins2/x11/x11_graphics.hpp

index 00edb2d8acf7380c6a568ddba127b4caffd29e76..8b353713dd9437219626cf8602de6dab40cc6166 100644 (file)
@@ -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();
index 1a2342ffa2a2012ab06941fe4b6d8c4b0569db08..c8cf28f998fd506da6ddeb03411b8a614b955b3c 100644 (file)
@@ -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,
index 00a4f9b57785d80fed3ce252f3918a178478fc97..bee4a09030db0b16dfc2d5ab71d4e596661af64e 100644 (file)
@@ -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 );
+    }
 }
 
 
index aa728add46676223269838dbe0bb990cc76b5e64..b3cbd95430a036203912426564340dd6feed6ff7 100644 (file)
@@ -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,
index e1b59cf793e885a541246243d2c58107f205fff9..b3e143d8908f4454f15a66084a9f6b1c23a10f9c 100644 (file)
@@ -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 );
+    }
 }
 
 
index 5e75dcfbae1b70b8f2f69d69539b9da436ac4538..63881d38a585298e35f419885832488f515436a6 100644 (file)
@@ -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,