summaryrefslogtreecommitdiff
path: root/src/FbTk/Transparent.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Transparent.cc')
-rw-r--r--src/FbTk/Transparent.cc31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/FbTk/Transparent.cc b/src/FbTk/Transparent.cc
index e3e1698..e43c005 100644
--- a/src/FbTk/Transparent.cc
+++ b/src/FbTk/Transparent.cc
@@ -19,20 +19,24 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Transparent.cc,v 1.1 2003/04/20 13:27:16 fluxgen Exp $ 22// $Id: Transparent.cc,v 1.2 2003/04/20 14:47:35 fluxgen Exp $
23 23
24#include "Transparent.hh" 24#include "Transparent.hh"
25#include "App.hh" 25#include "App.hh"
26 26
27// #ifdef HAVE_XRENDER 27#ifdef HAVE_CONFIG_H
28#include "config.h"
29#endif // HAVE_CONFIG_H
30
31#ifdef HAVE_XRENDER
28#include <X11/extensions/Xrender.h> 32#include <X11/extensions/Xrender.h>
29// #endif // HAVE_XRENDER 33#endif // HAVE_XRENDER
30 34
31#include <iostream> 35#include <iostream>
32using namespace std; 36using namespace std;
33 37
34namespace { 38namespace {
35 39#ifdef HAVE_XRENDER
36Picture createAlphaPic(Window drawable, unsigned char alpha) { 40Picture createAlphaPic(Window drawable, unsigned char alpha) {
37 Display *disp = FbTk::App::instance()->display(); 41 Display *disp = FbTk::App::instance()->display();
38 42
@@ -83,7 +87,7 @@ Picture createAlphaPic(Window drawable, unsigned char alpha) {
83 87
84 return alpha_pic; 88 return alpha_pic;
85} 89}
86 90#endif // HAVE_XRENDER
87}; 91};
88 92
89namespace FbTk { 93namespace FbTk {
@@ -93,6 +97,7 @@ Transparent::Transparent(Drawable src, Drawable dest, unsigned char alpha, int s
93 m_alpha_pic(0), m_src_pic(0), m_dest_pic(0), 97 m_alpha_pic(0), m_src_pic(0), m_dest_pic(0),
94 m_source(src), m_dest(dest), m_alpha(alpha) { 98 m_source(src), m_dest(dest), m_alpha(alpha) {
95 99
100#ifdef HAVE_XRENDER
96 allocAlpha(m_alpha); 101 allocAlpha(m_alpha);
97 102
98 Display *disp = FbTk::App::instance()->display(); 103 Display *disp = FbTk::App::instance()->display();
@@ -111,10 +116,11 @@ Transparent::Transparent(Drawable src, Drawable dest, unsigned char alpha, int s
111 m_dest_pic = XRenderCreatePicture(disp, dest, format, 116 m_dest_pic = XRenderCreatePicture(disp, dest, format,
112 0, 0); 117 0, 0);
113 } 118 }
114 119#endif // HAVE_XRENDER
115} 120}
116 121
117Transparent::~Transparent() { 122Transparent::~Transparent() {
123#ifdef HAVE_XRENDER
118 if (m_alpha_pic != 0) 124 if (m_alpha_pic != 0)
119 freeAlpha(); 125 freeAlpha();
120 126
@@ -125,6 +131,7 @@ Transparent::~Transparent() {
125 131
126 if (m_src_pic != 0) 132 if (m_src_pic != 0)
127 XRenderFreePicture(disp, m_src_pic); 133 XRenderFreePicture(disp, m_src_pic);
134#endif // HAVE_XRENDER
128} 135}
129 136
130void Transparent::setAlpha(unsigned char alpha) { 137void Transparent::setAlpha(unsigned char alpha) {
@@ -136,6 +143,7 @@ void Transparent::setAlpha(unsigned char alpha) {
136} 143}
137 144
138void Transparent::setDest(Drawable dest, int screen_num) { 145void Transparent::setDest(Drawable dest, int screen_num) {
146#ifdef HAVE_XRENDER
139 if (m_dest == dest) 147 if (m_dest == dest)
140 return; 148 return;
141 149
@@ -158,10 +166,11 @@ void Transparent::setDest(Drawable dest, int screen_num) {
158 166
159 } 167 }
160 m_dest = dest; 168 m_dest = dest;
161 169#endif // HAVE_XRENDER
162} 170}
163 171
164void Transparent::setSource(Drawable source, int screen_num) { 172void Transparent::setSource(Drawable source, int screen_num) {
173#ifdef HAVE_XRENDER
165 if (m_source == source) 174 if (m_source == source)
166 return; 175 return;
167 176
@@ -189,11 +198,13 @@ void Transparent::setSource(Drawable source, int screen_num) {
189 m_src_pic = XRenderCreatePicture(disp, m_source, format, 198 m_src_pic = XRenderCreatePicture(disp, m_source, format,
190 0, 0); 199 0, 0);
191 } 200 }
201#endif // HAVE_XRENDER
192} 202}
193 203
194void Transparent::render(int src_x, int src_y, 204void Transparent::render(int src_x, int src_y,
195 int dest_x, int dest_y, 205 int dest_x, int dest_y,
196 unsigned int width, unsigned int height) const { 206 unsigned int width, unsigned int height) const {
207#ifdef HAVE_XRENDER
197 if (m_src_pic == 0 || m_dest_pic == 0 || 208 if (m_src_pic == 0 || m_dest_pic == 0 ||
198 m_alpha_pic == 0) 209 m_alpha_pic == 0)
199 return; 210 return;
@@ -208,10 +219,11 @@ void Transparent::render(int src_x, int src_y,
208 dest_x, dest_y, 219 dest_x, dest_y,
209 width, height); 220 width, height);
210 221
211 222#endif // HAVE_XRENDER
212} 223}
213 224
214void Transparent::allocAlpha(unsigned char alpha) { 225void Transparent::allocAlpha(unsigned char alpha) {
226#ifdef HAVE_XRENDER
215 if (m_source == 0) 227 if (m_source == 0)
216 return; 228 return;
217 if (m_alpha_pic != 0) 229 if (m_alpha_pic != 0)
@@ -219,10 +231,13 @@ void Transparent::allocAlpha(unsigned char alpha) {
219 231
220 m_alpha_pic = createAlphaPic(m_source, alpha); 232 m_alpha_pic = createAlphaPic(m_source, alpha);
221 m_alpha = alpha; 233 m_alpha = alpha;
234#endif // HAVE_XRENDER
222} 235}
223 236
224void Transparent::freeAlpha() { 237void Transparent::freeAlpha() {
238#ifdef HAVE_XRENDER
225 XRenderFreePicture(FbTk::App::instance()->display(), m_alpha_pic); 239 XRenderFreePicture(FbTk::App::instance()->display(), m_alpha_pic);
240#endif // HAVE_XRENDER
226 m_alpha_pic = 0; 241 m_alpha_pic = 0;
227 m_alpha = 255; 242 m_alpha = 255;
228} 243}