static void
set_up_x_back_buffer (struct frame *f)
{
+#ifdef HAVE_XRENDER
+ block_input ();
+ if (FRAME_X_PICTURE (f) != None)
+ {
+ XRenderFreePicture (FRAME_X_DISPLAY (f),
+ FRAME_X_PICTURE (f));
+ FRAME_X_PICTURE (f) = None;
+ }
+ unblock_input ();
+#endif
+
#ifdef HAVE_XDBE
block_input ();
if (FRAME_X_WINDOW (f) && !FRAME_X_DOUBLE_BUFFERED_P (f))
server ran out of memory or we don't have the right kind
of visual, just use single-buffered rendering. */
x_catch_errors (FRAME_X_DISPLAY (f));
- FRAME_X_RAW_DRAWABLE (f) = XdbeAllocateBackBufferName (
- FRAME_X_DISPLAY (f),
- FRAME_X_WINDOW (f),
- XdbeCopied);
+ FRAME_X_RAW_DRAWABLE (f)
+ = XdbeAllocateBackBufferName (FRAME_X_DISPLAY (f),
+ FRAME_X_WINDOW (f),
+ XdbeCopied);
if (x_had_errors_p (FRAME_X_DISPLAY (f)))
FRAME_X_RAW_DRAWABLE (f) = FRAME_X_WINDOW (f);
x_uncatch_errors_after_check ();
void
tear_down_x_back_buffer (struct frame *f)
{
+#ifdef HAVE_XRENDER
+ block_input ();
+ if (FRAME_X_PICTURE (f) != None)
+ {
+ XRenderFreePicture (FRAME_X_DISPLAY (f),
+ FRAME_X_PICTURE (f));
+ FRAME_X_PICTURE (f) = None;
+ }
+ unblock_input ();
+#endif
+
#ifdef HAVE_XDBE
block_input ();
if (FRAME_X_WINDOW (f) && FRAME_X_DOUBLE_BUFFERED_P (f))
unblock_input ();
}
+#ifdef HAVE_XRENDER
+MAYBE_UNUSED static void
+x_xr_ensure_picture (struct frame *f)
+{
+ if (FRAME_X_PICTURE (f) == None && FRAME_X_PICTURE_FORMAT (f))
+ {
+ XRenderPictureAttributes attrs;
+ attrs.clip_mask = None;
+
+ FRAME_X_PICTURE (f) = XRenderCreatePicture (FRAME_X_DISPLAY (f),
+ FRAME_X_RAW_DRAWABLE (f),
+ FRAME_X_PICTURE_FORMAT (f),
+ CPClipMask, &attrs);
+ }
+}
+#endif
/* Remove calls to XFlush by defining XFlush to an empty replacement.
Calls to XFlush should be unnecessary because the X output buffer
#endif
-#ifdef USE_CAIRO
-
-#define FRAME_CR_CONTEXT(f) ((f)->output_data.x->cr_context)
-#define FRAME_CR_SURFACE_DESIRED_WIDTH(f) \
- ((f)->output_data.x->cr_surface_desired_width)
-#define FRAME_CR_SURFACE_DESIRED_HEIGHT(f) \
- ((f)->output_data.x->cr_surface_desired_height)
-
+#if defined USE_CAIRO || defined HAVE_XRENDER
static struct x_gc_ext_data *
x_gc_get_ext_data (struct frame *f, GC gc, int create_if_not_found_p)
{
dpyinfo->ext_codes = ext_codes;
}
+#endif
+
+#ifdef USE_CAIRO
+
+#define FRAME_CR_CONTEXT(f) ((f)->output_data.x->cr_context)
+#define FRAME_CR_SURFACE_DESIRED_WIDTH(f) \
+ ((f)->output_data.x->cr_surface_desired_width)
+#define FRAME_CR_SURFACE_DESIRED_HEIGHT(f) \
+ ((f)->output_data.x->cr_surface_desired_height)
#endif /* HAVE_CAIRO */
#endif /* USE_CAIRO */
+#if defined HAVE_XRENDER && !defined USE_CAIRO
+MAYBE_UNUSED static void
+x_xr_apply_ext_clip (struct frame *f, GC gc)
+{
+ eassert (FRAME_X_PICTURE (f) != None);
+
+ struct x_gc_ext_data *data = x_gc_get_ext_data (f, gc, 1);
+
+ if (data->n_clip_rects)
+ XRenderSetPictureClipRectangles (FRAME_X_DISPLAY (f),
+ FRAME_X_PICTURE (f),
+ 0, 0, data->clip_rects,
+ data->n_clip_rects);
+}
+
+MAYBE_UNUSED static void
+x_xr_reset_ext_clip (struct frame *f)
+{
+ XRenderPictureAttributes attrs = { .clip_mask = None };
+
+ XRenderChangePicture (FRAME_X_DISPLAY (f),
+ FRAME_X_PICTURE (f),
+ CPClipMask, &attrs);
+}
+#endif
+
static void
x_set_clip_rectangles (struct frame *f, GC gc, XRectangle *rectangles, int n)
{
XSetClipRectangles (FRAME_X_DISPLAY (f), gc, 0, 0, rectangles, n, Unsorted);
-#ifdef USE_CAIRO
+#if defined USE_CAIRO || defined HAVE_XRENDER
eassert (n >= 0 && n <= MAX_CLIP_RECTS);
{
x_reset_clip_rectangles (struct frame *f, GC gc)
{
XSetClipMask (FRAME_X_DISPLAY (f), gc, None);
-#ifdef USE_CAIRO
+#if defined USE_CAIRO || defined HAVE_XRENDER
{
struct x_gc_ext_data *gc_ext = x_gc_get_ext_data (f, gc, 0);
#ifndef USE_GTK
if (FRAME_X_DOUBLE_BUFFERED_P (f))
#endif
- XFillRectangle (FRAME_X_DISPLAY (f),
- FRAME_X_DRAWABLE (f),
- f->output_data.x->reverse_gc,
- x, y, width, height);
+ {
+#if defined HAVE_XRENDER && \
+ (RENDER_MAJOR > 0 || (RENDER_MINOR >= 2))
+ x_xr_ensure_picture (f);
+ if (FRAME_X_PICTURE (f) != None
+ && FRAME_CHECK_XR_VERSION (f, 0, 2))
+ {
+ XRenderColor xc;
+ GC gc = f->output_data.x->reverse_gc;
+
+ x_xr_apply_ext_clip (f, gc);
+ x_xrender_color_from_gc_foreground (f, gc, &xc);
+ XRenderFillRectangle (FRAME_X_DISPLAY (f),
+ PictOpSrc, FRAME_X_PICTURE (f),
+ &xc, x, y, width, height);
+ x_xr_reset_ext_clip (f);
+ x_mark_frame_dirty (f);
+ }
+ else
+#endif
+ XFillRectangle (FRAME_X_DISPLAY (f),
+ FRAME_X_DRAWABLE (f),
+ f->output_data.x->reverse_gc,
+ x, y, width, height);
+ }
#ifndef USE_GTK
else
x_clear_area1 (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
if (!XRenderQueryVersion (dpyinfo->display, &dpyinfo->xrender_major,
&dpyinfo->xrender_minor))
dpyinfo->xrender_supported_p = false;
+ else
+ dpyinfo->pict_format = XRenderFindVisualFormat (dpyinfo->display,
+ dpyinfo->visual);
}
#endif
x_session_initialize (dpyinfo);
#endif
-#ifdef USE_CAIRO
+#if defined USE_CAIRO || defined HAVE_XRENDER
x_extension_initialize (dpyinfo);
#endif
}
#endif
+#ifdef HAVE_XRENDER
+void
+x_xrender_color_from_gc_foreground (struct frame *f, GC gc, XRenderColor *color)
+{
+ XGCValues xgcv;
+ XColor xc;
+
+ XGetGCValues (FRAME_X_DISPLAY (f), gc, GCForeground, &xgcv);
+ xc.pixel = xgcv.foreground;
+ x_query_colors (f, &xc, 1);
+
+ color->alpha = 65535;
+ color->red = xc.red;
+ color->blue = xc.blue;
+ color->green = xc.green;
+}
+
+void
+x_xrender_color_from_gc_background (struct frame *f, GC gc, XRenderColor *color)
+{
+ XGCValues xgcv;
+ XColor xc;
+
+ XGetGCValues (FRAME_X_DISPLAY (f), gc, GCBackground, &xgcv);
+ xc.pixel = xgcv.foreground;
+ x_query_colors (f, &xc, 1);
+
+ color->alpha = 65535;
+ color->red = xc.red;
+ color->blue = xc.blue;
+ color->green = xc.green;
+}
+#endif
+
void
syms_of_xterm (void)
{
#define GTK_CHECK_VERSION(i, j, k) false
#endif
+#ifdef HAVE_XRENDER
+#include <X11/extensions/Xrender.h>
+#endif
+
#ifdef USE_GTK
/* Some definitions to reduce conditionals. */
typedef GtkWidget *xt_or_gtk_widget;
int height, width, depth;
};
\f
-#ifdef USE_CAIRO
+#if defined USE_CAIRO || defined HAVE_XRENDER
struct x_gc_ext_data
{
#define MAX_CLIP_RECTS 2
/* Clipping rectangles. */
XRectangle clip_rects[MAX_CLIP_RECTS];
};
+#endif
+#ifdef USE_CAIRO
extern cairo_pattern_t *x_bitmap_stipple (struct frame *, Pixmap);
#endif
/* The Visual being used for this display. */
Visual *visual;
+#ifdef HAVE_XRENDER
+ /* The picture format for this display. */
+ XRenderPictFormat *pict_format;
+#endif
+
/* The colormap being used. */
Colormap cmap;
int xrandr_minor_version;
#endif
-#ifdef USE_CAIRO
+#if defined USE_CAIRO || defined HAVE_XRENDER
XExtCodes *ext_codes;
#endif
window's back buffer. */
Drawable draw_desc;
+#ifdef HAVE_XRENDER
+ /* The Xrender picture that corresponds to this drawable. None
+ means no picture format was found, or the Xrender extension is
+ not present. */
+ Picture picture;
+#endif
+
/* Flag that indicates whether we've modified the back buffer and
need to publish our modifications to the front buffer at a
convenient time. */
/* This is the Visual which frame F is on. */
#define FRAME_X_VISUAL(f) FRAME_DISPLAY_INFO (f)->visual
+#ifdef HAVE_XRENDER
+#define FRAME_X_PICTURE_FORMAT(f) FRAME_DISPLAY_INFO (f)->pict_format
+#define FRAME_X_PICTURE(f) ((f)->output_data.x->picture)
+#define FRAME_CHECK_XR_VERSION(f, major, minor) \
+ (FRAME_DISPLAY_INFO (f)->xrender_supported_p \
+ && ((FRAME_DISPLAY_INFO (f)->xrender_major == (major) \
+ && FRAME_DISPLAY_INFO (f)->xrender_minor >= (minor)) \
+ || (FRAME_DISPLAY_INFO (f)->xrender_major > (major))))
+#endif
+
+
/* This is the Colormap which frame F uses. */
#define FRAME_X_COLORMAP(f) FRAME_DISPLAY_INFO (f)->cmap
extern Lisp_Object x_cr_export_frames (Lisp_Object, cairo_surface_type_t);
#endif
+#ifdef HAVE_XRENDER
+extern void x_xrender_color_from_gc_foreground (struct frame *, GC, XRenderColor *);
+extern void x_xrender_color_from_gc_background (struct frame *, GC, XRenderColor *);
+#endif
+
INLINE int
x_display_pixel_height (struct x_display_info *dpyinfo)
{