1#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
7#![allow(
8 clippy::approx_constant,
9 clippy::type_complexity,
10 clippy::unreadable_literal,
11 clippy::upper_case_acronyms
12)]
13#![cfg_attr(docsrs, feature(doc_cfg))]
14
15use cairo_sys as cairo;
16use gdk_pixbuf_sys as gdk_pixbuf;
17use gio_sys as gio;
18use glib_sys as glib;
19use gobject_sys as gobject;
20
21#[cfg(unix)]
22#[allow(unused_imports)]
23use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t};
24#[allow(unused_imports)]
25use libc::{intptr_t, off_t, size_t, ssize_t, time_t, uintptr_t, FILE};
26#[allow(unused_imports)]
27use std::ffi::{
28 c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void,
29};
30
31#[allow(unused_imports)]
32use glib::{gboolean, gconstpointer, gpointer, GType};
33
34pub type RsvgError = c_int;
36pub const RSVG_ERROR_FAILED: RsvgError = 0;
37
38pub type RsvgUnit = c_int;
39pub const RSVG_UNIT_PERCENT: RsvgUnit = 0;
40pub const RSVG_UNIT_PX: RsvgUnit = 1;
41pub const RSVG_UNIT_EM: RsvgUnit = 2;
42pub const RSVG_UNIT_EX: RsvgUnit = 3;
43pub const RSVG_UNIT_IN: RsvgUnit = 4;
44pub const RSVG_UNIT_CM: RsvgUnit = 5;
45pub const RSVG_UNIT_MM: RsvgUnit = 6;
46pub const RSVG_UNIT_PT: RsvgUnit = 7;
47pub const RSVG_UNIT_PC: RsvgUnit = 8;
48#[cfg(feature = "v2_58")]
49#[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
50pub const RSVG_UNIT_CH: RsvgUnit = 9;
51
52pub type RsvgHandleFlags = c_uint;
56pub const RSVG_HANDLE_FLAGS_NONE: RsvgHandleFlags = 0;
57pub const RSVG_HANDLE_FLAG_UNLIMITED: RsvgHandleFlags = 1;
58pub const RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA: RsvgHandleFlags = 2;
59
60pub type RsvgSizeFunc = Option<unsafe extern "C" fn(*mut c_int, *mut c_int, gpointer)>;
62
63#[derive(Copy, Clone)]
65#[repr(C)]
66pub struct RsvgDimensionData {
67 pub width: c_int,
68 pub height: c_int,
69 pub em: c_double,
70 pub ex: c_double,
71}
72
73impl ::std::fmt::Debug for RsvgDimensionData {
74 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
75 f.debug_struct(&format!("RsvgDimensionData @ {self:p}"))
76 .field("width", &self.width)
77 .field("height", &self.height)
78 .field("em", &self.em)
79 .field("ex", &self.ex)
80 .finish()
81 }
82}
83
84#[derive(Copy, Clone)]
85#[repr(C)]
86pub struct RsvgHandleClass {
87 pub parent: gobject::GObjectClass,
88 pub _abi_padding: [gpointer; 15],
89}
90
91impl ::std::fmt::Debug for RsvgHandleClass {
92 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
93 f.debug_struct(&format!("RsvgHandleClass @ {self:p}"))
94 .field("parent", &self.parent)
95 .finish()
96 }
97}
98
99#[derive(Copy, Clone)]
100#[repr(C)]
101pub struct RsvgLength {
102 pub length: c_double,
103 pub unit: RsvgUnit,
104}
105
106impl ::std::fmt::Debug for RsvgLength {
107 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
108 f.debug_struct(&format!("RsvgLength @ {self:p}"))
109 .field("length", &self.length)
110 .field("unit", &self.unit)
111 .finish()
112 }
113}
114
115#[derive(Copy, Clone)]
116#[repr(C)]
117pub struct RsvgPositionData {
118 pub x: c_int,
119 pub y: c_int,
120}
121
122impl ::std::fmt::Debug for RsvgPositionData {
123 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
124 f.debug_struct(&format!("RsvgPositionData @ {self:p}"))
125 .field("x", &self.x)
126 .field("y", &self.y)
127 .finish()
128 }
129}
130
131#[derive(Copy, Clone)]
132#[repr(C)]
133pub struct RsvgRectangle {
134 pub x: c_double,
135 pub y: c_double,
136 pub width: c_double,
137 pub height: c_double,
138}
139
140impl ::std::fmt::Debug for RsvgRectangle {
141 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
142 f.debug_struct(&format!("RsvgRectangle @ {self:p}"))
143 .field("x", &self.x)
144 .field("y", &self.y)
145 .field("width", &self.width)
146 .field("height", &self.height)
147 .finish()
148 }
149}
150
151#[derive(Copy, Clone)]
153#[repr(C)]
154pub struct RsvgHandle {
155 pub parent: gobject::GObject,
156 pub _abi_padding: [gpointer; 16],
157}
158
159impl ::std::fmt::Debug for RsvgHandle {
160 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
161 f.debug_struct(&format!("RsvgHandle @ {self:p}"))
162 .field("parent", &self.parent)
163 .finish()
164 }
165}
166
167#[link(name = "rsvg-2")]
168extern "C" {
169
170 pub fn rsvg_error_get_type() -> GType;
174 pub fn rsvg_error_quark() -> glib::GQuark;
175
176 pub fn rsvg_handle_flags_get_type() -> GType;
180
181 pub fn rsvg_handle_get_type() -> GType;
185 pub fn rsvg_handle_new() -> *mut RsvgHandle;
186 pub fn rsvg_handle_new_from_data(
187 data: *const u8,
188 data_len: size_t,
189 error: *mut *mut glib::GError,
190 ) -> *mut RsvgHandle;
191 pub fn rsvg_handle_new_from_file(
192 filename: *const c_char,
193 error: *mut *mut glib::GError,
194 ) -> *mut RsvgHandle;
195 pub fn rsvg_handle_new_from_gfile_sync(
196 file: *mut gio::GFile,
197 flags: RsvgHandleFlags,
198 cancellable: *mut gio::GCancellable,
199 error: *mut *mut glib::GError,
200 ) -> *mut RsvgHandle;
201 pub fn rsvg_handle_new_from_stream_sync(
202 input_stream: *mut gio::GInputStream,
203 base_file: *mut gio::GFile,
204 flags: RsvgHandleFlags,
205 cancellable: *mut gio::GCancellable,
206 error: *mut *mut glib::GError,
207 ) -> *mut RsvgHandle;
208 pub fn rsvg_handle_new_with_flags(flags: RsvgHandleFlags) -> *mut RsvgHandle;
209 pub fn rsvg_handle_close(handle: *mut RsvgHandle, error: *mut *mut glib::GError) -> gboolean;
210 pub fn rsvg_handle_free(handle: *mut RsvgHandle);
211 pub fn rsvg_handle_get_base_uri(handle: *mut RsvgHandle) -> *const c_char;
212 pub fn rsvg_handle_get_desc(handle: *mut RsvgHandle) -> *const c_char;
213 pub fn rsvg_handle_get_dimensions(
214 handle: *mut RsvgHandle,
215 dimension_data: *mut RsvgDimensionData,
216 );
217 pub fn rsvg_handle_get_dimensions_sub(
218 handle: *mut RsvgHandle,
219 dimension_data: *mut RsvgDimensionData,
220 id: *const c_char,
221 ) -> gboolean;
222 pub fn rsvg_handle_get_geometry_for_element(
223 handle: *mut RsvgHandle,
224 id: *const c_char,
225 out_ink_rect: *mut RsvgRectangle,
226 out_logical_rect: *mut RsvgRectangle,
227 error: *mut *mut glib::GError,
228 ) -> gboolean;
229 pub fn rsvg_handle_get_geometry_for_layer(
230 handle: *mut RsvgHandle,
231 id: *const c_char,
232 viewport: *const RsvgRectangle,
233 out_ink_rect: *mut RsvgRectangle,
234 out_logical_rect: *mut RsvgRectangle,
235 error: *mut *mut glib::GError,
236 ) -> gboolean;
237 pub fn rsvg_handle_get_intrinsic_dimensions(
238 handle: *mut RsvgHandle,
239 out_has_width: *mut gboolean,
240 out_width: *mut RsvgLength,
241 out_has_height: *mut gboolean,
242 out_height: *mut RsvgLength,
243 out_has_viewbox: *mut gboolean,
244 out_viewbox: *mut RsvgRectangle,
245 );
246 pub fn rsvg_handle_get_intrinsic_size_in_pixels(
247 handle: *mut RsvgHandle,
248 out_width: *mut c_double,
249 out_height: *mut c_double,
250 ) -> gboolean;
251 pub fn rsvg_handle_get_metadata(handle: *mut RsvgHandle) -> *const c_char;
252 pub fn rsvg_handle_get_pixbuf(handle: *mut RsvgHandle) -> *mut gdk_pixbuf::GdkPixbuf;
253 #[cfg(feature = "v2_59")]
254 #[cfg_attr(docsrs, doc(cfg(feature = "v2_59")))]
255 pub fn rsvg_handle_get_pixbuf_and_error(
256 handle: *mut RsvgHandle,
257 error: *mut *mut glib::GError,
258 ) -> *mut gdk_pixbuf::GdkPixbuf;
259 pub fn rsvg_handle_get_pixbuf_sub(
260 handle: *mut RsvgHandle,
261 id: *const c_char,
262 ) -> *mut gdk_pixbuf::GdkPixbuf;
263 pub fn rsvg_handle_get_position_sub(
264 handle: *mut RsvgHandle,
265 position_data: *mut RsvgPositionData,
266 id: *const c_char,
267 ) -> gboolean;
268 pub fn rsvg_handle_get_title(handle: *mut RsvgHandle) -> *const c_char;
269 pub fn rsvg_handle_has_sub(handle: *mut RsvgHandle, id: *const c_char) -> gboolean;
270 pub fn rsvg_handle_internal_set_testing(handle: *mut RsvgHandle, testing: gboolean);
271 pub fn rsvg_handle_read_stream_sync(
272 handle: *mut RsvgHandle,
273 stream: *mut gio::GInputStream,
274 cancellable: *mut gio::GCancellable,
275 error: *mut *mut glib::GError,
276 ) -> gboolean;
277 pub fn rsvg_handle_render_cairo(handle: *mut RsvgHandle, cr: *mut cairo::cairo_t) -> gboolean;
278 pub fn rsvg_handle_render_cairo_sub(
279 handle: *mut RsvgHandle,
280 cr: *mut cairo::cairo_t,
281 id: *const c_char,
282 ) -> gboolean;
283 pub fn rsvg_handle_render_document(
284 handle: *mut RsvgHandle,
285 cr: *mut cairo::cairo_t,
286 viewport: *const RsvgRectangle,
287 error: *mut *mut glib::GError,
288 ) -> gboolean;
289 pub fn rsvg_handle_render_element(
290 handle: *mut RsvgHandle,
291 cr: *mut cairo::cairo_t,
292 id: *const c_char,
293 element_viewport: *const RsvgRectangle,
294 error: *mut *mut glib::GError,
295 ) -> gboolean;
296 pub fn rsvg_handle_render_layer(
297 handle: *mut RsvgHandle,
298 cr: *mut cairo::cairo_t,
299 id: *const c_char,
300 viewport: *const RsvgRectangle,
301 error: *mut *mut glib::GError,
302 ) -> gboolean;
303 pub fn rsvg_handle_set_base_gfile(handle: *mut RsvgHandle, base_file: *mut gio::GFile);
304 pub fn rsvg_handle_set_base_uri(handle: *mut RsvgHandle, base_uri: *const c_char);
305 #[cfg(feature = "v2_59")]
306 #[cfg_attr(docsrs, doc(cfg(feature = "v2_59")))]
307 pub fn rsvg_handle_set_cancellable_for_rendering(
308 handle: *mut RsvgHandle,
309 cancellable: *mut gio::GCancellable,
310 );
311 pub fn rsvg_handle_set_dpi(handle: *mut RsvgHandle, dpi: c_double);
312 pub fn rsvg_handle_set_dpi_x_y(handle: *mut RsvgHandle, dpi_x: c_double, dpi_y: c_double);
313 pub fn rsvg_handle_set_size_callback(
314 handle: *mut RsvgHandle,
315 size_func: RsvgSizeFunc,
316 user_data: gpointer,
317 user_data_destroy: glib::GDestroyNotify,
318 );
319 pub fn rsvg_handle_set_stylesheet(
320 handle: *mut RsvgHandle,
321 css: *const u8,
322 css_len: size_t,
323 error: *mut *mut glib::GError,
324 ) -> gboolean;
325 pub fn rsvg_handle_write(
326 handle: *mut RsvgHandle,
327 buf: *const u8,
328 count: size_t,
329 error: *mut *mut glib::GError,
330 ) -> gboolean;
331
332 pub fn rsvg_cleanup();
336 pub fn rsvg_init();
337 pub fn rsvg_pixbuf_from_file(
338 filename: *const c_char,
339 error: *mut *mut glib::GError,
340 ) -> *mut gdk_pixbuf::GdkPixbuf;
341 pub fn rsvg_pixbuf_from_file_at_max_size(
342 filename: *const c_char,
343 max_width: c_int,
344 max_height: c_int,
345 error: *mut *mut glib::GError,
346 ) -> *mut gdk_pixbuf::GdkPixbuf;
347 pub fn rsvg_pixbuf_from_file_at_size(
348 filename: *const c_char,
349 width: c_int,
350 height: c_int,
351 error: *mut *mut glib::GError,
352 ) -> *mut gdk_pixbuf::GdkPixbuf;
353 pub fn rsvg_pixbuf_from_file_at_zoom(
354 filename: *const c_char,
355 x_zoom: c_double,
356 y_zoom: c_double,
357 error: *mut *mut glib::GError,
358 ) -> *mut gdk_pixbuf::GdkPixbuf;
359 pub fn rsvg_pixbuf_from_file_at_zoom_with_max(
360 filename: *const c_char,
361 x_zoom: c_double,
362 y_zoom: c_double,
363 max_width: c_int,
364 max_height: c_int,
365 error: *mut *mut glib::GError,
366 ) -> *mut gdk_pixbuf::GdkPixbuf;
367 pub fn rsvg_set_default_dpi(dpi: c_double);
368 pub fn rsvg_set_default_dpi_x_y(dpi_x: c_double, dpi_y: c_double);
369 pub fn rsvg_term();
370
371}