]> git.sesse.net Git - vlc/blob - modules/gui/skins2/x11/x11_graphics.hpp
* all: brand new skins interface ( still _experimental_) for x11 and
[vlc] / modules / gui / skins2 / x11 / x11_graphics.hpp
1 /*****************************************************************************
2  * x11_graphics.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: x11_graphics.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_GRAPHICS_HPP
26 #define X11_GRAPHICS_HPP
27
28 #include <X11/Xlib.h>
29 #include <X11/Xutil.h>
30
31 #include "../src/os_graphics.hpp"
32
33 class X11Display;
34 class GenericWindow;
35 class GenericBitmap;
36
37 /// X11 implementation of OSGraphics
38 class X11Graphics: public OSGraphics
39 {
40     public:
41         X11Graphics( intf_thread_t *pIntf, X11Display &rDisplay, int width,
42                      int height);
43
44         virtual ~X11Graphics();
45
46         /// Clear the graphics
47         virtual void clear();
48
49         /// Draw another graphics on this one
50         virtual void drawGraphics( const OSGraphics &rGraphics, int xSrc = 0,
51                                    int ySrc = 0, int xDest = 0, int yDest = 0,
52                                    int width = -1, int height = -1 );
53
54         /// Render a bitmap on this graphics
55         virtual void drawBitmap( const GenericBitmap &rBitmap, int xSrc = 0,
56                                  int ySrc = 0, int xDest = 0, int yDest = 0,
57                                  int width = -1, int height = -1 );
58
59         /// Draw a filled rectangle on the grahics (color is #RRGGBB)
60         virtual void fillRect( int left, int top, int width, int height,
61                                uint32_t color );
62
63         /// Draw an empty rectangle on the grahics (color is #RRGGBB)
64         virtual void drawRect( int left, int top, int width, int height,
65                                uint32_t color );
66
67         /// Set the shape of a window with the mask of this graphics.
68         virtual void applyMaskToWindow( OSWindow &rWindow );
69
70         /// Copy the graphics on a window
71         virtual void copyToWindow( OSWindow &rWindow, int xSrc,
72                                    int ySrc, int width, int height,
73                                    int xDest, int yDest );
74
75         /// Tell whether the pixel at the given position is visible
76         virtual bool hit( int x, int y ) const;
77
78         /// Getters
79         virtual int getWidth() const { return m_width; }
80         virtual int getHeight() const { return m_height; }
81
82         /// Get the pixmap ID
83         Pixmap getDrawable() const { return m_pixmap; }
84         /// Get the transparency mask
85         Region getMask() const { return m_mask; }
86
87     private:
88         /// X11 display
89         X11Display &m_rDisplay;
90         /// Size of the image
91         int m_width, m_height;
92         /// Pixmap
93         Pixmap m_pixmap;
94         /// Transparency mask
95         Region m_mask;
96         /// Graphics context
97         GC m_gc;
98
99         /// Add an horizontal segment in a region
100         void X11Graphics::addHSegmentInRegion( Region &rMask, int xStart,
101                                                int xEnd, int y );
102         /// Add a vertical segment in a region
103         void X11Graphics::addVSegmentInRegion( Region &rMask, int yStart,
104                                                int yEnd, int x );
105 };
106
107
108 #endif