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
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.
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_
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
)
59 cairo_surface_t
*surface
,
60 short offset_x
, short offset_y
,
61 GdkRectangle
* clip_rects
, unsigned int num_rects
);
64 * This type specifies whether the native drawing callback draws all pixels
65 * in its bounds opaquely, independent of the contents of the target drawable,
66 * or whether it leaves pixels transparent/translucent or depends on the
67 * existing contents of the target drawable in some way.
69 typedef enum _cairo_gdk_drawing_opacity
{
70 CAIRO_GDK_DRAWING_OPAQUE
,
71 CAIRO_GDK_DRAWING_TRANSPARENT
72 } cairo_gdk_drawing_opacity_t
;
75 * This type encodes the capabilities of the native drawing callback.
77 * If CAIRO_GDK_DRAWING_SUPPORTS_CLIP_RECT is set, then 'num_rects' can be
78 * zero or one in the call to the callback. Otherwise 'num_rects' will be
82 CAIRO_GDK_DRAWING_SUPPORTS_CLIP_RECT
= 0x02,
83 } cairo_gdk_drawing_support_t
;
86 * Draw GDK output into any cairo context. All cairo transforms and effects
87 * are honored, including the current operator. This is equivalent to a
88 * cairo_set_source_surface and then cairo_paint.
89 * @param cr the context to draw into
90 * @param drawable a GDK Drawable that we're targetting
91 * @param callback the code to perform GDK rendering
92 * @param closure associated data
93 * @param width the width of the putative image drawn by the callback
94 * @param height the height of the putative image drawn by the callback
95 * @param is_opaque set to CAIRO_GDK_DRAWING_IS_OPAQUE to indicate
96 * that all alpha values of the putative image will be 1.0; the pixels drawn into
97 * the Drawable must not depend on the prior contents of the Drawable
99 * @param capabilities the capabilities of the callback as described above.
100 * @param result if non-NULL, we *may* fill in the struct with information about
101 * the rendered image. 'surface' may be filled in with a surface representing
102 * the image, similar to the target of 'cr'. If 'uniform_alpha' is True then
103 * every pixel of the image has the same alpha value 'alpha'. If
104 * 'uniform_color' is True then every pixel of the image has the same RGB
105 * color (r, g, b). If the image has uniform color and alpha (or alpha is zero,
106 * in which case the color is always uniform) then we won't bother returning
109 void cairo_draw_with_gdk (cairo_t
*cr
,
110 cairo_gdk_drawing_callback callback
,
112 unsigned int width
, unsigned int height
,
113 cairo_gdk_drawing_opacity_t is_opaque
,
114 cairo_gdk_drawing_support_t capabilities
,
115 cairo_gdk_drawing_result_t
*result
);
119 #endif /*CAIROGDKUTILS_H_*/