]> git.sesse.net Git - vlc/blob - modules/gui/skins2/x11/x11_display.hpp
* all: brand new skins interface ( still _experimental_) for x11 and
[vlc] / modules / gui / skins2 / x11 / x11_display.hpp
1 /*****************************************************************************
2  * x11_display.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: x11_display.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
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.
14  *
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.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #ifndef X11_DISPLAY_HPP
26 #define X11_DISPLAY_HPP
27
28 #include <X11/Xlib.h>
29
30 #include "../src/skin_common.hpp"
31
32 // Helper macros
33 #define XDISPLAY m_rDisplay.getDisplay()
34 #define XVISUAL m_rDisplay.getVisual()
35 #define XPIXELSIZE m_rDisplay.getPixelSize()
36 #define XGC m_rDisplay.getGC()
37
38
39 /// Class for encapsulation of a X11 Display
40 class X11Display: public SkinObject
41 {
42     public:
43         X11Display( intf_thread_t *pIntf );
44         virtual ~X11Display();
45
46         /// Get the display
47         Display *getDisplay() const { return m_pDisplay; }
48
49         /// Get the visual
50         Visual *getVisual() const { return m_pVisual; }
51
52         /// Get the pixel size
53         int getPixelSize() const { return m_pixelSize; }
54
55         /// Get the graphics context
56         GC getGC() const { return m_gc; }
57
58         /// Type of function to convert RGB values into a pixel
59         typedef void (X11Display::*MakePixelFunc_t)( uint8_t *pPixel,
60             uint8_t r, uint8_t g, uint8_t b, uint8_t a ) const;
61
62         /// Get a pointer on the right makePixel implementation
63         MakePixelFunc_t getMakePixel() const { return makePixelImpl; }
64
65     private:
66         /// Display parameters
67         Display *m_pDisplay;
68         Visual *m_pVisual;
69         int m_pixelSize;
70         GC m_gc;
71         int m_redLeftShift, m_redRightShift;
72         int m_greenLeftShift, m_greenRightShift;
73         int m_blueLeftShift, m_blueRightShift;
74
75
76         /// Pointer on the right implementation of getPixel
77         MakePixelFunc_t makePixelImpl;
78
79         /// Calculate shifts from a color mask
80         void getShifts( uint32_t mask, int &rLeftShift,
81                         int &rRightShift ) const;
82
83         /// 16 bpp MSB first version of makePixel
84         void makePixel16MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
85                              uint8_t a ) const;
86
87         /// 16 bpp LSB first version of makePixel
88         void makePixel16LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
89                              uint8_t a ) const;
90
91         /// 24/32 bpp MSB first version of makePixel
92         void makePixel32MSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
93                              uint8_t a ) const;
94
95         /// 24/32 bpp LSB first version of makePixel
96         void makePixel32LSB( uint8_t *pPixel, uint8_t r, uint8_t g, uint8_t b,
97                              uint8_t a ) const;
98 };
99
100 #endif