XRender Base Driver
This driver represents a basic driver for all system-dependent drivers
implemented in the X-Windows system using the XRender extension. The implementation uses the
XRender and Xft API functions.
It can be used only as the context plus driver of the X-Win based drivers.
The main motivation for the use of XRender was transparency for all the primitives. Beyond that we got other features
like anti-aliasing, gradient filling and transformations.
This driver still does not completely replace the X-Windows base driver, because
XRender does not have support for
XOR and for line styles.
So we let the programmer to choose what to use. We created the function
cdUseContextPlus that allows to activate or to deactivate the use of
X-Render for the available X-Win based drivers.
This function affects only the cdCreateCanvas function call, once created
the canvas will be always a XRender canvas. In fact the function affects primary the definitions
CD_NATIVEWINDOW,
CD_IMAGE and
CD_DBUFFER, because they are
function calls and not static defines.
Using XRender it is allowed to create more that one canvas at the same time for the same Window. And they can co-exist
with a standard X-Windows canvas.
To enable the use of XRender based drivers you must call the initialization function
cdInitContextPlus once and link to the libraries "cdcontextplus", "Xrender" and "Xft".
Also the libraries "Xrender" and "Xft"
must be installed in your system. The XRender extension must be available in
the X-Windows server for the driver to work.
Currently, pre-compiled binaries are available for Linux
and BSD. It is not available for the systems we have with AIX, SunOS and
IRIX.
In CDLua it is not necessary any additional initialization, but the
application must still be linked with the cdcontextplus.lib
library or a require"cdluacontextplus" can be used when
using dynamic libraries. When using require, it is NOT available in Linux.
Behavior of Functions
Control
-
Play: does nothing, returns
CD_ERROR.
Coordinate System and Clipping
-
UpdateYAxis: the
orientation of axis Y is the opposite to its orientation in the CD library.
Except when using transformations.
Primitives
- Line:
simulated using the client's Poly.
- Text:
Generic transformation
matrix affects only the position of the text. Complex clipping regions can not
contain text regions.
-
Begin:
CD_BEZIER and CD_PATH
are simulated with lines.
- Rect:
simulated using the client's Line.
- Arc:
simulated using the client's Line.
- Sector:
simulated using the client's Poly.
- Chord:
simulated using the client's Poly
- Box:
simulated using the client's Poly.
- Floating point primitives are supported.
Attributes
-
LineWidth: the driver will
use a polygon that fits to the line extents, even when linewidth==1.
-
LineStyle: NOT supported.
-
Pattern: each pixel can contain transparency information.
-
NativeFont: also accepts the
X-Windows font string format. You can use program xfontsel to select a font and obtain the string.
For ex: "-*-times-bold-r-*-*-24-*-*-*-*-*-*-*" (equivalent of Font("Times",
CD_BOLD, -24).
-
Font: font support is
implemented using the Xft library. Internally the Xft library uses the
Freetype library.
Colors
-
Use the X-Windows base driver support for colors.
Client and Server Images
-
All functions use the X-Windows base driver functions.
Exclusive Attributes
- "GC": returns the X11 graphics
context (get only). In Lua is returned as a user data.
- "ROTATE": allows the usage of 1
angle and 1 coordinate (x, y), that define a global rotation transformation
centered in the specified coordinate. Use 1 real and 2 integer values inside a
string ("%g %d %d" = angle x y). In this driver will change the
current transformation matrix, if removed will reset the current
transformation matrix.
- "ANTIALIAS": controls the use of anti-aliasing
for the text, image zoom and line
drawing primitives. Assumes values "1" (active) and "0" (inactive). Default value: "1".
- "LINEARGRADIENT": defines a filled interior style that uses a linear gradient
between two colors. It uses 2 points ("%d %d %d %d" = x1 y1 x2 y2), one for the starting point using (using the
foreground color), and another one for the end point (using the background color).
(available only if Xrender version >= 0.10)
- "XRENDERVERSION": returns a
string with the XRender version number. It is empty if the XRender extension
is not available in the X-Windows server.