Bug 460926 A11y hierachy is broken on Ubuntu 8.10 (GNOME 2.24), r=Evan.Yan sr=roc
[wine-gecko.git] / gfx / thebes / src / cairo-gdk-utils.h
blob9ae733e0d92e61d32d8364d9ac3406d1e361cba1
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 CAIROGDKUTILS_H_
39 #define CAIROGDKUTILS_H_
41 #include "cairo.h"
42 #include <gdk/gdk.h>
44 CAIRO_BEGIN_DECLS
46 /**
47 * This callback encapsulates GDK-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_gdk call.
55 * @return True when able to draw, False otherwise
57 typedef cairo_bool_t (* cairo_gdk_drawing_callback)
58 (void *closure,
59 cairo_surface_t *surface,
60 short offset_x, short offset_y,
61 GdkRectangle * clip_rects, unsigned int num_rects);
63 /**
64 * This structure captures the result of the native drawing, in case the
65 * caller may wish to reapply the drawing efficiently later.
67 typedef struct {
68 cairo_surface_t *surface;
69 cairo_bool_t uniform_alpha;
70 cairo_bool_t uniform_color;
71 double alpha; /* valid only if uniform_alpha is TRUE */
72 double r, g, b; /* valid only if uniform_color is TRUE */
73 } cairo_gdk_drawing_result_t;
75 /**
76 * This type specifies whether the native drawing callback draws all pixels
77 * in its bounds opaquely, independent of the contents of the target drawable,
78 * or whether it leaves pixels transparent/translucent or depends on the
79 * existing contents of the target drawable in some way.
81 typedef enum _cairo_gdk_drawing_opacity {
82 CAIRO_GDK_DRAWING_OPAQUE,
83 CAIRO_GDK_DRAWING_TRANSPARENT
84 } cairo_gdk_drawing_opacity_t;
86 /**
87 * This type encodes the capabilities of the native drawing callback.
89 * If CAIRO_GDK_DRAWING_SUPPORTS_OFFSET is set, 'offset_x' and 'offset_y'
90 * can be nonzero in the call to the callback; otherwise they will be zero.
92 * If CAIRO_GDK_DRAWING_SUPPORTS_CLIP_RECT is set, then 'num_rects' can be
93 * zero or one in the call to the callback. If
94 * CAIRO_GDK_DRAWING_SUPPORTS_CLIP_LIST is set, then 'num_rects' can be
95 * anything in the call to the callback. Otherwise 'num_rects' will be zero.
96 * Do not set both of these values.
98 * If CAIRO_GDK_DRAWING_SUPPORTS_ALTERNATE_DISPLAY is set, then 'dpy' can be
99 * any display, otherwise it will be the display passed into
100 * cairo_draw_with_gdk.
102 * If CAIRO_GDK_DRAWING_SUPPORTS_NONDEFAULT_VISUAL is set, then 'visual' can be
103 * any visual, otherwise it will be equal to
104 * DefaultVisual (dpy, DefaultScreen (dpy)).
106 typedef enum {
107 CAIRO_GDK_DRAWING_SUPPORTS_OFFSET = 0x01,
108 CAIRO_GDK_DRAWING_SUPPORTS_CLIP_RECT = 0x02,
109 CAIRO_GDK_DRAWING_SUPPORTS_CLIP_LIST = 0x04,
110 CAIRO_GDK_DRAWING_SUPPORTS_ALTERNATE_SCREEN = 0x08,
111 CAIRO_GDK_DRAWING_SUPPORTS_NONDEFAULT_VISUAL = 0x10
112 } cairo_gdk_drawing_support_t;
115 * Draw GDK output into any cairo context. All cairo transforms and effects
116 * are honored, including the current operator. This is equivalent to a
117 * cairo_set_source_surface and then cairo_paint.
118 * @param cr the context to draw into
119 * @param drawable a GDK Drawable that we're targetting
120 * @param callback the code to perform GDK rendering
121 * @param closure associated data
122 * @param width the width of the putative image drawn by the callback
123 * @param height the height of the putative image drawn by the callback
124 * @param is_opaque set to CAIRO_GDK_DRAWING_IS_OPAQUE to indicate
125 * that all alpha values of the putative image will be 1.0; the pixels drawn into
126 * the Drawable must not depend on the prior contents of the Drawable
127 * in any way
128 * @param capabilities the capabilities of the callback as described above.
129 * @param result if non-NULL, we *may* fill in the struct with information about
130 * the rendered image. 'surface' may be filled in with a surface representing
131 * the image, similar to the target of 'cr'. If 'uniform_alpha' is True then
132 * every pixel of the image has the same alpha value 'alpha'. If
133 * 'uniform_color' is True then every pixel of the image has the same RGB
134 * color (r, g, b). If the image has uniform color and alpha (or alpha is zero,
135 * in which case the color is always uniform) then we won't bother returning
136 * a surface for it.
138 void cairo_draw_with_gdk (cairo_t *cr,
139 cairo_gdk_drawing_callback callback,
140 void * closure,
141 unsigned int width, unsigned int height,
142 cairo_gdk_drawing_opacity_t is_opaque,
143 cairo_gdk_drawing_support_t capabilities,
144 cairo_gdk_drawing_result_t *result);
146 CAIRO_END_DECLS
148 #endif /*CAIROGDKUTILS_H_*/