Commit 1b15fc5f authored by Julian Sparber's avatar Julian Sparber
Browse files

use RsvgRectangle as out arguments for get_geometry_sub()

parent b07be96d
......@@ -1199,7 +1199,7 @@ rsvg_handle_get_dimensions (RsvgHandle * handle, RsvgDimensionData * dimension_d
}
static gboolean
get_node_geometry(RsvgHandle *handle, RsvgNode *node, cairo_rectangle_t *ink_rect, cairo_rectangle_t *logical_rect)
get_node_geometry(RsvgHandle *handle, RsvgNode *node, RsvgRectangle *ink_rect, RsvgRectangle *logical_rect)
{
RsvgDimensionData dimensions;
cairo_surface_t *target;
......@@ -1250,12 +1250,12 @@ get_node_geometry(RsvgHandle *handle, RsvgNode *node, cairo_rectangle_t *ink_rec
gboolean
rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimension_data, const char *id)
{
cairo_rectangle_t ink_r;
RsvgRectangle ink_r;
g_return_val_if_fail (RSVG_IS_HANDLE (handle), FALSE);
g_return_val_if_fail (dimension_data, FALSE);
memset (&ink_r, 0, sizeof (cairo_rectangle_t));
memset (&ink_r, 0, sizeof (RsvgRectangle));
memset (dimension_data, 0, sizeof (RsvgDimensionData));
if (!rsvg_handle_get_geometry_sub (handle, &ink_r, NULL, id)) {
......@@ -1289,19 +1289,19 @@ rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimensi
* Since: 2.46
*/
gboolean
rsvg_handle_get_geometry_sub (RsvgHandle * handle, cairo_rectangle_t * ink_rect, cairo_rectangle_t * logical_rect, const char *id)
rsvg_handle_get_geometry_sub (RsvgHandle * handle, RsvgRectangle * ink_rect, RsvgRectangle * logical_rect, const char *id)
{
RsvgNode *root = NULL;
RsvgNode *node;
gboolean has_size;
int root_width, root_height;
gboolean res = FALSE;
cairo_rectangle_t ink_r, logical_r;
RsvgRectangle ink_r, logical_r;
g_return_val_if_fail (RSVG_IS_HANDLE (handle), FALSE);
memset (&ink_r, 0, sizeof (cairo_rectangle_t));
memset (&logical_r, 0, sizeof (cairo_rectangle_t));
memset (&ink_r, 0, sizeof (RsvgRectangle));
memset (&logical_r, 0, sizeof (RsvgRectangle));
if (handle->priv->tree == NULL)
return FALSE;
......@@ -1376,7 +1376,7 @@ out:
gboolean
rsvg_handle_get_position_sub (RsvgHandle * handle, RsvgPositionData * position_data, const char *id)
{
cairo_rectangle_t ink_r;
RsvgRectangle ink_r;
int width, height;
g_return_val_if_fail (RSVG_IS_HANDLE (handle), FALSE);
......
......@@ -223,7 +223,7 @@ gboolean rsvg_drawing_ctx_draw_node_from_stack (RsvgDrawingCtx *ctx, RsvgTree *t
/* Defined in rsvg_internals/src/drawing_ctx.rs */
G_GNUC_INTERNAL
void rsvg_drawing_ctx_get_geometry (RsvgDrawingCtx *ctx, cairo_rectangle_t *ink_rect, cairo_rectangle_t *logical_rect);
void rsvg_drawing_ctx_get_geometry (RsvgDrawingCtx *ctx, RsvgRectangle *ink_rect, RsvgRectangle *logical_rect);
/* Implemented in rust/src/node.rs */
G_GNUC_INTERNAL
......
......@@ -71,6 +71,7 @@ typedef struct RsvgHandlePrivate RsvgHandlePrivate;
typedef struct _RsvgHandleClass RsvgHandleClass;
typedef struct _RsvgDimensionData RsvgDimensionData;
typedef struct _RsvgPositionData RsvgPositionData;
typedef struct _RsvgRectangle RsvgRectangle;
/**
* RsvgHandleClass:
......@@ -131,6 +132,25 @@ struct _RsvgPositionData {
int y;
};
/**
* RsvgRectangle:
* @x: X coordinate of the left side of the rectangle
* @y: Y coordinate of the the top side of the rectangle
* @width: width of the rectangle
* @height: height of the rectangle
*
* A data structure for holding a rectangle.
*
* Since: 2.46
*/
struct _RsvgRectangle {
double x;
double y;
double width;
double height;
};
void rsvg_cleanup (void);
RSVG_DEPRECATED
......@@ -156,7 +176,7 @@ void rsvg_handle_get_dimensions (RsvgHandle * handle, RsvgDimensionData * dimens
gboolean rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimension_data, const char *id);
gboolean rsvg_handle_get_position_sub (RsvgHandle * handle, RsvgPositionData * position_data, const char *id);
gboolean rsvg_handle_get_geometry_sub (RsvgHandle * handle, cairo_rectangle_t * ink_rect, cairo_rectangle_t * logical_rect, const char *id);
gboolean rsvg_handle_get_geometry_sub (RsvgHandle * handle, RsvgRectangle * ink_rect, RsvgRectangle * logical_rect, const char *id);
gboolean rsvg_handle_has_sub (RsvgHandle * handle, const char *id);
......
......@@ -1093,11 +1093,20 @@ pub extern "C" fn rsvg_drawing_ctx_add_node_and_ancestors_to_stack(
draw_ctx.add_node_and_ancestors_to_stack(node);
}
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(C)]
pub struct RsvgRectangle {
pub x: f64,
pub y: f64,
pub width: f64,
pub height: f64,
}
#[no_mangle]
pub unsafe extern "C" fn rsvg_drawing_ctx_get_geometry(
raw_draw_ctx: *const RsvgDrawingCtx,
ink_rect: *mut cairo_sys::cairo_rectangle_t,
logical_rect: *mut cairo_sys::cairo_rectangle_t,
ink_rect: *mut RsvgRectangle,
logical_rect: *mut RsvgRectangle,
) {
assert!(!raw_draw_ctx.is_null());
let draw_ctx = &mut *(raw_draw_ctx as *mut DrawingCtx<'_>);
......@@ -1105,8 +1114,8 @@ pub unsafe extern "C" fn rsvg_drawing_ctx_get_geometry(
assert!(!ink_rect.is_null());
assert!(!logical_rect.is_null());
let ink_rect: &mut cairo::Rectangle = &mut *ink_rect;
let logical_rect: &mut cairo::Rectangle = &mut *logical_rect;
let ink_rect: &mut RsvgRectangle = &mut *ink_rect;
let logical_rect: &mut RsvgRectangle = &mut *logical_rect;
match draw_ctx.get_bbox().ink_rect {
Some(r) => {
......
......@@ -501,8 +501,8 @@ dimensions_and_position (void)
g_assert_cmpint (pos.y, ==, EXAMPLE_TWO_Y);
/* TODO: test logical_rect */
cairo_rectangle_t ink_rect;
cairo_rectangle_t logical_rect;
RsvgRectangle ink_rect;
RsvgRectangle logical_rect;
g_assert (rsvg_handle_get_geometry_sub (handle, &ink_rect, &logical_rect, EXAMPLE_TWO_ID));
g_assert_cmpint (ink_rect.x, ==, EXAMPLE_TWO_X);
g_assert_cmpint (ink_rect.y, ==, EXAMPLE_TWO_Y);
......
......@@ -28,8 +28,8 @@ test_dimensions (FixtureData *fixture)
RsvgHandle *handle;
RsvgPositionData position;
RsvgDimensionData dimension;
cairo_rectangle_t ink_rect;
cairo_rectangle_t logical_rect;
RsvgRectangle ink_rect;
RsvgRectangle logical_rect;
gchar *target_file;
GError *error = NULL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment