1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifndef X11_DISPLAY_HPP
26 #define X11_DISPLAY_HPP
30 #include "../src/skin_common.hpp"
33 #define XDISPLAY m_rDisplay.getDisplay()
34 #define XVISUAL m_rDisplay.getVisual()
35 #define XPIXELSIZE m_rDisplay.getPixelSize()
36 #define XGC m_rDisplay.getGC()
39 /// Class for encapsulation of a X11 Display
40 class X11Display: public SkinObject
43 X11Display( intf_thread_t *pIntf );
44 virtual ~X11Display();
47 Display *getDisplay() const { return m_pDisplay; }
50 Visual *getVisual() const { return m_pVisual; }
52 /// Get the pixel size
53 int getPixelSize() const { return m_pixelSize; }
55 /// Get the graphics context
56 GC getGC() const { return m_gc; }
59 Colormap getColormap() const { return m_colormap; }
61 /// Type of function to put RGBA values into a pixel
62 typedef void (X11Display::*MakePixelFunc_t)( uint8_t *pPixel,
63 uint8_t r, uint8_t g, uint8_t b, uint8_t a ) const;
65 /// Get a pointer on the right blendPixel implementation
66 MakePixelFunc_t getBlendPixel() const { return blendPixelImpl; }
68 /// Get a pointer on the right putPixel implementation
69 MakePixelFunc_t getPutPixel() const { return putPixelImpl; }
71 /// Get the pixel value corresponding to the given colors
72 unsigned long getPixelValue( uint8_t r, uint8_t g, uint8_t b ) const;
74 /// Get the main window ID
75 Window getMainWindow() const { return m_mainWindow; }
81 /// Dummy parent window for the task bar
83 /// Display parameters
89 int m_redLeftShift, m_redRightShift;
90 int m_greenLeftShift, m_greenRightShift;
91 int m_blueLeftShift, m_blueRightShift;
92 /// Pointer on the right implementation of blendPixel
93 MakePixelFunc_t blendPixelImpl;
94 /// Pointer on the right implementation of putPixel
95 MakePixelFunc_t putPixelImpl;
97 template<class type> type putPixel(type r, type g, type b) const;
99 type blendPixel(type v,type r, type g, type b,type a) const;
101 /// Calculate shifts from a color mask
102 void getShifts( uint32_t mask, int &rLeftShift,
103 int &rRightShift ) const;
105 /// 8 bpp version of blendPixel
106 void blendPixel8( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
109 /// 16 bpp MSB first version of blendPixel
110 void blendPixel16MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
113 /// 16 bpp LSB first version of blendPixel
114 void blendPixel16LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
117 /// 24/32 bpp MSB first version of blendPixel
118 void blendPixel32MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
121 /// 24/32 bpp LSB first version of blendPixel
122 void blendPixel32LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
125 /// 8 bpp version of putPixel
126 void putPixel8( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
129 /// 16 bpp MSB first version of putPixel
130 void putPixel16MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
133 /// 16 bpp LSB first version of putPixel
134 void putPixel16LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
137 /// 24/32 bpp MSB first version of putPixel
138 void putPixel32MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
141 /// 24/32 bpp LSB first version of putPixel
142 void putPixel32LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,