]> git.sesse.net Git - vlc/blob - modules/gui/skins2/x11/x11_graphics.hpp
5b187710607a86aa5d9e9664df71d25aa79fbc35
[vlc] / modules / gui / skins2 / x11 / x11_graphics.hpp
1 /*****************************************************************************
2  * x11_graphics.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 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                                  bool blend = false );
59
60         /// Draw a filled rectangle on the grahics (color is #RRGGBB)
61         virtual void fillRect( int left, int top, int width, int height,
62                                uint32_t color );
63
64         /// Draw an empty rectangle on the grahics (color is #RRGGBB)
65         virtual void drawRect( int left, int top, int width, int height,
66                                uint32_t color );
67
68         /// Set the shape of a window with the mask of this graphics.
69         virtual void applyMaskToWindow( OSWindow &rWindow );
70
71         /// Copy the graphics on a window
72         virtual void copyToWindow( OSWindow &rWindow, int xSrc,
73                                    int ySrc, int width, int height,
74                                    int xDest, int yDest );
75
76         /// Tell whether the pixel at the given position is visible
77         virtual bool hit( int x, int y ) const;
78
79         /// Getters
80         virtual int getWidth() const { return m_width; }
81         virtual int getHeight() const { return m_height; }
82
83         /// Get the pixmap ID
84         Pixmap getDrawable() const { return m_pixmap; }
85         /// Get the transparency mask
86         Region getMask() const { return m_mask; }
87
88     private:
89         /// X11 display
90         X11Display &m_rDisplay;
91         /// Size of the image
92         int m_width, m_height;
93         /// Pixmap
94         Pixmap m_pixmap;
95         /// Transparency mask
96         Region m_mask;
97         /// Graphics context
98         GC m_gc;
99
100         /// Add an horizontal segment in a region
101         void X11Graphics::addHSegmentInRegion( Region &rMask, int xStart,
102                                                int xEnd, int y );
103         /// Add a vertical segment in a region
104         void X11Graphics::addVSegmentInRegion( Region &rMask, int yStart,
105                                                int yEnd, int x );
106 };
107
108
109 #endif