Bumping manifests a=b2g-bump
[gecko.git] / gfx / thebes / cairo-xlib-utils.h
blobf64a84dce73d3b9fa7f814be77c3820e8ceeb39d
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef CAIROXLIBUTILS_H_
7 #define CAIROXLIBUTILS_H_
9 #include "cairo.h"
10 #include <X11/Xlib.h>
12 CAIRO_BEGIN_DECLS
14 /**
15 * This callback encapsulates Xlib-based rendering. We assume that the
16 * execution of the callback is equivalent to compositing some RGBA image of
17 * size (bounds_width, bounds_height) onto the drawable at offset (offset_x,
18 * offset_y), clipped to the union of the clip_rects if num_rects is greater
19 * than zero. This includes the assumption that the same RGBA image
20 * is composited if you call the callback multiple times with the same closure,
21 * display and visual during a single cairo_draw_with_xlib call.
23 * @return True on success, False on non-recoverable error
25 typedef cairo_bool_t (* cairo_xlib_drawing_callback)
26 (void *closure,
27 Screen *screen,
28 Drawable drawable,
29 Visual *visual,
30 short offset_x, short offset_y,
31 XRectangle* clip_rects, unsigned int num_rects);
33 /**
34 * This structure captures the result of the native drawing, in case the
35 * caller may wish to reapply the drawing efficiently later.
37 typedef struct {
38 cairo_surface_t *surface;
39 cairo_bool_t uniform_alpha;
40 cairo_bool_t uniform_color;
41 double alpha; /* valid only if uniform_alpha is TRUE */
42 double r, g, b; /* valid only if uniform_color is TRUE */
43 } cairo_xlib_drawing_result_t;
45 /**
46 * This type specifies whether the native drawing callback draws all pixels
47 * in its bounds opaquely, independent of the contents of the target drawable,
48 * or whether it leaves pixels transparent/translucent or depends on the
49 * existing contents of the target drawable in some way.
51 typedef enum _cairo_xlib_drawing_opacity {
52 CAIRO_XLIB_DRAWING_OPAQUE,
53 CAIRO_XLIB_DRAWING_TRANSPARENT
54 } cairo_xlib_drawing_opacity_t;
56 /**
57 * This type encodes the capabilities of the native drawing callback.
59 * If CAIRO_XLIB_DRAWING_SUPPORTS_OFFSET is set, 'offset_x' and 'offset_y'
60 * can be nonzero in the call to the callback; otherwise they will be zero.
62 * If CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_RECT is set, then 'num_rects' can be
63 * zero or one in the call to the callback. If
64 * CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_LIST is set, then 'num_rects' can be
65 * anything in the call to the callback. Otherwise 'num_rects' will be zero.
66 * Do not set both of these values.
68 * If CAIRO_XLIB_DRAWING_SUPPORTS_ALTERNATE_SCREEN is set, then 'screen' can
69 * be any screen on any display, otherwise it will be the default screen of
70 * the display passed into cairo_draw_with_xlib.
72 * If CAIRO_XLIB_DRAWING_SUPPORTS_NONDEFAULT_VISUAL is set, then 'visual' can be
73 * any visual, otherwise it will be equal to
74 * DefaultVisualOfScreen (screen).
76 typedef enum {
77 CAIRO_XLIB_DRAWING_SUPPORTS_OFFSET = 0x01,
78 CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_RECT = 0x02,
79 CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_LIST = 0x04,
80 CAIRO_XLIB_DRAWING_SUPPORTS_ALTERNATE_SCREEN = 0x08,
81 CAIRO_XLIB_DRAWING_SUPPORTS_NONDEFAULT_VISUAL = 0x10
82 } cairo_xlib_drawing_support_t;
84 /**
85 * Draw Xlib output into any cairo context. All cairo transforms and effects
86 * are honored, including the current operator. This is equivalent to a
87 * cairo_set_source_surface and then cairo_paint.
88 * @param cr the context to draw into
89 * @param callback the code to perform Xlib rendering
90 * @param closure associated data
91 * @param dpy an X display to use in case the cairo context has no associated X display
92 * @param width the width of the putative image drawn by the callback
93 * @param height the height of the putative image drawn by the callback
94 * @param is_opaque set to CAIRO_XLIB_DRAWING_IS_OPAQUE to indicate
95 * that all alpha values of the putative image will be 1.0; the pixels drawn into
96 * the Drawable must not depend on the prior contents of the Drawable
97 * in any way
98 * @param capabilities the capabilities of the callback as described above.
99 * @param result if non-NULL, we *may* fill in the struct with information about
100 * the rendered image. 'surface' may be filled in with a surface representing
101 * the image, similar to the target of 'cr'. If 'uniform_alpha' is True then
102 * every pixel of the image has the same alpha value 'alpha'. If
103 * 'uniform_color' is True then every pixel of the image has the same RGB
104 * color (r, g, b). If the image has uniform color and alpha (or alpha is zero,
105 * in which case the color is always uniform) then we won't bother returning
106 * a surface for it.
108 void cairo_draw_with_xlib (cairo_t *cr,
109 cairo_xlib_drawing_callback callback,
110 void *closure,
111 Display *dpy,
112 unsigned int width, unsigned int height,
113 cairo_xlib_drawing_opacity_t is_opaque,
114 cairo_xlib_drawing_support_t capabilities,
115 cairo_xlib_drawing_result_t *result);
117 CAIRO_END_DECLS
119 #endif /*CAIROXLIBUTILS_H_*/