[librsvg: 3/6] Fold cairo-clip.c into cairo-draw.c
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 3/6] Fold cairo-clip.c into cairo-draw.c
- Date: Sat, 28 Apr 2018 16:19:46 +0000 (UTC)
commit 2a5d538ec85f5d93204fdfe6da4762f317b5e006
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Apr 28 13:14:28 2018 +0200
Fold cairo-clip.c into cairo-draw.c
No reason to keep this in a separate file
Makefile.am | 2 -
librsvg/rsvg-cairo-clip.c | 109 ----------------------------------------------
librsvg/rsvg-cairo-clip.h | 42 ------------------
librsvg/rsvg-cairo-draw.c | 71 +++++++++++++++++++++++++++++-
4 files changed, 70 insertions(+), 154 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index f317dd44..fc92b92e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -47,8 +47,6 @@ librsvg_@RSVG_API_MAJOR_VERSION@_la_SOURCES = \
librsvg/rsvg-attributes.h \
librsvg/rsvg-base-file-util.c \
librsvg/rsvg-base.c \
- librsvg/rsvg-cairo-clip.c \
- librsvg/rsvg-cairo-clip.h \
librsvg/rsvg-cairo-draw.c \
librsvg/rsvg-cairo-draw.h \
librsvg/rsvg-cairo-render.c \
diff --git a/librsvg/rsvg-cairo-draw.c b/librsvg/rsvg-cairo-draw.c
index 03be5c7a..b0d512a9 100644
--- a/librsvg/rsvg-cairo-draw.c
+++ b/librsvg/rsvg-cairo-draw.c
@@ -31,9 +31,9 @@
#include "rsvg-cairo-draw.h"
#include "rsvg-cairo-render.h"
-#include "rsvg-cairo-clip.h"
#include "rsvg-styles.h"
#include "rsvg-filter.h"
+#include "rsvg-mask.h"
#include "rsvg-structure.h"
#include <math.h>
@@ -320,6 +320,75 @@ rsvg_cairo_generate_mask (cairo_t * cr, RsvgNode *mask, RsvgDrawingCtx *ctx, Rsv
cairo_surface_destroy (surface);
}
+static void
+rsvg_cairo_clip (RsvgDrawingCtx *ctx, RsvgNode *node_clip_path, RsvgBbox *bbox)
+{
+ RsvgCairoRender *save = RSVG_CAIRO_RENDER (ctx->render);
+ cairo_matrix_t affinesave;
+ RsvgState *clip_path_state;
+ cairo_t *cr;
+ RsvgCoordUnits clip_units;
+ GList *orig_cr_stack;
+ GList *orig_bb_stack;
+ GList *orig_ink_bb_stack;
+ GList *orig_surfaces_stack;
+ RsvgBbox orig_bbox;
+ RsvgBbox orig_ink_bbox;
+
+ g_assert (rsvg_node_get_type (node_clip_path) == RSVG_NODE_TYPE_CLIP_PATH);
+ clip_units = rsvg_node_clip_path_get_units (node_clip_path);
+
+ cr = save->cr;
+
+ clip_path_state = rsvg_node_get_state (node_clip_path);
+
+ /* Horribly dirty hack to have the bbox premultiplied to everything */
+ if (clip_units == objectBoundingBox) {
+ cairo_matrix_t bbtransform;
+ cairo_matrix_init (&bbtransform,
+ bbox->rect.width,
+ 0,
+ 0,
+ bbox->rect.height,
+ bbox->rect.x,
+ bbox->rect.y);
+ affinesave = rsvg_state_get_affine (clip_path_state);
+ cairo_matrix_multiply (&bbtransform, &bbtransform, &affinesave);
+ rsvg_state_set_affine (clip_path_state, bbtransform);
+ }
+
+ orig_cr_stack = save->cr_stack;
+ orig_bb_stack = save->bb_stack;
+ orig_ink_bb_stack = save->ink_bb_stack;
+ orig_surfaces_stack = save->surfaces_stack;
+
+ orig_bbox = save->bbox;
+ orig_ink_bbox = save->ink_bbox;
+
+ rsvg_drawing_ctx_state_push (ctx);
+ rsvg_node_draw_children (node_clip_path, ctx, 0, TRUE);
+ rsvg_drawing_ctx_state_pop (ctx);
+
+ if (clip_units == objectBoundingBox) {
+ rsvg_state_set_affine (clip_path_state, affinesave);
+ }
+
+ g_assert (save->cr_stack == orig_cr_stack);
+ g_assert (save->bb_stack == orig_bb_stack);
+ g_assert (save->ink_bb_stack == orig_ink_bb_stack);
+ g_assert (save->surfaces_stack == orig_surfaces_stack);
+
+ /* FIXME: this is an EPIC HACK to keep the clipping context from
+ * accumulating bounding boxes. We'll remove this later, when we
+ * are able to extract bounding boxes from outside the
+ * general drawing loop.
+ */
+ save->bbox = orig_bbox;
+ save->ink_bbox = orig_ink_bbox;
+
+ cairo_clip (cr);
+}
+
static void
rsvg_cairo_push_render_stack (RsvgDrawingCtx * ctx)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]