summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-01 02:09:01 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-01 02:09:01 +0200
commit9c9674b3081bfd433460be934e2a792390474367 (patch)
treecf939985e2d7fd1f7b42fe30b232dcd035c9c026
parente1101a5de25079fa42ac03e5abea48b0f382ec4e (diff)
downloadmupdf-9c9674b3081bfd433460be934e2a792390474367.tar.xz
xps: fix clip/popclip nesting
-rw-r--r--xps/xpscolor.c26
-rw-r--r--xps/xpscommon.c5
-rw-r--r--xps/xpsglyphs.c7
-rw-r--r--xps/xpsgradient.c10
-rw-r--r--xps/xpspath.c23
-rw-r--r--xps/xpstile.c4
6 files changed, 18 insertions, 57 deletions
diff --git a/xps/xpscolor.c b/xps/xpscolor.c
index bb2f225f..b0678603 100644
--- a/xps/xpscolor.c
+++ b/xps/xpscolor.c
@@ -199,29 +199,3 @@ xps_read_icc_colorspace(xps_context *ctx, char *base_uri, char *profilename)
return NULL;
#endif
}
-
-void
-xps_parse_solid_color_brush(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *dict, xps_item *node)
-{
- char *opacity_att;
- char *color_att;
- fz_colorspace *colorspace;
- float samples[32];
-
- color_att = xps_att(node, "Color");
- opacity_att = xps_att(node, "Opacity");
-
- colorspace = fz_devicergb;
- samples[0] = 1.0;
- samples[1] = 0.0;
- samples[2] = 0.0;
- samples[3] = 0.0;
-
- if (color_att)
- xps_parse_color(ctx, base_uri, color_att, &colorspace, samples);
- if (opacity_att)
- samples[0] = atof(opacity_att);
-
- xps_set_color(ctx, colorspace, samples);
- xps_fill(ctx, ctm);
-}
diff --git a/xps/xpscommon.c b/xps/xpscommon.c
index 2d46caa4..d338ffaa 100644
--- a/xps/xpscommon.c
+++ b/xps/xpscommon.c
@@ -4,9 +4,8 @@
void
xps_parse_brush(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *dict, xps_item *node)
{
- if (!strcmp(xps_tag(node), "SolidColorBrush"))
- xps_parse_solid_color_brush(ctx, ctm, base_uri, dict, node);
- else if (!strcmp(xps_tag(node), "ImageBrush"))
+ /* SolidColorBrushes are handled in a special case and will never show up here */
+ if (!strcmp(xps_tag(node), "ImageBrush"))
xps_parse_image_brush(ctx, ctm, base_uri, dict, node);
else if (!strcmp(xps_tag(node), "VisualBrush"))
xps_parse_visual_brush(ctx, ctm, base_uri, dict, node);
diff --git a/xps/xpsglyphs.c b/xps/xpsglyphs.c
index d30f016b..372cf222 100644
--- a/xps/xpsglyphs.c
+++ b/xps/xpsglyphs.c
@@ -497,7 +497,14 @@ xps_parse_glyphs(xps_context *ctx, fz_matrix ctm,
xps_parse_glyphs_imp(ctx, ctm, font, font_size,
atof(origin_x_att), atof(origin_y_att),
is_sideways, bidi_level, indices_att, unicode_att, 1);
+
+ ctx->dev->cliptext(ctx->dev->user, ctx->text, ctm, 0);
+ fz_freetext(ctx->text);
+ ctx->text = nil;
+
xps_parse_brush(ctx, ctm, fill_uri, dict, fill_tag);
+
+ ctx->dev->popclip(ctx->dev->user);
}
xps_end_opacity(ctx, opacity_mask_uri, dict, opacity_att, opacity_mask_tag);
diff --git a/xps/xpsgradient.c b/xps/xpsgradient.c
index 5104ef1f..c1b45e93 100644
--- a/xps/xpsgradient.c
+++ b/xps/xpsgradient.c
@@ -338,7 +338,7 @@ xps_draw_radial_gradient(xps_context *ctx, fz_matrix ctm,
dx = x1 - x0;
dy = y1 - y0;
- xps_draw_one_radial_gradient(ctx, ctm, stops, count, 0, x0, y0, r0, x1, y1, r1);
+ xps_draw_one_radial_gradient(ctx, ctm, stops, count, 1, x0, y0, r0, x1, y1, r1);
#if 0
xps_bounds_in_user_space(ctx, &bbox);
@@ -461,7 +461,7 @@ xps_draw_linear_gradient(xps_context *ctx, fz_matrix ctm,
dx = x1 - x0;
dy = y1 - y0;
- xps_draw_one_linear_gradient(ctx, ctm, stops, count, 0, x0, y0, x1, y1);
+ xps_draw_one_linear_gradient(ctx, ctm, stops, count, 1, x0, y0, x1, y1);
#if 0
xps_bounds_in_user_space(ctx, &bbox);
@@ -572,8 +572,6 @@ xps_parse_gradient_brush(xps_context *ctx, fz_matrix ctm,
spread_method = SPREAD_REPEAT;
}
- xps_clip(ctx, ctm);
-
transform = fz_identity;
if (transform_att)
xps_parse_render_transform(ctx, transform_att, &transform);
@@ -606,16 +604,12 @@ void
xps_parse_linear_gradient_brush(xps_context *ctx, fz_matrix ctm,
char *base_uri, xps_resource *dict, xps_item *root)
{
- xps_clip(ctx, ctm);
xps_parse_gradient_brush(ctx, ctm, base_uri, dict, root, xps_draw_linear_gradient);
- ctx->dev->popclip(ctx->dev->user);
}
void
xps_parse_radial_gradient_brush(xps_context *ctx, fz_matrix ctm,
char *base_uri, xps_resource *dict, xps_item *root)
{
- xps_clip(ctx, ctm);
xps_parse_gradient_brush(ctx, ctm, base_uri, dict, root, xps_draw_radial_gradient);
- ctx->dev->popclip(ctx->dev->user);
}
diff --git a/xps/xpspath.c b/xps/xpspath.c
index 86d37197..d442698d 100644
--- a/xps/xpspath.c
+++ b/xps/xpspath.c
@@ -38,22 +38,9 @@ fz_currentpoint(fz_path *path)
void
xps_clip(xps_context *ctx, fz_matrix ctm)
{
- if (ctx->path)
- {
- ctx->dev->clippath(ctx->dev->user, ctx->path, ctx->fill_rule == 0, ctm);
- fz_freepath(ctx->path);
- ctx->path = NULL;
- }
- else if (ctx->text)
- {
- ctx->dev->cliptext(ctx->dev->user, ctx->text, ctm, 0);
- fz_freetext(ctx->text);
- ctx->text = nil;
- }
- else
- {
- fz_warn("clip not a path nor text");
- }
+ ctx->dev->clippath(ctx->dev->user, ctx->path, ctx->fill_rule == 0, ctm);
+ fz_freepath(ctx->path);
+ ctx->path = NULL;
}
void
@@ -984,7 +971,11 @@ xps_parse_path(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *di
if (data_tag)
xps_parse_path_geometry(ctx, dict, data_tag, 0);
+ xps_clip(ctx, ctm);
+
xps_parse_brush(ctx, ctm, fill_uri, dict, fill_tag);
+
+ ctx->dev->popclip(ctx->dev->user);
}
if (stroke_att)
diff --git a/xps/xpstile.c b/xps/xpstile.c
index db6e6655..baa274e6 100644
--- a/xps/xpstile.c
+++ b/xps/xpstile.c
@@ -148,8 +148,6 @@ xps_parse_tiling_brush(xps_context *ctx, fz_matrix ctm,
tile_mode = TILE_FLIP_X_Y;
}
- xps_clip(ctx, ctm);
-
xps_begin_opacity(ctx, ctm, base_uri, dict, opacity_att, NULL);
ctm = fz_concat(transform, ctm);
@@ -180,6 +178,4 @@ xps_parse_tiling_brush(xps_context *ctx, fz_matrix ctm,
}
xps_end_opacity(ctx, base_uri, dict, opacity_att, NULL);
-
- ctx->dev->popclip(ctx->dev->user);
}