1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2010 Red Hat Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it either under the terms of the GNU Lesser General Public
7 * License version 2.1 as published by the Free Software Foundation
8 * (the "LGPL") or, at your option, under the terms of the Mozilla
9 * Public License Version 1.1 (the "MPL"). If you do not alter this
10 * notice, a recipient may use your version of this file under either
11 * the MPL or the LGPL.
13 * You should have received a copy of the LGPL along with this library
14 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
16 * You should have received a copy of the MPL along with this library
17 * in the file COPYING-MPL-1.1
19 * The contents of this file are subject to the Mozilla Public License
20 * Version 1.1 (the "License"); you may not use this file except in
21 * compliance with the License. You may obtain a copy of the License at
22 * http://www.mozilla.org/MPL/
24 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
26 * the specific language governing rights and limitations.
28 * The Original Code is the cairo graphics library.
30 * The Initial Developer of the Original Code is University of Southern
34 * Benjamin Otte <otte@redhat.com>
41 #include "cairo-gobject.h"
43 #define CAIRO_DEFINE_BOXED(Name,underscore_name,copy_func,free_func) \
45 underscore_name ## _get_type (void) \
47 static volatile gsize type_volatile = 0; \
48 if (g_once_init_enter (&type_volatile)) { \
49 GType type = g_boxed_type_register_static (g_intern_static_string (Name), \
50 (GBoxedCopyFunc)copy_func, \
51 (GBoxedFreeFunc)free_func); \
52 g_once_init_leave (&type_volatile, type); \
54 return type_volatile; \
57 CAIRO_DEFINE_BOXED ("CairoContext", cairo_gobject_context,
58 cairo_reference, cairo_destroy);
59 CAIRO_DEFINE_BOXED ("CairoDevice", cairo_gobject_device,
60 cairo_device_reference, cairo_device_destroy);
61 CAIRO_DEFINE_BOXED ("CairoPattern", cairo_gobject_pattern,
62 cairo_pattern_reference, cairo_pattern_destroy);
63 CAIRO_DEFINE_BOXED ("CairoSurface", cairo_gobject_surface,
64 cairo_surface_reference, cairo_surface_destroy);
65 CAIRO_DEFINE_BOXED ("CairoScaledFont", cairo_gobject_scaled_font,
66 cairo_scaled_font_reference, cairo_scaled_font_destroy);
67 CAIRO_DEFINE_BOXED ("CairoFontFace", cairo_gobject_font_face,
68 cairo_font_face_reference, cairo_font_face_destroy);
69 CAIRO_DEFINE_BOXED ("CairoFontOptions", cairo_gobject_font_options,
70 cairo_font_options_copy, cairo_font_options_destroy);
71 CAIRO_DEFINE_BOXED ("CairoRegion", cairo_gobject_region,
72 cairo_region_reference, cairo_region_destroy);
74 #define COPY_FUNC(name) \
76 cairo_gobject_cairo_ ## name ## _copy (gpointer src) \
78 return g_memdup (src, sizeof (cairo_ ## name ## _t)); \
82 CAIRO_DEFINE_BOXED ("CairoRectangle", cairo_gobject_rectangle,
83 cairo_gobject_cairo_rectangle_copy, g_free);
84 COPY_FUNC (rectangle_int)
85 CAIRO_DEFINE_BOXED ("CairoRectangleInt", cairo_gobject_rectangle_int,
86 cairo_gobject_cairo_rectangle_int_copy, g_free);