Audit casts in callers of rsvg_drawing_ctx_acquire_node_of_type()

The pattern was

  RsvgNodeFoo *foo = (RsvgNodeFoo *) rsvg_drawing_ctx_acquire_node_of_type (ctx, FOO);

This is wrong now, since RsvgNode is a Rust structure.

Instead, do

  RsvgNode *node;
  RsvgNodeFoo *foo;

  node = rsvg_drawing_ctx_acquire_node_of_type (ctx, FOO);
  foo = rsvg_rust_cnode_get_impl (node);
parent 0256e231
......@@ -138,11 +138,15 @@ rsvg_cairo_clip_render_new (cairo_t * cr, RsvgCairoRender *parent)
}
void
rsvg_cairo_clip (RsvgDrawingCtx * ctx, RsvgClipPath * clip, RsvgBbox * bbox)
rsvg_cairo_clip (RsvgDrawingCtx * ctx, RsvgNode *node_clip_path, RsvgBbox * bbox)
{
RsvgClipPath *clip;
RsvgCairoRender *save = RSVG_CAIRO_RENDER (ctx->render);
cairo_matrix_t affinesave;
g_assert (rsvg_node_get_type (node_clip_path) == RSVG_NODE_TYPE_CLIP_PATH);
clip = rsvg_rust_cnode_get_impl (node_clip_path);
ctx->render = rsvg_cairo_clip_render_new (save->cr, save);
/* Horribly dirty hack to have the bbox premultiplied to everything */
......@@ -160,7 +164,7 @@ rsvg_cairo_clip (RsvgDrawingCtx * ctx, RsvgClipPath * clip, RsvgBbox * bbox)
}
rsvg_state_push (ctx);
_rsvg_node_draw_children ((RsvgNode *) clip, ctx, 0);
_rsvg_node_draw_children (node_clip_path, ctx, 0);
rsvg_state_pop (ctx);
if (clip->units == objectBoundingBox)
......
......@@ -35,7 +35,7 @@
G_BEGIN_DECLS
G_GNUC_INTERNAL
void rsvg_cairo_clip (RsvgDrawingCtx * ctx, RsvgClipPath * clip, RsvgBbox * bbox);
void rsvg_cairo_clip (RsvgDrawingCtx * ctx, RsvgNode *node_clip_path, RsvgBbox * bbox);
G_END_DECLS
......
......@@ -41,6 +41,7 @@
#include <pango/pangocairo.h>
#include <pango/pangofc-fontmap.h>
static gboolean
add_color_stop_to_gradient (RsvgNode *node, gpointer data)
{
......@@ -50,7 +51,7 @@ add_color_stop_to_gradient (RsvgNode *node, gpointer data)
if (rsvg_node_get_type (node) != RSVG_NODE_TYPE_STOP)
return TRUE; /* just ignore this node */
stop = (RsvgGradientStop *) node;
stop = rsvg_rust_cnode_get_impl (node);
if (!stop->is_valid) {
/* Don't add any more stops. */
......@@ -69,10 +70,14 @@ add_color_stops_to_gradient (Gradient *gradient, RsvgNode *node)
}
static Gradient *
linear_gradient_to_rust (RsvgLinearGradient *linear)
linear_gradient_to_rust (RsvgNode *node)
{
RsvgLinearGradient *linear;
Gradient *gradient;
g_assert (rsvg_node_get_type (node) == RSVG_NODE_TYPE_LINEAR_GRADIENT);
linear = rsvg_rust_cnode_get_impl (node);
gradient = gradient_linear_new (linear->hasx1 ? &linear->x1 : NULL,
linear->hasy1 ? &linear->y1 : NULL,
linear->hasx2 ? &linear->x2 : NULL,
......@@ -82,16 +87,20 @@ linear_gradient_to_rust (RsvgLinearGradient *linear)
linear->hasspread ? &linear->spread : NULL,
linear->fallback);
add_color_stops_to_gradient (gradient, (RsvgNode *) linear);
add_color_stops_to_gradient (gradient, node);
return gradient;
}
static Gradient *
radial_gradient_to_rust (RsvgRadialGradient *radial)
radial_gradient_to_rust (RsvgNode *node)
{
RsvgRadialGradient *radial;
Gradient *gradient;
g_assert (rsvg_node_get_type (node) == RSVG_NODE_TYPE_RADIAL_GRADIENT);
radial = rsvg_rust_cnode_get_impl (node);
gradient = gradient_radial_new (radial->hascx ? &radial->cx : NULL,
radial->hascy ? &radial->cy : NULL,
radial->hasr ? &radial->r : NULL,
......@@ -102,7 +111,7 @@ radial_gradient_to_rust (RsvgRadialGradient *radial)
radial->hasspread ? &radial->spread : NULL,
radial->fallback);
add_color_stops_to_gradient (gradient, (RsvgNode *) radial);
add_color_stops_to_gradient (gradient, node);
return gradient;
}
......@@ -111,9 +120,9 @@ Gradient *
rsvg_gradient_node_to_rust_gradient (RsvgNode *node)
{
if (rsvg_node_get_type (node) == RSVG_NODE_TYPE_LINEAR_GRADIENT) {
return linear_gradient_to_rust ((RsvgLinearGradient *) node);
return linear_gradient_to_rust (node);
} else if (rsvg_node_get_type (node) == RSVG_NODE_TYPE_RADIAL_GRADIENT) {
return radial_gradient_to_rust ((RsvgRadialGradient *) node);
return radial_gradient_to_rust (node);
} else {
return NULL;
}
......@@ -121,12 +130,12 @@ rsvg_gradient_node_to_rust_gradient (RsvgNode *node)
static void
_set_source_rsvg_linear_gradient (RsvgDrawingCtx *ctx,
RsvgLinearGradient *linear,
RsvgNode *node,
guint8 opacity, RsvgBbox bbox)
{
Gradient *gradient;
gradient = linear_gradient_to_rust (linear);
gradient = linear_gradient_to_rust (node);
gradient_resolve_fallbacks_and_set_pattern (gradient, ctx, opacity, bbox);
......@@ -135,12 +144,12 @@ _set_source_rsvg_linear_gradient (RsvgDrawingCtx *ctx,
static void
_set_source_rsvg_radial_gradient (RsvgDrawingCtx * ctx,
RsvgRadialGradient * radial,
RsvgNode *node,
guint8 opacity, RsvgBbox bbox)
{
Gradient *gradient;
gradient = radial_gradient_to_rust (radial);
gradient = radial_gradient_to_rust (node);
gradient_resolve_fallbacks_and_set_pattern (gradient, ctx, opacity, bbox);
......@@ -168,13 +177,15 @@ _set_source_rsvg_solid_color (RsvgDrawingCtx * ctx,
}
static gboolean
_set_source_rsvg_pattern (RsvgDrawingCtx * ctx,
RsvgPattern * rsvg_pattern, RsvgBbox bbox)
_set_source_rsvg_pattern (RsvgDrawingCtx *ctx,
RsvgNode *node,
RsvgBbox bbox)
{
Pattern *pattern;
gboolean result;
pattern = rsvg_pattern_node_to_rust_pattern ((RsvgNode *) rsvg_pattern);
pattern = rsvg_pattern_node_to_rust_pattern (node);
g_assert (pattern != NULL);
result = pattern_resolve_fallbacks_and_set_pattern (pattern, ctx, bbox);
......@@ -204,13 +215,13 @@ _set_source_rsvg_paint_server (RsvgDrawingCtx * ctx,
if (node == NULL) {
use_alternate = TRUE;
} else if (rsvg_node_get_type (node) == RSVG_NODE_TYPE_LINEAR_GRADIENT) {
_set_source_rsvg_linear_gradient (ctx, (RsvgLinearGradient *) node, opacity, bbox);
_set_source_rsvg_linear_gradient (ctx, node, opacity, bbox);
had_paint_server = TRUE;
} else if (rsvg_node_get_type (node) == RSVG_NODE_TYPE_RADIAL_GRADIENT) {
_set_source_rsvg_radial_gradient (ctx, (RsvgRadialGradient *) node, opacity, bbox);
_set_source_rsvg_radial_gradient (ctx, node, opacity, bbox);
had_paint_server = TRUE;
} else if (rsvg_node_get_type (node) == RSVG_NODE_TYPE_PATTERN) {
if (_set_source_rsvg_pattern (ctx, (RsvgPattern *) node, bbox)) {
if (_set_source_rsvg_pattern (ctx, node, bbox)) {
had_paint_server = TRUE;
} else {
use_alternate = TRUE;
......@@ -607,7 +618,7 @@ rsvg_cairo_set_cairo_context (RsvgDrawingCtx *ctx, cairo_t *cr)
}
static void
rsvg_cairo_generate_mask (cairo_t * cr, RsvgMask * self, RsvgDrawingCtx * ctx, RsvgBbox * bbox)
rsvg_cairo_generate_mask (cairo_t * cr, RsvgNode *node_mask, RsvgDrawingCtx *ctx, RsvgBbox *bbox)
{
RsvgCairoRender *render = RSVG_CAIRO_RENDER (ctx->render);
cairo_surface_t *surface;
......@@ -619,6 +630,10 @@ rsvg_cairo_generate_mask (cairo_t * cr, RsvgMask * self, RsvgDrawingCtx * ctx, R
cairo_matrix_t affinesave;
double sx, sy, sw, sh;
gboolean nest = cr != render->initial_cr;
RsvgMask *self;
g_assert (rsvg_node_get_type (node_mask) == RSVG_NODE_TYPE_MASK);
self = rsvg_rust_cnode_get_impl (node_mask);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) {
......@@ -669,12 +684,16 @@ rsvg_cairo_generate_mask (cairo_t * cr, RsvgMask * self, RsvgDrawingCtx * ctx, R
}
rsvg_state_push (ctx);
_rsvg_node_draw_children (&self->super, ctx, 0);
_rsvg_node_draw_children (node_mask, ctx, 0);
rsvg_state_pop (ctx);
if (self->contentunits == objectBoundingBox) {
RsvgState *state;
rsvg_drawing_ctx_pop_view_box (ctx);
self->super.state->affine = affinesave;
state = rsvg_node_get_state (node_mask);
state->affine = affinesave;
}
render->cr = save_cr;
......@@ -731,11 +750,11 @@ rsvg_cairo_push_render_stack (RsvgDrawingCtx * ctx)
RsvgNode *node;
node = rsvg_drawing_ctx_acquire_node_of_type (ctx, rsvg_current_state (ctx)->clip_path, RSVG_NODE_TYPE_CLIP_PATH);
if (node) {
RsvgClipPath *clip_path = (RsvgClipPath *) node;
RsvgClipPath *clip_path = rsvg_rust_cnode_get_impl (node);
switch (clip_path->units) {
case userSpaceOnUse:
rsvg_cairo_clip (ctx, clip_path, NULL);
rsvg_cairo_clip (ctx, node, NULL);
break;
case objectBoundingBox:
lateclip = TRUE;
......@@ -800,7 +819,7 @@ rsvg_cairo_pop_render_stack (RsvgDrawingCtx * ctx)
{
RsvgCairoRender *render = RSVG_CAIRO_RENDER (ctx->render);
cairo_t *child_cr = render->cr;
RsvgClipPath *lateclip = NULL;
RsvgNode *lateclip = NULL;
cairo_surface_t *surface = NULL;
RsvgState *state = rsvg_current_state (ctx);
gboolean nest, needs_destroy = FALSE;
......@@ -808,10 +827,15 @@ rsvg_cairo_pop_render_stack (RsvgDrawingCtx * ctx)
if (rsvg_current_state (ctx)->clip_path) {
RsvgNode *node;
node = rsvg_drawing_ctx_acquire_node_of_type (ctx, rsvg_current_state (ctx)->clip_path, RSVG_NODE_TYPE_CLIP_PATH);
if (node && ((RsvgClipPath *) node)->units == objectBoundingBox)
lateclip = (RsvgClipPath *) node;
else
rsvg_drawing_ctx_release_node (ctx, node);
if (node) {
RsvgClipPath *cp = rsvg_rust_cnode_get_impl (node);
if (cp->units == objectBoundingBox) {
lateclip = node;
} else {
rsvg_drawing_ctx_release_node (ctx, node);
}
}
}
if (state->opacity == 0xFF
......@@ -849,7 +873,7 @@ rsvg_cairo_pop_render_stack (RsvgDrawingCtx * ctx)
if (lateclip) {
rsvg_cairo_clip (ctx, lateclip, &render->bbox);
rsvg_drawing_ctx_release_node (ctx, (RsvgNode *) lateclip);
rsvg_drawing_ctx_release_node (ctx, lateclip);
}
cairo_set_operator (render->cr, state->comp_op);
......@@ -859,7 +883,7 @@ rsvg_cairo_pop_render_stack (RsvgDrawingCtx * ctx)
mask = rsvg_drawing_ctx_acquire_node_of_type (ctx, state->mask, RSVG_NODE_TYPE_MASK);
if (mask) {
rsvg_cairo_generate_mask (render->cr, (RsvgMask *) mask, ctx, &render->bbox);
rsvg_cairo_generate_mask (render->cr, mask, ctx, &render->bbox);
rsvg_drawing_ctx_release_node (ctx, mask);
}
} else if (state->opacity != 0xFF)
......
......@@ -562,7 +562,7 @@ render_child_if_filter_primitive (RsvgNode *node, gpointer data)
* Returns: (transfer full): a new #cairo_surface_t
**/
cairo_surface_t *
rsvg_filter_render (RsvgNode *node,
rsvg_filter_render (RsvgNode *filter_node,
cairo_surface_t *source,
RsvgDrawingCtx *context,
RsvgBbox *bounds,
......@@ -576,8 +576,8 @@ rsvg_filter_render (RsvgNode *node,
g_return_val_if_fail (source != NULL, NULL);
g_return_val_if_fail (cairo_surface_get_type (source) == CAIRO_SURFACE_TYPE_IMAGE, NULL);
g_assert (rsvg_node_get_type (node) == RSVG_NODE_TYPE_FILTER);
filter = rsvg_rust_cnode_get_impl (node);
g_assert (rsvg_node_get_type (filter_node) == RSVG_NODE_TYPE_FILTER);
filter = rsvg_rust_cnode_get_impl (filter_node);
ctx = g_new0 (RsvgFilterContext, 1);
ctx->filter = filter;
......@@ -594,7 +594,7 @@ rsvg_filter_render (RsvgNode *node,
for (i = 0; i < 4; i++)
ctx->channelmap[i] = channelmap[i] - '0';
rsvg_node_foreach_child (node, render_child_if_filter_primitive, ctx);
rsvg_node_foreach_child (filter_node, render_child_if_filter_primitive, ctx);
output = ctx->lastresult.surface;
......
......@@ -44,7 +44,7 @@ struct _RsvgFilter {
};
G_GNUC_INTERNAL
cairo_surface_t *rsvg_filter_render (RsvgNode *node,
cairo_surface_t *rsvg_filter_render (RsvgNode *filter_node,
cairo_surface_t *source,
RsvgDrawingCtx *context,
RsvgBbox *dimentions,
......
......@@ -548,7 +548,7 @@ rsvg_pattern_node_to_rust_pattern (RsvgNode *node)
Pattern *pattern;
if (rsvg_node_get_type (node) != RSVG_NODE_TYPE_PATTERN)
return NULL;
return NULL; /* FIXME: make this always return a Pattern; make the checks in the caller */
pnode = rsvg_rust_cnode_get_impl (node);
......
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