aboutsummaryrefslogtreecommitdiff
path: root/util/fbcompose/XRenderResources.hh
diff options
context:
space:
mode:
Diffstat (limited to 'util/fbcompose/XRenderResources.hh')
-rw-r--r--util/fbcompose/XRenderResources.hh166
1 files changed, 166 insertions, 0 deletions
diff --git a/util/fbcompose/XRenderResources.hh b/util/fbcompose/XRenderResources.hh
new file mode 100644
index 0000000..8bdedac
--- /dev/null
+++ b/util/fbcompose/XRenderResources.hh
@@ -0,0 +1,166 @@
1/** XRenderResources.hh file for the fluxbox compositor. */
2
3// Copyright (c) 2011 Gediminas Liktaras (gliktaras at gmail dot com)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21// THE SOFTWARE.
22
23
24#ifndef FBCOMPOSITOR_XRENDERRESOURCES_HH
25#define FBCOMPOSITOR_XRENDERRESOURCES_HH
26
27
28#include "config.h"
29
30#include "FbTk/RefCount.hh"
31
32#include <X11/extensions/Xrender.h>
33#include <X11/Xlib.h>
34
35
36namespace FbCompositor {
37
38 class XRenderScreen;
39
40
41 //--- XRENDER PICTURE WRAPPER ----------------------------------------------
42
43 /**
44 * XRender picture wrapper.
45 */
46 class XRenderPicture {
47 public:
48 //--- CONSTRUCTORS AND DESTRUCTORS -------------------------------------
49
50 /** Constructor. */
51 XRenderPicture(const XRenderScreen &screen, XRenderPictFormat *pict_format, const char *pict_filter);
52
53 /** Destructor. */
54 ~XRenderPicture();
55
56
57 //--- ACCESSORS --------------------------------------------------------
58
59 /** \returns the handle of the picture's drawable. */
60 Drawable drawableHandle() const;
61
62 /** \returns the GC of the picture's drawable. */
63 GC gcHandle() const;
64
65 /** \returns the handle of the picture held. */
66 Picture pictureHandle() const;
67
68
69 //--- MUTATORS ---------------------------------------------------------
70
71 /** Set a new PictFormat. */
72 void setPictFormat(XRenderPictFormat *pict_format);
73
74
75 /** Associate the picture with the given pixmap. */
76 void setPixmap(Pixmap pixmap, bool manage_pixmap, XRenderPictureAttributes pa = XRenderPictureAttributes(), long pa_mask = 0);
77
78 /** Associate the picture with the given window. */
79 void setWindow(Window window, XRenderPictureAttributes pa = XRenderPictureAttributes(), long pa_mask = 0);
80
81
82 /** Reset the picture's transformation matrix. */
83 void resetPictureTransform();
84
85 /** Scale the picture by the given inverse quotients. */
86 void scalePicture(double x_factor_inv, double y_factor_inv);
87
88 /** Set the picture's transformation matrix. */
89 void setPictureTransform(const XTransform &transform);
90
91 private:
92 //--- CONSTRUCTORS -----------------------------------------------------
93
94 /** Constructor. */
95 XRenderPicture(const XRenderPicture &other);
96
97 /** Assignment operator. */
98 XRenderPicture &operator=(const XRenderPicture &other);
99
100
101 //--- OTHER FUNCTIONS --------------------------------------------------
102
103 /** Free held resources, if any. */
104 void freeResources();
105
106
107 //--- INTERNALS --------------------------------------------------------
108
109 /** The picture's drawable. */
110 Drawable m_drawable;
111
112 /** The picture's drawable's GC. */
113 GC m_gc;
114
115 /** The picture in question. */
116 Picture m_picture;
117
118 /** Whether the resources are managed by this object. */
119 bool m_resources_managed;
120
121
122 /** Picture filter to use. */
123 const char *m_pict_filter;
124
125 /** Picture format to use. */
126 XRenderPictFormat *m_pict_format;
127
128
129 /** Current connection to the X server. */
130 Display *m_display;
131
132 /** The screen that manages the current picture. */
133 const XRenderScreen &m_screen;
134 };
135
136
137 // Returns the handle of the picture's drawable.
138 inline Drawable XRenderPicture::drawableHandle() const {
139 return m_drawable;
140 }
141
142 // Returns the GC of the picture's drawable.
143 inline GC XRenderPicture::gcHandle() const {
144 return m_gc;
145 }
146
147 // Returns the picture held.
148 inline Picture XRenderPicture::pictureHandle() const {
149 return m_picture;
150 }
151
152 // Set a new PictFormat.
153 inline void XRenderPicture::setPictFormat(XRenderPictFormat *pict_format) {
154 if (pict_format) {
155 m_pict_format = pict_format;
156 }
157 }
158
159
160 //--- TYPEDEFS -------------------------------------------------------------
161
162 /** XRender picture wrapper smart pointer. */
163 typedef FbTk::RefCount<XRenderPicture> XRenderPicturePtr;
164}
165
166#endif // FBCOMPOSITOR_XRENDERRESOURCES_HH