summaryrefslogtreecommitdiff
path: root/src/drivers/Xlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/Xlib')
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx41
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h1
2 files changed, 42 insertions, 0 deletions
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
index 0385413f1..cdcfd4548 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
@@ -21,6 +21,10 @@
#include "../../config_lib.h"
#include "Fl_Xlib_Graphics_Driver.h"
+#if HAVE_XRENDER
+#include <X11/extensions/Xrender.h>
+#endif
+
const char *Fl_Xlib_Graphics_Driver::class_id = "Fl_Xlib_Graphics_Driver";
@@ -34,6 +38,43 @@ Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver()
return new Fl_Xlib_Graphics_Driver();
}
+char Fl_Xlib_Graphics_Driver::can_do_alpha_blending() {
+ return Fl_X::xrender_supported();
+}
+
+
+void Fl_Xlib_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) {
+ XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y);
+}
+
+void Fl_Xlib_Graphics_Driver::copy_offscreen_with_alpha(int x, int y, int w, int h,
+ Fl_Offscreen pixmap, int srcx, int srcy) {
+#if HAVE_XRENDER
+ XRenderPictureAttributes srcattr;
+ memset(&srcattr, 0, sizeof(XRenderPictureAttributes));
+ static XRenderPictFormat *srcfmt = XRenderFindStandardFormat(fl_display, PictStandardARGB32);
+ static XRenderPictFormat *dstfmt = XRenderFindStandardFormat(fl_display, PictStandardRGB24);
+
+ Picture src = XRenderCreatePicture(fl_display, pixmap, srcfmt, 0, &srcattr);
+ Picture dst = XRenderCreatePicture(fl_display, fl_window, dstfmt, 0, &srcattr);
+
+ if (!src || !dst) {
+ fprintf(stderr, "Failed to create Render pictures (%lu %lu)\n", src, dst);
+ return;
+ }
+
+ const Fl_Region clipr = fl_clip_region();
+ if (clipr)
+ XRenderSetPictureClipRegion(fl_display, dst, clipr);
+
+ XRenderComposite(fl_display, PictOpOver, src, None, dst, srcx, srcy, 0, 0,
+ x, y, w, h);
+
+ XRenderFreePicture(fl_display, src);
+ XRenderFreePicture(fl_display, dst);
+#endif
+}
+
//
// End of "$Id$".
//
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h
index 577f5f573..8cd086a2a 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h
@@ -37,6 +37,7 @@ public:
static const char *class_id;
const char *class_name() {return class_id;};
virtual int has_feature(driver_feature mask) { return mask & NATIVE; }
+ char can_do_alpha_blending();
// --- bitmap stuff
Fl_Bitmask create_bitmask(int w, int h, const uchar *array);