x11_display.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * x11_display.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: f019f1535bd0c90d8661fcc6f49949197ccab166 $
00006  *
00007  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
00008  *          Olivier Teulière <ipkiss@via.ecp.fr>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License along
00021  * with this program; if not, write to the Free Software Foundation, Inc.,
00022  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef X11_DISPLAY_HPP
00026 #define X11_DISPLAY_HPP
00027 
00028 #include <X11/Xlib.h>
00029 #include <X11/Xatom.h>
00030 #include "../src/skin_common.hpp"
00031 
00032 // Helper macros
00033 #define XDISPLAY m_rDisplay.getDisplay()
00034 #define XVISUAL m_rDisplay.getVisual()
00035 #define XPIXELSIZE m_rDisplay.getPixelSize()
00036 #define XGC m_rDisplay.getGC()
00037 
00038 #define NET_WM_SUPPORTED          m_rDisplay.m_net_wm_supported
00039 #define NET_WM_STATE              m_rDisplay.m_net_wm_state
00040 #define NET_WM_STATE_FULLSCREEN   m_rDisplay.m_net_wm_state_fullscreen
00041 #define NET_WM_STATE_ABOVE        m_rDisplay.m_net_wm_state_above
00042 
00043 #define NET_WM_STAYS_ON_TOP       m_rDisplay.m_net_wm_stays_on_top
00044 #define NET_WM_WINDOW_OPACITY     m_rDisplay.m_net_wm_window_opacity
00045 
00046 #define NET_WM_PID                m_rDisplay.m_net_wm_pid
00047 
00048 /// Class for encapsulation of a X11 Display
00049 class X11Display: public SkinObject
00050 {
00051 public:
00052     X11Display( intf_thread_t *pIntf );
00053     virtual ~X11Display();
00054 
00055     /// Get the display
00056     Display *getDisplay() const { return m_pDisplay; }
00057 
00058     /// Get the visual
00059     Visual *getVisual() const { return m_pVisual; }
00060 
00061     /// Get the pixel size
00062     int getPixelSize() const { return m_pixelSize; }
00063 
00064     /// Get the graphics context
00065     GC getGC() const { return m_gc; }
00066 
00067     /// Get the colormap
00068     Colormap getColormap() const { return m_colormap; }
00069 
00070     /// Type of function to put RGBA values into a pixel
00071     typedef void (X11Display::*MakePixelFunc_t)( uint8_t *pPixel,
00072         uint8_t r, uint8_t g, uint8_t b, uint8_t a ) const;
00073 
00074     /// Get a pointer on the right blendPixel implementation
00075     MakePixelFunc_t getBlendPixel() const { return blendPixelImpl; }
00076 
00077     /// Get a pointer on the right putPixel implementation
00078     MakePixelFunc_t getPutPixel() const { return putPixelImpl; }
00079 
00080     /// Get the pixel value corresponding to the given colors
00081     unsigned long getPixelValue( uint8_t r, uint8_t g, uint8_t b ) const;
00082 
00083     /// Get the main window ID
00084     Window getMainWindow() const { return m_mainWindow; }
00085 
00086     //XXX
00087     ///Window m_voutWindow;
00088 
00089     /// EWMH spec
00090     Atom m_net_wm_supported;
00091     Atom m_net_wm_state;
00092     Atom m_net_wm_state_above;
00093     Atom m_net_wm_state_fullscreen;
00094 
00095     Atom m_net_wm_stays_on_top;
00096     Atom m_net_wm_window_opacity;
00097 
00098     Atom m_net_wm_pid;
00099 
00100     /// test EWMH capabilities
00101     void testEWMH();
00102 
00103 private:
00104     /// Dummy parent window for the task bar
00105     Window m_mainWindow;
00106     /// Display parameters
00107     Display *m_pDisplay;
00108     Visual *m_pVisual;
00109     int m_pixelSize;
00110     GC m_gc;
00111     Colormap m_colormap;
00112     int m_redLeftShift, m_redRightShift;
00113     int m_greenLeftShift, m_greenRightShift;
00114     int m_blueLeftShift, m_blueRightShift;
00115     /// Pointer on the right implementation of blendPixel
00116     MakePixelFunc_t blendPixelImpl;
00117     /// Pointer on the right implementation of putPixel
00118     MakePixelFunc_t putPixelImpl;
00119 
00120     template<class type> type putPixel(type r, type g, type b) const;
00121     template<class type>
00122     type blendPixel(type v,type r, type g, type b,type a) const;
00123 
00124     /// Calculate shifts from a color mask
00125     static void getShifts( uint32_t mask, int &rLeftShift, int &rRightShift );
00126 
00127     /// 8 bpp version of blendPixel
00128     void blendPixel8( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
00129                       uint8_t a ) const;
00130 
00131     /// 16 bpp MSB first version of blendPixel
00132     void blendPixel16MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
00133                           uint8_t a ) const;
00134 
00135     /// 16 bpp LSB first version of blendPixel
00136     void blendPixel16LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
00137                           uint8_t a ) const;
00138 
00139     /// 24/32 bpp MSB first version of blendPixel
00140     void blendPixel32MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
00141                           uint8_t a ) const;
00142 
00143     /// 24/32 bpp LSB first version of blendPixel
00144     void blendPixel32LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
00145                           uint8_t a ) const;
00146 
00147     /// 8 bpp version of putPixel
00148     void putPixel8( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
00149                     uint8_t a ) const;
00150 
00151     /// 16 bpp MSB first version of putPixel
00152     void putPixel16MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
00153                         uint8_t a ) const;
00154 
00155     /// 16 bpp LSB first version of putPixel
00156     void putPixel16LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
00157                         uint8_t a ) const;
00158 
00159     /// 24/32 bpp MSB first version of putPixel
00160     void putPixel32MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
00161                         uint8_t a ) const;
00162 
00163     /// 24/32 bpp LSB first version of putPixel
00164     void putPixel32LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
00165                         uint8_t a ) const;
00166 
00167 };
00168 
00169 #endif

Generated on Tue May 25 08:04:58 2010 for VLC by  doxygen 1.5.6