[librsvg/rustification] Move the get_*_marker functions to take an RsvgDrawingCtx, not a RsvgState
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustification] Move the get_*_marker functions to take an RsvgDrawingCtx, not a RsvgState
- Date: Wed, 9 Nov 2016 01:18:11 +0000 (UTC)
commit a77084dda60fce6b506a508074672b7ba7543ee5
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Nov 8 19:06:42 2016 -0600
Move the get_*_marker functions to take an RsvgDrawingCtx, not a RsvgState
That is, following the "fish out stuff from the current state" pattern
from rsvg_get_normalized_stroke_width().
rsvg-base.c | 67 +++++++++++++++++++++++++++++++++++----------------
rsvg-marker.c | 15 ++---------
rsvg-private.h | 9 +++++++
rsvg-styles.c | 18 --------------
rsvg-styles.h | 7 -----
rust/src/marker.rs | 4 ++-
6 files changed, 61 insertions(+), 59 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index 24338b5..961f53a 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -304,7 +304,7 @@ rsvg_standard_element_start (RsvgHandle * ctx, const char *name, RsvgPropertyBag
else if (!strcmp (name, "tref"))
newnode = rsvg_new_tref ();
else {
- /* hack for bug 401115. whenever we encounter a node we don't understand, push it into a
group.
+ /* hack for bug 401115. whenever we encounter a node we don't understand, push it into a
group.
this will allow us to handle things like conditionals properly. */
newnode = rsvg_new_group ();
}
@@ -946,7 +946,7 @@ rsvg_processing_instruction (void *ctx, const xmlChar * target, const xmlChar *
&mime_type,
&style_data_len,
NULL);
- if (style_data &&
+ if (style_data &&
mime_type &&
strcmp (mime_type, "text/css") == 0) {
rsvg_parse_cssbuffer (handle, style_data, style_data_len);
@@ -1059,7 +1059,7 @@ rsvg_handle_set_base_uri (RsvgHandle * handle, const char *base_uri)
if (base_uri == NULL)
return;
- if (rsvg_path_is_uri (base_uri))
+ if (rsvg_path_is_uri (base_uri))
uri = g_strdup (base_uri);
else
uri = rsvg_get_base_uri_from_filename (base_uri);
@@ -1242,7 +1242,7 @@ rsvg_drawing_ctx_free (RsvgDrawingCtx * handle)
g_warn_if_fail (handle->acquired_nodes == NULL);
g_slist_free (handle->acquired_nodes);
-
+
if (handle->pango_context != NULL)
g_object_unref (handle->pango_context);
@@ -1446,7 +1446,7 @@ rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimensi
bbox.rect.height + bbox.rect.y * 2,
12) + 0.5);
}
-
+
dimension_data->em = dimension_data->width;
dimension_data->ex = dimension_data->height;
@@ -1553,7 +1553,7 @@ bail:
return ret;
}
-/**
+/**
* rsvg_handle_has_sub:
* @handle: a #RsvgHandle
* @id: an element's id within the SVG
@@ -1576,7 +1576,7 @@ rsvg_handle_has_sub (RsvgHandle * handle,
return rsvg_defs_lookup (handle->priv->defs, id) != NULL;
}
-/**
+/**
* rsvg_set_default_dpi:
* @dpi: Dots Per Inch (aka Pixels Per Inch)
*
@@ -1592,7 +1592,7 @@ rsvg_set_default_dpi (double dpi)
rsvg_set_default_dpi_x_y (dpi, dpi);
}
-/**
+/**
* rsvg_set_default_dpi_x_y:
* @dpi_x: Dots Per Inch (aka Pixels Per Inch)
* @dpi_y: Dots Per Inch (aka Pixels Per Inch)
@@ -1688,16 +1688,16 @@ rsvg_handle_set_dpi_x_y (RsvgHandle * handle, double dpi_x, double dpi_y)
* RsvgDimensionData dimensions;
* double x_factor, y_factor;
* double scale_factor;
- *
+ *
* rsvg_handle_get_dimensions (handle, &dimensions);
- *
+ *
* x_factor = (double) width / dimensions.width;
* y_factor = (double) height / dimensions.height;
- *
+ *
* scale_factor = MIN (x_factor, y_factor);
- *
+ *
* cairo_scale (cr, scale_factor, scale_factor);
- *
+ *
* rsvg_handle_render_cairo (handle, cr);
* }
* ]|
@@ -2173,6 +2173,31 @@ rsvg_get_normalized_stroke_width (RsvgDrawingCtx *ctx)
return _rsvg_css_normalize_length (&state->stroke_width, ctx, LENGTH_DIR_BOTH);
}
+
+const char *
+rsvg_get_start_marker (RsvgDrawingCtx *ctx)
+{
+ RsvgState *state = rsvg_current_state (ctx);
+
+ return state->startMarker;
+}
+
+const char *
+rsvg_get_middle_marker (RsvgDrawingCtx *ctx)
+{
+ RsvgState *state = rsvg_current_state (ctx);
+
+ return state->middleMarker;
+}
+
+const char *
+rsvg_get_end_marker (RsvgDrawingCtx *ctx)
+{
+ RsvgState *state = rsvg_current_state (ctx);
+
+ return state->endMarker;
+}
+
void
rsvg_add_clipping_rect (RsvgDrawingCtx * ctx, double x, double y, double w, double h)
{
@@ -2446,7 +2471,7 @@ _rsvg_handle_resolve_uri (RsvgHandle *handle,
return resolved_uri;
}
-char *
+char *
_rsvg_handle_acquire_data (RsvgHandle *handle,
const char *url,
char **content_type,
@@ -2459,10 +2484,10 @@ _rsvg_handle_acquire_data (RsvgHandle *handle,
uri = _rsvg_handle_resolve_uri (handle, url);
if (_rsvg_handle_allow_load (handle, uri, error)) {
- data = _rsvg_io_acquire_data (uri,
- rsvg_handle_get_base_uri (handle),
- content_type,
- len,
+ data = _rsvg_io_acquire_data (uri,
+ rsvg_handle_get_base_uri (handle),
+ content_type,
+ len,
handle->priv->cancellable,
error);
} else {
@@ -2485,9 +2510,9 @@ _rsvg_handle_acquire_stream (RsvgHandle *handle,
uri = _rsvg_handle_resolve_uri (handle, url);
if (_rsvg_handle_allow_load (handle, uri, error)) {
- stream = _rsvg_io_acquire_stream (uri,
- rsvg_handle_get_base_uri (handle),
- content_type,
+ stream = _rsvg_io_acquire_stream (uri,
+ rsvg_handle_get_base_uri (handle),
+ content_type,
handle->priv->cancellable,
error);
} else {
diff --git a/rsvg-marker.c b/rsvg-marker.c
index d90d149..e280216 100644
--- a/rsvg-marker.c
+++ b/rsvg-marker.c
@@ -205,7 +205,6 @@ rsvg_marker_render (const char * marker_name, gdouble xpos, gdouble ypos, gdoubl
extern void rsvg_rust_render_markers (RsvgDrawingCtx *ctx,
RsvgPathBuilder *builder,
- double linewidth,
const char *startmarker,
const char *middlemarker,
const char *endmarker);
@@ -214,17 +213,9 @@ void
rsvg_render_markers (RsvgDrawingCtx *ctx,
RsvgPathBuilder *builder)
{
- RsvgState *state;
- double linewidth;
-
- state = rsvg_current_state (ctx);
-
- linewidth = rsvg_get_normalized_stroke_width (ctx);
-
rsvg_rust_render_markers (ctx,
builder,
- linewidth,
- rsvg_state_get_start_marker (state),
- rsvg_state_get_middle_marker (state),
- rsvg_state_get_end_marker (state));
+ rsvg_get_start_marker (ctx),
+ rsvg_get_middle_marker (ctx),
+ rsvg_get_end_marker (ctx));
}
diff --git a/rsvg-private.h b/rsvg-private.h
index 797fc08..078f696 100644
--- a/rsvg-private.h
+++ b/rsvg-private.h
@@ -386,8 +386,17 @@ void rsvg_render_path_builder (RsvgDrawingCtx * ctx, RsvgPathBuilder *builder)
G_GNUC_INTERNAL
void rsvg_render_surface (RsvgDrawingCtx * ctx, cairo_surface_t *surface,
double x, double y, double w, double h);
+
G_GNUC_INTERNAL
double rsvg_get_normalized_stroke_width (RsvgDrawingCtx *ctx);
+
+G_GNUC_INTERNAL
+const char *rsvg_get_start_marker (RsvgDrawingCtx *ctx);
+G_GNUC_INTERNAL
+const char *rsvg_get_middle_marker (RsvgDrawingCtx *ctx);
+G_GNUC_INTERNAL
+const char *rsvg_get_end_marker (RsvgDrawingCtx *ctx);
+
G_GNUC_INTERNAL
void rsvg_render_free (RsvgRender * render);
G_GNUC_INTERNAL
diff --git a/rsvg-styles.c b/rsvg-styles.c
index 24a0e4a..de5eb00 100644
--- a/rsvg-styles.c
+++ b/rsvg-styles.c
@@ -1699,21 +1699,3 @@ rsvg_state_reconstruct (RsvgState * state, RsvgNode * current)
rsvg_state_reconstruct (state, current->parent);
rsvg_state_inherit (state, current->state);
}
-
-const char *
-rsvg_state_get_start_marker (RsvgState *state)
-{
- return state->startMarker;
-}
-
-const char *
-rsvg_state_get_middle_marker (RsvgState *state)
-{
- return state->middleMarker;
-}
-
-const char *
-rsvg_state_get_end_marker (RsvgState *state)
-{
- return state->endMarker;
-}
diff --git a/rsvg-styles.h b/rsvg-styles.h
index ae46565..a044d3f 100644
--- a/rsvg-styles.h
+++ b/rsvg-styles.h
@@ -243,13 +243,6 @@ void rsvg_state_reinherit_top (RsvgDrawingCtx * ctx, RsvgState * state, int domi
G_GNUC_INTERNAL
void rsvg_state_reconstruct (RsvgState * state, RsvgNode * current);
-G_GNUC_INTERNAL
-const char *rsvg_state_get_start_marker (RsvgState *state);
-G_GNUC_INTERNAL
-const char *rsvg_state_get_middle_marker (RsvgState *state);
-G_GNUC_INTERNAL
-const char *rsvg_state_get_end_marker (RsvgState *state);
-
G_END_DECLS
#endif /* RSVG_STYLES_H */
diff --git a/rust/src/marker.rs b/rust/src/marker.rs
index cb68f63..d9088cf 100644
--- a/rust/src/marker.rs
+++ b/rust/src/marker.rs
@@ -300,6 +300,7 @@ extern "C" {
orient: f64,
linewidth: f64,
ctx: *mut RsvgDrawingCtx);
+ fn rsvg_get_normalized_stroke_width (ctx: *const RsvgDrawingCtx) -> f64;
}
enum SubpathState {
@@ -356,10 +357,11 @@ fn render_marker_at_end_of_segment (segment: &Segment,
#[no_mangle]
pub extern fn rsvg_rust_render_markers (ctx: *mut RsvgDrawingCtx,
raw_builder: *mut RsvgPathBuilder,
- linewidth: f64,
startmarker: *const libc::c_char,
middlemarker: *const libc::c_char,
endmarker: *const libc::c_char) {
+ let linewidth: f64 = unsafe { rsvg_get_normalized_stroke_width (ctx) };
+
if linewidth == 0.0 {
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]