1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
//
// "$Id$"
//
// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2016 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// http://www.fltk.org/COPYING.php
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
#include "../../config_lib.h"
#include "Fl_Xlib_Graphics_Driver.H"
#include <FL/fl_draw.H>
#include <string.h>
#if HAVE_XRENDER
#include <X11/extensions/Xrender.h>
#endif
/* Reference to the current graphics context
For back-compatibility only. The preferred procedure to get this pointer is
Fl_Surface_Device::surface()->driver()->gc().
*/
GC fl_gc = 0;
void Fl_Graphics_Driver::global_gc()
{
}
/*
* By linking this module, the following static method will instatiate the
* X11 Xlib Graphics driver as the main display driver.
*/
Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver()
{
return new Fl_Xlib_Graphics_Driver();
}
GC Fl_Xlib_Graphics_Driver::gc_ = NULL;
Fl_Xlib_Graphics_Driver::Fl_Xlib_Graphics_Driver(void) {
if (!gc_) {
fl_open_display();
// the unique GC used by all X windows
gc_ = XCreateGC(fl_display, RootWindow(fl_display, fl_screen), 0, 0);
fl_gc = gc_;
}
mask_bitmap_ = NULL;
}
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, gc_, srcx, srcy, w, h, x, y);
}
#ifndef FL_DOXYGEN
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
}
#endif
//
// End of "$Id$".
//
|