Bug 435739 Poor performance of Firefox 3 with no X RENDER extension
[wine-gecko.git] / gfx / thebes / src / cairo-xlib-utils.h
blobb072225e46bd599ade2abd0a3dccb33fd1625997
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Novell code.
17 * The Initial Developer of the Original Code is Novell.
18 * Portions created by the Initial Developer are Copyright (C) 2006
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * rocallahan@novell.com
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef CAIROXLIBUTILS_H_
39 #define CAIROXLIBUTILS_H_
41 #include "cairo.h"
42 #include <X11/Xlib.h>
44 CAIRO_BEGIN_DECLS
46 /**
47 * This callback encapsulates Xlib-based rendering. We assume that the
48 * execution of the callback is equivalent to compositing some RGBA image of
49 * size (bounds_width, bounds_height) onto the drawable at offset (offset_x,
50 * offset_y), clipped to the union of the clip_rects if num_rects is greater
51 * than zero. This includes the assumption that the same RGBA image
52 * is composited if you call the callback multiple times with the same closure,
53 * display and visual during a single cairo_draw_with_xlib call.
55 * @return True on success, False on non-recoverable error
57 typedef cairo_bool_t (* cairo_xlib_drawing_callback)
58 (void *closure,
59 Display *dpy,
60 Drawable drawable,
61 Visual *visual,
62 short offset_x, short offset_y,
63 XRectangle* clip_rects, unsigned int num_rects);
65 /**
66 * This structure captures the result of the native drawing, in case the
67 * caller may wish to reapply the drawing efficiently later.
69 typedef struct {
70 cairo_surface_t *surface;
71 cairo_bool_t uniform_alpha;
72 cairo_bool_t uniform_color;
73 double alpha; /* valid only if uniform_alpha is TRUE */
74 double r, g, b; /* valid only if uniform_color is TRUE */
75 } cairo_xlib_drawing_result_t;
77 /**
78 * This type specifies whether the native drawing callback draws all pixels
79 * in its bounds opaquely, independent of the contents of the target drawable,
80 * or whether it leaves pixels transparent/translucent or depends on the
81 * existing contents of the target drawable in some way.
83 typedef enum _cairo_xlib_drawing_opacity {
84 CAIRO_XLIB_DRAWING_OPAQUE,
85 CAIRO_XLIB_DRAWING_TRANSPARENT
86 } cairo_xlib_drawing_opacity_t;
88 /**
89 * This type encodes the capabilities of the native drawing callback.
91 * If CAIRO_XLIB_DRAWING_SUPPORTS_OFFSET is set, 'offset_x' and 'offset_y'
92 * can be nonzero in the call to the callback; otherwise they will be zero.
94 * If CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_RECT is set, then 'num_rects' can be
95 * zero or one in the call to the callback. If
96 * CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_LIST is set, then 'num_rects' can be
97 * anything in the call to the callback. Otherwise 'num_rects' will be zero.
98 * Do not set both of these values.
100 * If CAIRO_XLIB_DRAWING_SUPPORTS_ALTERNATE_DISPLAY is set, then 'dpy' can be
101 * any display, otherwise it will be the display passed into
102 * cairo_draw_with_xlib.
104 * If CAIRO_XLIB_DRAWING_SUPPORTS_NONDEFAULT_VISUAL is set, then 'visual' can be
105 * any visual, otherwise it will be equal to
106 * DefaultVisual (dpy, DefaultScreen (dpy)).
108 typedef enum {
109 CAIRO_XLIB_DRAWING_SUPPORTS_OFFSET = 0x01,
110 CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_RECT = 0x02,
111 CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_LIST = 0x04,
112 CAIRO_XLIB_DRAWING_SUPPORTS_ALTERNATE_DISPLAY = 0x08,
113 CAIRO_XLIB_DRAWING_SUPPORTS_NONDEFAULT_VISUAL = 0x10
114 } cairo_xlib_drawing_support_t;
117 * Draw Xlib output into any cairo context. All cairo transforms and effects
118 * are honored, including the current operator. This is equivalent to a
119 * cairo_set_source_surface and then cairo_paint.
120 * @param cr the context to draw into
121 * @param callback the code to perform Xlib rendering
122 * @param closure associated data
123 * @param dpy an X display to use in case the cairo context has no associated X display
124 * @param width the width of the putative image drawn by the callback
125 * @param height the height of the putative image drawn by the callback
126 * @param is_opaque set to CAIRO_XLIB_DRAWING_IS_OPAQUE to indicate
127 * that all alpha values of the putative image will be 1.0; the pixels drawn into
128 * the Drawable must not depend on the prior contents of the Drawable
129 * in any way
130 * @param capabilities the capabilities of the callback as described above.
131 * @param result if non-NULL, we *may* fill in the struct with information about
132 * the rendered image. 'surface' may be filled in with a surface representing
133 * the image, similar to the target of 'cr'. If 'uniform_alpha' is True then
134 * every pixel of the image has the same alpha value 'alpha'. If
135 * 'uniform_color' is True then every pixel of the image has the same RGB
136 * color (r, g, b). If the image has uniform color and alpha (or alpha is zero,
137 * in which case the color is always uniform) then we won't bother returning
138 * a surface for it.
140 void cairo_draw_with_xlib (cairo_t *cr,
141 cairo_xlib_drawing_callback callback,
142 void *closure,
143 Display *dpy,
144 unsigned int width, unsigned int height,
145 cairo_xlib_drawing_opacity_t is_opaque,
146 cairo_xlib_drawing_support_t capabilities,
147 cairo_xlib_drawing_result_t *result);
149 CAIRO_END_DECLS
151 #endif /*CAIROXLIBUTILS_H_*/