[librsvg] RsvgMask: make private; provide accessor functions
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] RsvgMask: make private; provide accessor functions
- Date: Tue, 5 Dec 2017 03:01:04 +0000 (UTC)
commit d0b7a3779f42271b02f394fe0f4016c349df4db0
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Dec 4 20:01:49 2017 -0600
RsvgMask: make private; provide accessor functions
rsvg-cairo-draw.c | 29 ++++++++++++++++++++---------
rsvg-mask.c | 42 ++++++++++++++++++++++++++++++++++++++++++
rsvg-mask.h | 25 ++++++++++++++++++-------
3 files changed, 80 insertions(+), 16 deletions(-)
---
diff --git a/rsvg-cairo-draw.c b/rsvg-cairo-draw.c
index 4170e2c..624b50e 100644
--- a/rsvg-cairo-draw.c
+++ b/rsvg-cairo-draw.c
@@ -528,9 +528,12 @@ rsvg_cairo_generate_mask (cairo_t * cr, RsvgNode *node_mask, RsvgDrawingCtx *ctx
guint32 width = render->width, height = render->height;
guint32 rowstride = width * 4, row, i;
cairo_matrix_t affinesave;
+ RsvgLength mask_x, mask_y, mask_w, mask_h;
double sx, sy, sw, sh;
gboolean nest = cr != render->initial_cr;
RsvgMask *mask;
+ RsvgCoordUnits mask_units;
+ RsvgCoordUnits content_units;
g_assert (rsvg_node_get_type (node_mask) == RSVG_NODE_TYPE_MASK);
mask = rsvg_rust_cnode_get_impl (node_mask);
@@ -544,22 +547,30 @@ rsvg_cairo_generate_mask (cairo_t * cr, RsvgNode *node_mask, RsvgDrawingCtx *ctx
pixels = cairo_image_surface_get_data (surface);
rowstride = cairo_image_surface_get_stride (surface);
- if (mask->maskunits == objectBoundingBox)
+ mask_units = rsvg_node_mask_get_units (mask);
+ content_units = rsvg_node_mask_get_content_units (mask);
+
+ if (mask_units == objectBoundingBox)
rsvg_drawing_ctx_push_view_box (ctx, 1, 1);
- sx = rsvg_length_normalize (&mask->x, ctx);
- sy = rsvg_length_normalize (&mask->y, ctx);
- sw = rsvg_length_normalize (&mask->width, ctx);
- sh = rsvg_length_normalize (&mask->height, ctx);
+ mask_x = rsvg_node_mask_get_x (mask);
+ mask_y = rsvg_node_mask_get_y (mask);
+ mask_w = rsvg_node_mask_get_width (mask);
+ mask_h = rsvg_node_mask_get_height (mask);
+
+ sx = rsvg_length_normalize (&mask_x, ctx);
+ sy = rsvg_length_normalize (&mask_y, ctx);
+ sw = rsvg_length_normalize (&mask_w, ctx);
+ sh = rsvg_length_normalize (&mask_h, ctx);
- if (mask->maskunits == objectBoundingBox)
+ if (mask_units == objectBoundingBox)
rsvg_drawing_ctx_pop_view_box (ctx);
mask_cr = cairo_create (surface);
save_cr = render->cr;
render->cr = mask_cr;
- if (mask->maskunits == objectBoundingBox)
+ if (mask_units == objectBoundingBox)
rsvg_cairo_add_clipping_rect (ctx,
sx * bbox->rect.width + bbox->rect.x,
sy * bbox->rect.height + bbox->rect.y,
@@ -569,7 +580,7 @@ rsvg_cairo_generate_mask (cairo_t * cr, RsvgNode *node_mask, RsvgDrawingCtx *ctx
rsvg_cairo_add_clipping_rect (ctx, sx, sy, sw, sh);
/* Horribly dirty hack to have the bbox premultiplied to everything */
- if (mask->contentunits == objectBoundingBox) {
+ if (content_units == objectBoundingBox) {
cairo_matrix_t bbtransform;
RsvgState *mask_state;
@@ -592,7 +603,7 @@ rsvg_cairo_generate_mask (cairo_t * cr, RsvgNode *node_mask, RsvgDrawingCtx *ctx
rsvg_node_draw_children (node_mask, ctx, 0);
rsvg_state_pop (ctx);
- if (mask->contentunits == objectBoundingBox) {
+ if (content_units == objectBoundingBox) {
RsvgState *mask_state;
rsvg_drawing_ctx_pop_view_box (ctx);
diff --git a/rsvg-mask.c b/rsvg-mask.c
index dfb772e..d9f4b30 100644
--- a/rsvg-mask.c
+++ b/rsvg-mask.c
@@ -29,6 +29,12 @@
#include "rsvg-css.h"
#include <string.h>
+struct _RsvgMask {
+ RsvgLength x, y, width, height;
+ RsvgMaskUnits maskunits;
+ RsvgMaskUnits contentunits;
+};
+
static void
rsvg_mask_set_atts (RsvgNode *node, gpointer impl, RsvgHandle *handle, RsvgPropertyBag *atts)
{
@@ -84,3 +90,39 @@ rsvg_new_mask (const char *element_name, RsvgNode *parent)
rsvg_mask_draw,
g_free);
}
+
+RsvgLength
+rsvg_node_mask_get_x (RsvgMask *mask)
+{
+ return mask->x;
+}
+
+RsvgLength
+rsvg_node_mask_get_y (RsvgMask *mask)
+{
+ return mask->y;
+}
+
+RsvgLength
+rsvg_node_mask_get_width (RsvgMask *mask)
+{
+ return mask->width;
+}
+
+RsvgLength
+rsvg_node_mask_get_height (RsvgMask *mask)
+{
+ return mask->height;
+}
+
+RsvgCoordUnits
+rsvg_node_mask_get_units (RsvgMask *mask)
+{
+ return mask->maskunits;
+}
+
+RsvgCoordUnits
+rsvg_node_mask_get_content_units (RsvgMask *mask)
+{
+ return mask->contentunits;
+}
diff --git a/rsvg-mask.h b/rsvg-mask.h
index e9f5a45..29fab06 100644
--- a/rsvg-mask.h
+++ b/rsvg-mask.h
@@ -35,19 +35,30 @@
G_BEGIN_DECLS
-typedef RsvgCoordUnits RsvgMaskUnits;
typedef struct _RsvgMask RsvgMask;
-struct _RsvgMask {
- RsvgLength x, y, width, height;
- RsvgMaskUnits maskunits;
- RsvgMaskUnits contentunits;
-};
-
G_GNUC_INTERNAL
RsvgNode *rsvg_new_mask (const char *element_name, RsvgNode *node);
+G_GNUC_INTERNAL
+RsvgLength rsvg_node_mask_get_x (RsvgMask *mask);
+
+G_GNUC_INTERNAL
+RsvgLength rsvg_node_mask_get_y (RsvgMask *mask);
+
+G_GNUC_INTERNAL
+RsvgLength rsvg_node_mask_get_width (RsvgMask *mask);
+
+G_GNUC_INTERNAL
+RsvgLength rsvg_node_mask_get_height (RsvgMask *mask);
+
+G_GNUC_INTERNAL
+RsvgCoordUnits rsvg_node_mask_get_units (RsvgMask *mask);
+
+G_GNUC_INTERNAL
+RsvgCoordUnits rsvg_node_mask_get_content_units (RsvgMask *mask);
+
/* Implemented in rust/src/clip_path.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_clip_path_new (const char *element_name, RsvgNode *node);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]