summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/fitz/bbox-device.c9
-rw-r--r--source/fitz/device.c43
-rw-r--r--source/fitz/draw-device.c67
-rw-r--r--source/fitz/list-device.c23
-rw-r--r--source/fitz/stext-device.c2
-rw-r--r--source/fitz/svg-device.c2
-rw-r--r--source/fitz/trace-device.c2
-rw-r--r--source/pdf/pdf-device.c2
-rw-r--r--source/pdf/pdf-op-run.c13
-rw-r--r--source/xps/xps-glyphs.c2
10 files changed, 44 insertions, 121 deletions
diff --git a/source/fitz/bbox-device.c b/source/fitz/bbox-device.c
index 2c639499..fcab733f 100644
--- a/source/fitz/bbox-device.c
+++ b/source/fitz/bbox-device.c
@@ -102,13 +102,10 @@ fz_bbox_clip_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, const f
}
static void
-fz_bbox_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, int accumulate)
+fz_bbox_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
{
- fz_rect r = fz_infinite_rect;
- if (accumulate)
- fz_bbox_add_rect(ctx, dev, &r, accumulate != 2);
- else
- fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, NULL, ctm, &r), 1);
+ fz_rect r;
+ fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, NULL, ctm, &r), 1);
}
static void
diff --git a/source/fitz/device.c b/source/fitz/device.c
index 6df650f4..cd3435c9 100644
--- a/source/fitz/device.c
+++ b/source/fitz/device.c
@@ -67,38 +67,6 @@ push_clip_stack(fz_context *ctx, fz_device *dev, const fz_rect *rect, int flags)
}
static void
-push_clip_stack_accumulate(fz_context *ctx, fz_device *dev, const fz_rect *rect, int accumulate)
-{
- if (accumulate <= 1)
- {
- dev->scissor_accumulator = *rect;
- if (dev->container_len == dev->container_cap)
- {
- int newmax = dev->container_cap * 2;
- if (newmax == 0)
- newmax = 4;
- dev->container = fz_resize_array(ctx, dev->container, newmax, sizeof(*dev->container));
- dev->container_cap = newmax;
- }
- if (dev->container_len > 0)
- dev->container[dev->container_len].scissor = dev->container[dev->container_len-1].scissor;
- else
- dev->container[dev->container_len].scissor = fz_infinite_rect;
- fz_intersect_rect(&dev->container[dev->container_len].scissor, rect);
- dev->container[dev->container_len].flags = fz_device_container_stack_is_clip_text;
- dev->container[dev->container_len].user = 0;
- dev->container_len++;
- }
- else
- {
- if (dev->container_len <= 0)
- return;
- fz_union_rect(&dev->scissor_accumulator, rect);
- fz_intersect_rect(&dev->container[dev->container_len-1].scissor, &dev->scissor_accumulator);
- }
-}
-
-static void
pop_clip_stack(fz_context *ctx, fz_device *dev)
{
if (dev->container_len > 0)
@@ -212,12 +180,11 @@ fz_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *
}
void
-fz_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, int accumulate)
+fz_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
{
if (dev->error_depth)
{
- if (accumulate == 0 || accumulate == 1)
- dev->error_depth++;
+ dev->error_depth++;
return;
}
@@ -227,15 +194,13 @@ fz_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ct
{
fz_rect bbox;
fz_bound_text(ctx, text, NULL, ctm, &bbox);
- push_clip_stack_accumulate(ctx, dev, &bbox, accumulate);
+ push_clip_stack(ctx, dev, &bbox, fz_device_container_stack_is_clip_text);
}
if (dev->clip_text)
- dev->clip_text(ctx, dev, text, ctm, accumulate);
+ dev->clip_text(ctx, dev, text, ctm);
}
fz_catch(ctx)
{
- if (accumulate == 2)
- fz_rethrow(ctx);
dev->error_depth = 1;
strcpy(dev->errmess, fz_caught_message(ctx));
/* Error swallowed */
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index ab6ebbe7..065daaa9 100644
--- a/source/fitz/draw-device.c
+++ b/source/fitz/draw-device.c
@@ -708,7 +708,7 @@ fz_draw_stroke_text(fz_context *ctx, fz_device *devp, fz_text *text, fz_stroke_s
}
static void
-fz_draw_clip_text(fz_context *ctx, fz_device *devp, fz_text *text, const fz_matrix *ctm, int accumulate)
+fz_draw_clip_text(fz_context *ctx, fz_device *devp, fz_text *text, const fz_matrix *ctm)
{
fz_draw_device *dev = (fz_draw_device*)devp;
fz_irect bbox;
@@ -719,60 +719,38 @@ fz_draw_clip_text(fz_context *ctx, fz_device *devp, fz_text *text, const fz_matr
fz_draw_state *state;
fz_colorspace *model;
fz_text_span *span;
-
- /* If accumulate == 0 then this text object is guaranteed complete */
- /* If accumulate == 1 then this text object is the first (or only) in a sequence */
- /* If accumulate == 2 then this text object is a continuation */
+ fz_rect rect;
state = push_stack(ctx, dev);
STACK_PUSHED("clip text");
model = state->dest->colorspace;
- if (accumulate == 0)
- {
- /* make the mask the exact size needed */
- fz_rect rect;
-
- fz_irect_from_rect(&bbox, fz_bound_text(ctx, text, NULL, ctm, &rect));
- fz_intersect_irect(&bbox, &state->scissor);
- }
- else
- {
- /* be conservative about the size of the mask needed */
- bbox = state->scissor;
- }
+ /* make the mask the exact size needed */
+ fz_irect_from_rect(&bbox, fz_bound_text(ctx, text, NULL, ctm, &rect));
+ fz_intersect_irect(&bbox, &state->scissor);
fz_try(ctx)
{
- if (accumulate == 0 || accumulate == 1)
+ mask = fz_new_pixmap_with_bbox(ctx, NULL, &bbox);
+ fz_clear_pixmap(ctx, mask);
+ dest = fz_new_pixmap_with_bbox(ctx, model, &bbox);
+ fz_clear_pixmap(ctx, dest);
+ if (state->shape)
{
- mask = fz_new_pixmap_with_bbox(ctx, NULL, &bbox);
- fz_clear_pixmap(ctx, mask);
- dest = fz_new_pixmap_with_bbox(ctx, model, &bbox);
- fz_clear_pixmap(ctx, dest);
- if (state->shape)
- {
- shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox);
- fz_clear_pixmap(ctx, shape);
- }
- else
- shape = NULL;
+ shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox);
+ fz_clear_pixmap(ctx, shape);
+ }
+ else
+ shape = NULL;
- state[1].blendmode |= FZ_BLEND_ISOLATED;
- state[1].scissor = bbox;
- state[1].dest = dest;
- state[1].mask = mask;
- state[1].shape = shape;
+ state[1].blendmode |= FZ_BLEND_ISOLATED;
+ state[1].scissor = bbox;
+ state[1].dest = dest;
+ state[1].mask = mask;
+ state[1].shape = shape;
#ifdef DUMP_GROUP_BLENDS
- dump_spaces(dev->top-1, "Clip (text) begin\n");
+ dump_spaces(dev->top-1, "Clip (text) begin\n");
#endif
- }
- else
- {
- mask = state->mask;
- dev->top--;
- STACK_POPPED("clip text");
- }
if (!fz_is_empty_irect(&bbox) && mask)
{
@@ -837,8 +815,7 @@ fz_draw_clip_text(fz_context *ctx, fz_device *devp, fz_text *text, const fz_matr
}
fz_catch(ctx)
{
- if (accumulate == 0 || accumulate == 1)
- emergency_pop_stack(ctx, dev, state);
+ emergency_pop_stack(ctx, dev, state);
fz_rethrow(ctx);
}
}
diff --git a/source/fitz/list-device.c b/source/fitz/list-device.c
index ea61b3d2..14e2278c 100644
--- a/source/fitz/list-device.c
+++ b/source/fitz/list-device.c
@@ -194,12 +194,8 @@ fz_append_display_node(
}
writer->top++;
break;
- case FZ_CMD_CLIP_TEXT:
- /* don't reset the clip rect for accumulated text */
- if (flags == 2)
- break;
- /* fallthrough */
case FZ_CMD_END_MASK:
+ case FZ_CMD_CLIP_TEXT:
case FZ_CMD_CLIP_STROKE_TEXT:
if (writer->top < STACK_SIZE)
{
@@ -840,22 +836,19 @@ fz_list_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_st
}
static void
-fz_list_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, int accumulate)
+fz_list_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
{
fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
fz_try(ctx)
{
- if (accumulate)
- rect = fz_infinite_rect;
- else
- fz_bound_text(ctx, text, NULL, ctm, &rect);
+ fz_bound_text(ctx, text, NULL, ctm, &rect);
fz_append_display_node(
ctx,
dev,
FZ_CMD_CLIP_TEXT,
- accumulate, /* flags */
+ 0, /* flags */
&rect,
NULL, /* path */
NULL, /* color */
@@ -1636,17 +1629,13 @@ fz_run_display_list(fz_context *ctx, fz_display_list *list, fz_device *dev, cons
{
case FZ_CMD_CLIP_PATH:
case FZ_CMD_CLIP_STROKE_PATH:
+ case FZ_CMD_CLIP_TEXT:
case FZ_CMD_CLIP_STROKE_TEXT:
case FZ_CMD_CLIP_IMAGE_MASK:
case FZ_CMD_BEGIN_MASK:
case FZ_CMD_BEGIN_GROUP:
clipped++;
continue;
- case FZ_CMD_CLIP_TEXT:
- /* Accumulated text has no extra pops */
- if (n.flags != 2)
- clipped++;
- continue;
case FZ_CMD_POP_CLIP:
case FZ_CMD_END_GROUP:
if (!clipped)
@@ -1694,7 +1683,7 @@ visible:
fz_stroke_text(ctx, dev, *(fz_text **)node, stroke, &trans_ctm, colorspace, color, alpha);
break;
case FZ_CMD_CLIP_TEXT:
- fz_clip_text(ctx, dev, *(fz_text **)node, &trans_ctm, n.flags);
+ fz_clip_text(ctx, dev, *(fz_text **)node, &trans_ctm);
break;
case FZ_CMD_CLIP_STROKE_TEXT:
fz_clip_stroke_text(ctx, dev, *(fz_text **)node, stroke, &trans_ctm);
diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c
index 060311d3..a9dadc9b 100644
--- a/source/fitz/stext-device.c
+++ b/source/fitz/stext-device.c
@@ -854,7 +854,7 @@ fz_stext_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_s
}
static void
-fz_stext_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, int accumulate)
+fz_stext_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
{
fz_stext_device *tdev = (fz_stext_device*)dev;
fz_stext_style *style;
diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c
index a2cc5ed1..879b3bd0 100644
--- a/source/fitz/svg-device.c
+++ b/source/fitz/svg-device.c
@@ -603,7 +603,7 @@ svg_dev_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_st
}
static void
-svg_dev_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, int accumulate)
+svg_dev_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
diff --git a/source/fitz/trace-device.c b/source/fitz/trace-device.c
index df2f6455..1f972642 100644
--- a/source/fitz/trace-device.c
+++ b/source/fitz/trace-device.c
@@ -218,7 +218,7 @@ fz_trace_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_s
}
static void
-fz_trace_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, int accumulate)
+fz_trace_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<clip_text");
diff --git a/source/pdf/pdf-device.c b/source/pdf/pdf-device.c
index a2ee1295..dce26a3a 100644
--- a/source/pdf/pdf-device.c
+++ b/source/pdf/pdf-device.c
@@ -980,7 +980,7 @@ pdf_dev_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_st
}
static void
-pdf_dev_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, int accumulate)
+pdf_dev_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
{
pdf_device *pdev = (pdf_device*)dev;
fz_text_span *span;
diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c
index ea2384be..f18b593d 100644
--- a/source/pdf/pdf-op-run.c
+++ b/source/pdf/pdf-op-run.c
@@ -85,7 +85,6 @@ struct pdf_run_processor_s
fz_matrix tlm;
fz_matrix tm;
int text_mode;
- int accumulate;
/* graphics state */
pdf_gstate *gstate;
@@ -794,7 +793,7 @@ pdf_flush_text(fz_context *ctx, pdf_run_processor *pr)
case PDF_MAT_PATTERN:
if (gstate->fill.pattern)
{
- fz_clip_text(ctx, pr->dev, text, &gstate->ctm, 0);
+ fz_clip_text(ctx, pr->dev, text, &gstate->ctm);
pdf_show_pattern(ctx, pr, gstate->fill.pattern, &pr->gstate[gstate->fill.gstate_num], &tb, PDF_FILL);
fz_pop_clip(ctx, pr->dev);
}
@@ -802,7 +801,7 @@ pdf_flush_text(fz_context *ctx, pdf_run_processor *pr)
case PDF_MAT_SHADE:
if (gstate->fill.shade)
{
- fz_clip_text(ctx, pr->dev, text, &gstate->ctm, 0);
+ fz_clip_text(ctx, pr->dev, text, &gstate->ctm);
/* Page 2 of patterns.pdf shows that fz_fill_shade should NOT be called with gstate->ctm */
fz_fill_shade(ctx, pr->dev, gstate->fill.shade, &pr->gstate[gstate->fill.gstate_num].ctm, gstate->fill.alpha);
fz_pop_clip(ctx, pr->dev);
@@ -848,10 +847,8 @@ pdf_flush_text(fz_context *ctx, pdf_run_processor *pr)
if (doclip)
{
- if (pr->accumulate < 2)
- gstate->clip_depth++;
- fz_clip_text(ctx, pr->dev, text, &gstate->ctm, pr->accumulate);
- pr->accumulate = 2;
+ gstate->clip_depth++;
+ fz_clip_text(ctx, pr->dev, text, &gstate->ctm);
}
}
fz_always(ctx)
@@ -1626,7 +1623,6 @@ static void pdf_run_ET(fz_context *ctx, pdf_processor *proc)
{
pdf_run_processor *pr = (pdf_run_processor *)proc;
pdf_flush_text(ctx, pr);
- pr->accumulate = 1;
}
/* text state */
@@ -2126,7 +2122,6 @@ pdf_new_run_processor(fz_context *ctx, fz_device *dev, const fz_matrix *ctm, con
proc->tlm = fz_identity;
proc->tm = fz_identity;
proc->text_mode = 0;
- proc->accumulate = 1;
fz_try(ctx)
{
diff --git a/source/xps/xps-glyphs.c b/source/xps/xps-glyphs.c
index 4434c4ed..8cfbbafc 100644
--- a/source/xps/xps-glyphs.c
+++ b/source/xps/xps-glyphs.c
@@ -612,7 +612,7 @@ xps_parse_glyphs(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
if (fill_tag)
{
- fz_clip_text(ctx, dev, text, &local_ctm, 0);
+ fz_clip_text(ctx, dev, text, &local_ctm);
xps_parse_brush(ctx, doc, &local_ctm, &area, fill_uri, dict, fill_tag);
fz_pop_clip(ctx, dev);
}