]> git.sesse.net Git - vlc/commitdiff
* os_graphics.hpp: added a parameter "blend" to drawBitmap(), to perform alpha
authorCyril Deguet <asmax@videolan.org>
Sun, 1 May 2005 13:19:04 +0000 (13:19 +0000)
committerCyril Deguet <asmax@videolan.org>
Sun, 1 May 2005 13:19:04 +0000 (13:19 +0000)
  blending only when it is useful (i.e. when drawing antialiased text)
* x11/*: optimized drawBitmap when alpha blending is not used: 5 times faster

13 files changed:
modules/gui/skins2/controls/ctrl_list.cpp
modules/gui/skins2/controls/ctrl_text.cpp
modules/gui/skins2/macosx/macosx_loop.cpp
modules/gui/skins2/macosx/macosx_loop.hpp
modules/gui/skins2/src/ft2_bitmap.cpp
modules/gui/skins2/src/os_graphics.hpp
modules/gui/skins2/src/tooltip.cpp
modules/gui/skins2/win32/win32_graphics.cpp
modules/gui/skins2/win32/win32_graphics.hpp
modules/gui/skins2/x11/x11_display.cpp
modules/gui/skins2/x11/x11_display.hpp
modules/gui/skins2/x11/x11_graphics.cpp
modules/gui/skins2/x11/x11_graphics.hpp

index ddb29d41f21e9cafc32cc63fa88cfe3997a0a308..50fee9217ee8f94a71241cb25382074fc52dbf87 100644 (file)
@@ -471,7 +471,7 @@ void CtrlList::makeImage()
         }
         int lineHeight = __MIN( pText->getHeight() - ySrc, height - yPos );
         m_pImage->drawBitmap( *pText, 0, ySrc, 0, yPos, pText->getWidth(),
-                              lineHeight );
+                              lineHeight, true );
         yPos += (pText->getHeight() - ySrc );
         delete pText;
 
index 7cd218655be7c0f235f853fb081e2cfc15657974..838e8f8559ad20195c4041680d5c08a509254757 100644 (file)
@@ -160,7 +160,7 @@ void CtrlText::draw( OSGraphics &rImage, int xDest, int yDest )
         if( width > 0 && height > 0 )
         {
             rImage.drawBitmap( *m_pCurrImg, -m_xPos, 0, xDest, yDest,
-                            width, height );
+                            width, height, true );
         }
     }
 }
index 7133f13ea66f3c766e065c178be012cfd935de79..1e5c94dc7e5b17cc482b1267151084089e4f91c7 100644 (file)
 
 #ifdef MACOSX_SKINS
 
+#include <Carbon/Carbon.h>
 #include "macosx_loop.hpp"
 
 
 MacOSXLoop::MacOSXLoop( intf_thread_t *pIntf ):
-    OSLoop( pIntf )
+    OSLoop( pIntf ), m_exit( false )
 {
-    // TODO
 }
 
 
 MacOSXLoop::~MacOSXLoop()
 {
-    // TODO
 }
 
 
@@ -62,13 +61,58 @@ void MacOSXLoop::destroy( intf_thread_t *pIntf )
 
 void MacOSXLoop::run()
 {
-    // TODO
+    // Main event loop
+    while( !m_exit )
+    {
+        EventRef pEvent;
+        OSStatus err = ReceiveNextEvent( 0, NULL, kEventDurationForever, true,
+                                         &pEvent );
+        if( err != noErr )
+        {
+            // Get the event type
+            UInt32 evClass = GetEventClass( pEvent );
+
+            switch( evClass )
+            {
+                case kEventClassMouse:
+                {
+                    break;
+                }
+
+                case kEventClassKeyboard:
+                {
+                    break;
+                }
+
+                case kEventClassWindow:
+                {
+                    handleWindowEvent( pEvent );
+                    break;
+                }
+
+                default:
+                {
+                    EventTargetRef pTarget;
+                    pTarget = GetEventDispatcherTarget();
+                    SendEventToEventTarget( pEvent, pTarget );
+                    ReleaseEvent( pEvent );
+                }
+            }
+        }
+    }
 }
 
 
 void MacOSXLoop::exit()
 {
-    // TODO
+    m_exit = true;
+}
+
+
+void MacOSXLoop::handleWindowEvent( EventRef pEvent )
+{
+    UInt32 evKind = GetEventKind( pEvent );
+
 }
 
 
index 27291006f902099eb95e2160682a3c1ddab5c933..76ec12ba7f47eec92f3961642b66cd32cb80f008 100644 (file)
@@ -49,6 +49,11 @@ class MacOSXLoop: public OSLoop
         // Private because it's a singleton
         MacOSXLoop( intf_thread_t *pIntf );
         virtual ~MacOSXLoop();
+        // Flag set to exit the loop
+        bool m_exit;
+
+        // Handle a window event
+        void handleWindowEvent( EventRef pEvent );
 };
 
 #endif
index ebd7e5466490c4b240789e64222edb9b2f5b110a..c2de698b29b80716d41af663309babc4d856022b 100644 (file)
@@ -60,9 +60,9 @@ void FT2Bitmap::draw( const FT_Bitmap &rBitmap, int left, int top,
         {
             // The buffer in FT_Bitmap contains alpha values
             uint8_t val = *(pBuf++);
-            *(pData++) = blue;
-            *(pData++) = green;
-            *(pData++) = red;
+            *(pData++) = (blue * val) >> 8;
+            *(pData++) = (green * val) >> 8;
+            *(pData++) = (red * val) >> 8;
             *(pData++) = val;
         }
     }
index 92bf1a518ff6ccd63aaf649e7d7577f70b88113c..430fad13b0107f3a239b5a7a2c4cd61c25945351 100644 (file)
@@ -49,7 +49,8 @@ class OSGraphics: public SkinObject
         /// Render a bitmap on this graphics
         virtual void drawBitmap( const GenericBitmap &rBitmap, int xSrc = 0,
                                  int ySrc = 0, int xDest = 0, int yDest = 0,
-                                 int width = -1, int height = -1 ) = 0;
+                                 int width = -1, int height = -1,
+                                 bool blend = false) = 0;
 
         /// Draw a filled rectangle on the grahics (color is #RRGGBB)
         virtual void fillRect( int left, int top, int width, int height,
index b23571dd8831b09bd9e0cad17c76d1f512f691a8..64683e110272907dc841f1b74274db62b0a5d7e4 100644 (file)
@@ -113,7 +113,7 @@ void Tooltip::makeImage( const UString &rText )
     m_pImage = OSFactory::instance( getIntf() )->createOSGraphics( w, h );
     m_pImage->fillRect( 0, 0, w, h, 0xffffd0 );
     m_pImage->drawRect( 0, 0, w, h, 0x000000 );
-    m_pImage->drawBitmap( *pBmpTip, 0, 0, 5, 5 );
+    m_pImage->drawBitmap( *pBmpTip, 0, 0, 5, 5, -1, -1, true );
 
     delete pBmpTip;
 }
index 9e2cbe517bcc38f7f0b720e3b4895430a9171d70..43fbe2d4018a4f28a4f7dac3d35c04b772b7fa2b 100644 (file)
@@ -68,7 +68,7 @@ void Win32Graphics::clear()
 
 void Win32Graphics::drawBitmap( const GenericBitmap &rBitmap,
                                 int xSrc, int ySrc, int xDest, int yDest,
-                                int width, int height )
+                                int width, int height, bool blend )
 {
     // Get the bitmap size if necessary
     if( width == -1 )
index 41ac1f02af3cedb578b3ed32256bb3e6d6680aef..ce464b8612264d1a6d8ada269acbc8bf177d23d4 100644 (file)
@@ -44,7 +44,8 @@ class Win32Graphics: public OSGraphics
         /// Render a bitmap on this graphics
         virtual void drawBitmap( const GenericBitmap &rBitmap, int xSrc = 0,
                                  int ySrc = 0, int xDest = 0, int yDest = 0,
-                                 int width = -1, int height = -1 );
+                                 int width = -1, int height = -1,
+                                 bool blend = false );
 
         /// Draw another graphics on this one
         virtual void drawGraphics( const OSGraphics &rGraphics, int xSrc = 0,
index e5a61b8f7ca506440a8a18e1ae427febb218f3aa..594b503bc92d4c5e6da4ff72b14135dca1d42f6c 100644 (file)
 #include "x11_display.hpp"
 #include "../src/logger.hpp"
 
+// Macro to compute a pixel value
+#define PUT_PIXEL(value, r, g, b, type) \
+    value = \
+        ( ((type)r >> m_redRightShift) << m_redLeftShift ) | \
+        ( ((type)g >> m_greenRightShift) << m_greenLeftShift ) | \
+        ( ((type)b >> m_blueRightShift) << m_blueLeftShift );
+
+// Macro to blend a pixel with another color
+#define BLEND_PIXEL(value, r, g, b, a, type) \
+    uint16_t temp; \
+    temp = ((uint8_t)((value >> m_redLeftShift) << m_redRightShift)); \
+    uint8_t red = r + ( temp * (255 - a) ) / 255; \
+    temp = ((uint8_t)((value >> m_greenLeftShift) << m_greenRightShift)); \
+    uint8_t green = g + ( temp * (255 - a) ) / 255; \
+    temp = ((uint8_t)((value >> m_blueLeftShift) << m_blueRightShift)); \
+    uint8_t blue = b + ( temp * (255 - a) ) / 255; \
+    PUT_PIXEL(value, red, green, blue, type)
+
 
 X11Display::X11Display( intf_thread_t *pIntf ): SkinObject( pIntf ),
     m_mainWindow( 0 ), m_gc( NULL ), m_colormap( 0 )
@@ -52,6 +70,7 @@ X11Display::X11Display( intf_thread_t *pIntf ): SkinObject( pIntf ),
     int screen = DefaultScreen( m_pDisplay );
     int depth = DefaultDepth( m_pDisplay, screen );
     int order = ImageByteOrder( m_pDisplay );
+    Window root = DefaultRootWindow( m_pDisplay );
 
     // Template for looking up the XVisualInfo
     XVisualInfo xVInfoTemplate;
@@ -84,8 +103,7 @@ X11Display::X11Display( intf_thread_t *pIntf ): SkinObject( pIntf ),
             getShifts( pVInfo->blue_mask, m_blueLeftShift, m_blueRightShift );
 
             // Create a color map
-            m_colormap = XCreateColormap( m_pDisplay,
-                    DefaultRootWindow( m_pDisplay ),
+            m_colormap = XCreateColormap( m_pDisplay, root,
                     DefaultVisual( m_pDisplay, screen ), AllocAll );
 
             // Create the palette
@@ -97,12 +115,16 @@ X11Display::X11Display( intf_thread_t *pIntf ): SkinObject( pIntf ),
                 pColors[i].pixel = 254-i;
                 pColors[i].pad   = 0;
                 pColors[i].flags = DoRed | DoGreen | DoBlue;
-                pColors[i].red   = (i >> m_redLeftShift) << (m_redRightShift + 8);
-                pColors[i].green = (i >> m_greenLeftShift) << (m_greenRightShift + 8);
-                pColors[i].blue  = (i >> m_blueLeftShift) << (m_blueRightShift + 8);
+                pColors[i].red   =
+                    (i >> m_redLeftShift) << (m_redRightShift + 8);
+                pColors[i].green =
+                    (i >> m_greenLeftShift) << (m_greenRightShift + 8);
+                pColors[i].blue  =
+                    (i >> m_blueLeftShift) << (m_blueRightShift + 8);
             }
             XStoreColors( m_pDisplay, m_colormap, pColors, 255 );
-            makePixelImpl = &X11Display::makePixel8;
+            blendPixelImpl = &X11Display::blendPixel8;
+            putPixelImpl = &X11Display::putPixel8;
             m_pixelSize = 1;
             break;
 
@@ -130,21 +152,17 @@ X11Display::X11Display( intf_thread_t *pIntf ): SkinObject( pIntf ),
                        m_greenRightShift );
             getShifts( pVInfo->blue_mask, m_blueLeftShift, m_blueRightShift );
 
-            if( depth == 8 )
-            {
-                makePixelImpl = &X11Display::makePixel8;
-                m_pixelSize = 1;
-            }
-
             if( depth == 15 || depth == 16 )
             {
                 if( order == MSBFirst )
                 {
-                    makePixelImpl = &X11Display::makePixel16MSB;
+                    blendPixelImpl = &X11Display::blendPixel16MSB;
+                    putPixelImpl = &X11Display::putPixel16MSB;
                 }
                 else
                 {
-                    makePixelImpl = &X11Display::makePixel16LSB;
+                    blendPixelImpl = &X11Display::blendPixel16LSB;
+                    putPixelImpl = &X11Display::putPixel16LSB;
                 }
                 m_pixelSize = 2;
             }
@@ -152,11 +170,13 @@ X11Display::X11Display( intf_thread_t *pIntf ): SkinObject( pIntf ),
             {
                 if( order == MSBFirst )
                 {
-                    makePixelImpl = &X11Display::makePixel32MSB;
+                    blendPixelImpl = &X11Display::blendPixel32MSB;
+                    putPixelImpl = &X11Display::putPixel32MSB;
                 }
                 else
                 {
-                    makePixelImpl = &X11Display::makePixel32LSB;
+                    blendPixelImpl = &X11Display::blendPixel32LSB;
+                    putPixelImpl = &X11Display::putPixel32LSB;
                 }
                 m_pixelSize = 4;
             }
@@ -179,14 +199,12 @@ X11Display::X11Display( intf_thread_t *pIntf ): SkinObject( pIntf ),
     {
         XGCValues xgcvalues;
         xgcvalues.graphics_exposures = False;
-        m_gc = XCreateGC( m_pDisplay, DefaultRootWindow( m_pDisplay ),
-                          GCGraphicsExposures, &xgcvalues );
+        m_gc = XCreateGC( m_pDisplay, root, GCGraphicsExposures, &xgcvalues );
 
         // Create a parent window to have a single task in the task bar
         XSetWindowAttributes attr;
-        m_mainWindow = XCreateWindow( m_pDisplay, DefaultRootWindow( m_pDisplay),
-                                      0, 0, 1, 1, 0, 0, InputOutput,
-                                      CopyFromParent, 0, &attr );
+        m_mainWindow = XCreateWindow( m_pDisplay, root, 0, 0, 1, 1, 0, 0,
+                                      InputOutput, CopyFromParent, 0, &attr );
 
         // Changing decorations
         struct {
@@ -264,150 +282,138 @@ void X11Display::getShifts( uint32_t mask, int &rLeftShift,
 }
 
 
-void X11Display::makePixel8( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
-                             uint8_t a ) const
+void X11Display::blendPixel8( uint8_t *pPixel, uint8_t r, uint8_t g,
+                              uint8_t b, uint8_t a ) const
 {
-    // Get the current pixel value
     uint8_t value = 255 - *pPixel;
 
-    // Compute the new color values
-    uint16_t temp;
-    temp = ((uint8_t)((value >> m_redLeftShift) << m_redRightShift));
-    uint8_t red = ( temp * (255 - a) + r * a ) / 255;
-    temp = ((uint8_t)((value >> m_greenLeftShift) << m_greenRightShift));
-    uint8_t green = ( temp * (255 - a) + g * a ) / 255;
-    temp = ((uint8_t)((value >> m_blueLeftShift) << m_blueRightShift));
-    uint8_t blue = ( temp * (255 - a) + b * a ) / 255;
-
-    // Set the new pixel value
-    value =
-        ( ((uint8_t)red >> m_redRightShift) << m_redLeftShift ) |
-        ( ((uint8_t)green >> m_greenRightShift) << m_greenLeftShift ) |
-        ( ((uint8_t)blue >> m_blueRightShift) << m_blueLeftShift );
+    BLEND_PIXEL(value, r, g, b, a, uint8_t)
 
     *pPixel = 255 - value;
 }
 
 
-void X11Display::makePixel16MSB( uint8_t *pPixel, uint8_t r, uint8_t g,
-                                 uint8_t b, uint8_t a ) const
+void X11Display::blendPixel16MSB( uint8_t *pPixel, uint8_t r, uint8_t g,
+                                  uint8_t b, uint8_t a ) const
 {
-    // Get the current pixel value
     uint16_t value = pPixel[1] | pPixel[0] << 8;
 
-    // Compute the new color values
-    uint16_t temp;
-    temp = ((uint8_t)((value >> m_redLeftShift) << m_redRightShift));
-    uint8_t red = ( temp * (255 - a) + r * a ) / 255;
-    temp = ((uint8_t)((value >> m_greenLeftShift) << m_greenRightShift));
-    uint8_t green = ( temp * (255 - a) + g * a ) / 255;
-    temp = ((uint8_t)((value >> m_blueLeftShift) << m_blueRightShift));
-    uint8_t blue = ( temp * (255 - a) + b * a ) / 255;
-
-    // Set the new pixel value
-    value =
-        ( ((uint16_t)red >> m_redRightShift) << m_redLeftShift ) |
-        ( ((uint16_t)green >> m_greenRightShift) << m_greenLeftShift ) |
-        ( ((uint16_t)blue >> m_blueRightShift) << m_blueLeftShift );
+    BLEND_PIXEL(value, r, g, b, a, uint16_t)
 
-    pPixel[1] = value;
-    value >>= 8;
+    pPixel[1] = value; value >>= 8;
     pPixel[0] = value;
 }
 
 
-void X11Display::makePixel16LSB( uint8_t *pPixel, uint8_t r, uint8_t g,
-                                 uint8_t b, uint8_t a ) const
+void X11Display::blendPixel16LSB( uint8_t *pPixel, uint8_t r, uint8_t g,
+                                  uint8_t b, uint8_t a ) const
 {
-    // Get the current pixel value
     uint16_t value = pPixel[0] | pPixel[1] << 8;
 
-    // Compute the new color values
-    uint16_t temp;
-    temp = ((uint8_t)((value >> m_redLeftShift) << m_redRightShift));
-    uint8_t red = ( temp * (255 - a) + r * a ) / 255;
-    temp = ((uint8_t)((value >> m_greenLeftShift) << m_greenRightShift));
-    uint8_t green = ( temp * (255 - a) + g * a ) / 255;
-    temp = ((uint8_t)((value >> m_blueLeftShift) << m_blueRightShift));
-    uint8_t blue = ( temp * (255 - a) + b * a ) / 255;
-
-    // Set the new pixel value
-    value =
-        ( ((uint16_t)red >> m_redRightShift) << m_redLeftShift ) |
-        ( ((uint16_t)green >> m_greenRightShift) << m_greenLeftShift ) |
-        ( ((uint16_t)blue >> m_blueRightShift) << m_blueLeftShift );
+    BLEND_PIXEL(value, r, g, b, a, uint16_t)
 
-    pPixel[0] = value;
-    value >>= 8;
+    pPixel[0] = value; value >>= 8;
     pPixel[1] = value;
 }
 
 
-void X11Display::makePixel32MSB( uint8_t *pPixel, uint8_t r, uint8_t g,
-                                 uint8_t b, uint8_t a ) const
+void X11Display::blendPixel32MSB( uint8_t *pPixel, uint8_t r, uint8_t g,
+                                  uint8_t b, uint8_t a ) const
 {
-    // Get the current pixel value
     uint32_t value = pPixel[3] | pPixel[2] << 8 | pPixel[1] << 16 |
                           pPixel[0] << 24;
 
-    // Compute the new color values
-    uint16_t temp;
-    temp = ((uint8_t)((value >> m_redLeftShift) << m_redRightShift));
-    uint8_t red = ( temp * (255 - a) + r * a ) / 255;
-    temp = ((uint8_t)((value >> m_greenLeftShift) << m_greenRightShift));
-    uint8_t green = ( temp * (255 - a) + g * a ) / 255;
-    temp = ((uint8_t)((value >> m_blueLeftShift) << m_blueRightShift));
-    uint8_t blue = ( temp * (255 - a) + b * a ) / 255;
-
-    // Set the new pixel value
-    value =
-        ( ((uint32_t)red >> m_redRightShift) << m_redLeftShift ) |
-        ( ((uint32_t)green >> m_greenRightShift) << m_greenLeftShift ) |
-        ( ((uint32_t)blue >> m_blueRightShift) << m_blueLeftShift );
+    BLEND_PIXEL(value, r, g, b, a, uint32_t)
 
-    pPixel[3] = value;
-    value >>= 8;
-    pPixel[2] = value;
-    value >>= 8;
-    pPixel[1] = value;
-    value >>= 8;
+    pPixel[3] = value; value >>= 8;
+    pPixel[2] = value; value >>= 8;
+    pPixel[1] = value; value >>= 8;
     pPixel[0] = value;
 }
 
 
-void X11Display::makePixel32LSB( uint8_t *pPixel, uint8_t r, uint8_t g,
-                                 uint8_t b, uint8_t a ) const
+void X11Display::blendPixel32LSB( uint8_t *pPixel, uint8_t r, uint8_t g,
+                                  uint8_t b, uint8_t a ) const
 {
-    // Get the current pixel value
     uint32_t value = pPixel[0] | pPixel[1] << 8 | pPixel[2] << 16 |
                           pPixel[3] << 24;
 
-    // Compute the new color values
-    uint16_t temp;
-    temp = ((uint8_t)((value >> m_redLeftShift) << m_redRightShift));
-    uint8_t red = ( temp * (255 - a) + r * a ) / 255;
-    temp = ((uint8_t)((value >> m_greenLeftShift) << m_greenRightShift));
-    uint8_t green = ( temp * (255 - a) + g * a ) / 255;
-    temp = ((uint8_t)((value >> m_blueLeftShift) << m_blueRightShift));
-    uint8_t blue = ( temp * (255 - a) + b * a ) / 255;
-
-    // Set the new pixel value
-    value =
-        ( ((uint32_t)red >> m_redRightShift) << m_redLeftShift ) |
-        ( ((uint32_t)green >> m_greenRightShift) << m_greenLeftShift ) |
-        ( ((uint32_t)blue >> m_blueRightShift) << m_blueLeftShift );
+    BLEND_PIXEL(value, r, g, b, a, uint32_t)
+
+    pPixel[0] = value; value >>= 8;
+    pPixel[1] = value; value >>= 8;
+    pPixel[2] = value; value >>= 8;
+    pPixel[3] = value;
+}
+
+
+void X11Display::putPixel8( uint8_t *pPixel, uint8_t r, uint8_t g,
+                            uint8_t b, uint8_t a ) const
+{
+    uint8_t value = 255 - *pPixel;
+
+    PUT_PIXEL(value, r, g, b, uint8_t)
+
+    *pPixel = 255 - value;
+}
+
+
+void X11Display::putPixel16MSB( uint8_t *pPixel, uint8_t r, uint8_t g,
+                                uint8_t b, uint8_t a ) const
+{
+    uint16_t value = pPixel[1] | pPixel[0] << 8;
+
+    PUT_PIXEL(value, r, g, b, uint16_t)
 
+    pPixel[1] = value; value >>= 8;
     pPixel[0] = value;
-    value >>= 8;
+}
+
+
+void X11Display::putPixel16LSB( uint8_t *pPixel, uint8_t r, uint8_t g,
+                                uint8_t b, uint8_t a ) const
+{
+    uint16_t value = pPixel[0] | pPixel[1] << 8;
+
+    PUT_PIXEL(value, r, g, b, uint16_t)
+
+    pPixel[0] = value; value >>= 8;
     pPixel[1] = value;
-    value >>= 8;
-    pPixel[2] = value;
-    value >>= 8;
+}
+
+
+void X11Display::putPixel32MSB( uint8_t *pPixel, uint8_t r, uint8_t g,
+                                uint8_t b, uint8_t a ) const
+{
+    uint32_t value = pPixel[3] | pPixel[2] << 8 | pPixel[1] << 16 |
+                          pPixel[0] << 24;
+
+    PUT_PIXEL(value, r, g, b, uint32_t)
+
+    pPixel[3] = value; value >>= 8;
+    pPixel[2] = value; value >>= 8;
+    pPixel[1] = value; value >>= 8;
+    pPixel[0] = value;
+}
+
+
+void X11Display::putPixel32LSB( uint8_t *pPixel, uint8_t r, uint8_t g,
+                                uint8_t b, uint8_t a ) const
+{
+    uint32_t value = pPixel[0] | pPixel[1] << 8 | pPixel[2] << 16 |
+                          pPixel[3] << 24;
+
+    PUT_PIXEL(value, r, g, b, uint32_t)
+
+    pPixel[0] = value; value >>= 8;
+    pPixel[1] = value; value >>= 8;
+    pPixel[2] = value; value >>= 8;
     pPixel[3] = value;
 }
 
 
-unsigned long X11Display::getPixelValue( uint8_t r, uint8_t g, uint8_t b ) const
+unsigned long X11Display::getPixelValue( uint8_t r, uint8_t g, uint8_t b )
+    const
 {
     unsigned long value;
     value = ( ((uint32_t)r >> m_redRightShift) << m_redLeftShift ) |
index 2b18f27298fd2793b8754f934da005567a2d0f00..7c1cfc57bda9866f4a691657202926db06b16c9c 100644 (file)
@@ -58,12 +58,15 @@ class X11Display: public SkinObject
         /// Get the colormap
         Colormap getColormap() const { return m_colormap; }
 
-        /// Type of function to convert RGB values into a pixel
+        /// Type of function to put RGBA values into a pixel
         typedef void (X11Display::*MakePixelFunc_t)( uint8_t *pPixel,
             uint8_t r, uint8_t g, uint8_t b, uint8_t a ) const;
 
-        /// Get a pointer on the right makePixel implementation
-        MakePixelFunc_t getMakePixel() const { return makePixelImpl; }
+        /// Get a pointer on the right blendPixel implementation
+        MakePixelFunc_t getBlendPixel() const { return blendPixelImpl; }
+
+        /// Get a pointer on the right putPixel implementation
+        MakePixelFunc_t getPutPixel() const { return putPixelImpl; }
 
         /// Get the pixel value corresponding to the given colors
         unsigned long getPixelValue( uint8_t r, uint8_t g, uint8_t b ) const;
@@ -86,33 +89,54 @@ class X11Display: public SkinObject
         int m_redLeftShift, m_redRightShift;
         int m_greenLeftShift, m_greenRightShift;
         int m_blueLeftShift, m_blueRightShift;
-
-        /// Pointer on the right implementation of getPixel
-        MakePixelFunc_t makePixelImpl;
+        /// Pointer on the right implementation of blendPixel
+        MakePixelFunc_t blendPixelImpl;
+        /// Pointer on the right implementation of putPixel
+        MakePixelFunc_t putPixelImpl;
 
         /// Calculate shifts from a color mask
         void getShifts( uint32_t mask, int &rLeftShift,
                         int &rRightShift ) const;
 
-        /// 8 bpp version of makePixel
-        void makePixel8( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
-                         uint8_t a ) const;
+        /// 8 bpp version of blendPixel
+        void blendPixel8( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
+                          uint8_t a ) const;
+
+        /// 16 bpp MSB first version of blendPixel
+        void blendPixel16MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
+                              uint8_t a ) const;
+
+        /// 16 bpp LSB first version of blendPixel
+        void blendPixel16LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
+                              uint8_t a ) const;
+
+        /// 24/32 bpp MSB first version of blendPixel
+        void blendPixel32MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
+                              uint8_t a ) const;
+
+        /// 24/32 bpp LSB first version of blendPixel
+        void blendPixel32LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
+                              uint8_t a ) const;
+
+        /// 8 bpp version of putPixel
+        void putPixel8( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
+                        uint8_t a ) const;
 
-        /// 16 bpp MSB first version of makePixel
-        void makePixel16MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
-                             uint8_t a ) const;
+        /// 16 bpp MSB first version of putPixel
+        void putPixel16MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
+                            uint8_t a ) const;
 
-        /// 16 bpp LSB first version of makePixel
-        void makePixel16LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
-                             uint8_t a ) const;
+        /// 16 bpp LSB first version of putPixel
+        void putPixel16LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
+                            uint8_t a ) const;
 
-        /// 24/32 bpp MSB first version of makePixel
-        void makePixel32MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
-                             uint8_t a ) const;
+        /// 24/32 bpp MSB first version of putPixel
+        void putPixel32MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
+                            uint8_t a ) const;
 
-        /// 24/32 bpp LSB first version of makePixel
-        void makePixel32LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
-                             uint8_t a ) const;
+        /// 24/32 bpp LSB first version of putPixel
+        void putPixel32LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
+                            uint8_t a ) const;
 };
 
 #endif
index a5a080c874ab706ef69f9409e8b7552b73e4dc37..6b2a560734865da346787acd1b0cd3e749710cda 100644 (file)
@@ -129,7 +129,7 @@ void X11Graphics::drawGraphics( const OSGraphics &rGraphics, int xSrc,
 
 void X11Graphics::drawBitmap( const GenericBitmap &rBitmap, int xSrc,
                               int ySrc, int xDest, int yDest, int width,
-                              int height )
+                              int height, bool blend )
 {
     // Get the bitmap size if necessary
     if( width == -1 )
@@ -190,7 +190,8 @@ void X11Graphics::drawBitmap( const GenericBitmap &rBitmap, int xSrc,
     Region mask = XCreateRegion();
 
     // Get a pointer on the right X11Display::makePixel method
-    X11Display::MakePixelFunc_t makePixelFunc = m_rDisplay.getMakePixel();
+    X11Display::MakePixelFunc_t makePixelFunc = ( blend ?
+        m_rDisplay.getBlendPixel() : m_rDisplay.getPutPixel() );
 
     // Skip the first lines of the image
     pBmpData += 4 * ySrc * rBitmap.getWidth();
index 1e58d7db75192cb5195c9df3d7aee2e7034f0635..e7b6901e4dca44a43f4532330fc926cae5161f36 100644 (file)
@@ -54,7 +54,8 @@ class X11Graphics: public OSGraphics
         /// Render a bitmap on this graphics
         virtual void drawBitmap( const GenericBitmap &rBitmap, int xSrc = 0,
                                  int ySrc = 0, int xDest = 0, int yDest = 0,
-                                 int width = -1, int height = -1 );
+                                 int width = -1, int height = -1,
+                                 bool blend = false );
 
         /// Draw a filled rectangle on the grahics (color is #RRGGBB)
         virtual void fillRect( int left, int top, int width, int height,