summaryrefslogtreecommitdiff
path: root/xps/xpstile.c
diff options
context:
space:
mode:
Diffstat (limited to 'xps/xpstile.c')
-rw-r--r--xps/xpstile.c172
1 files changed, 36 insertions, 136 deletions
diff --git a/xps/xpstile.c b/xps/xpstile.c
index d7118b52..4f2f57ec 100644
--- a/xps/xpstile.c
+++ b/xps/xpstile.c
@@ -1,19 +1,5 @@
-/* Copyright (C) 2006-2010 Artifex Software, Inc.
- All Rights Reserved.
-
- This software is provided AS-IS with no warranty, either express or
- implied.
-
- This software is distributed under license and may not be copied, modified
- or distributed except as expressly authorized under the terms of that
- license. Refer to licensing information at http://www.artifex.com/
- or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
- San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
-*/
-
-/* XPS interpreter - tiles for pattern rendering */
-
-#include "ghostxps.h"
+#include "fitz.h"
+#include "muxps.h"
/*
* Parse a tiling brush (visual and image brushes at this time) common
@@ -28,7 +14,7 @@ struct tile_closure_s
char *base_uri;
xps_resource_t *dict;
xps_item_t *tag;
- gs_rect viewbox;
+ fz_rect viewbox;
int tile_mode;
void *user;
int (*func)(xps_context_t*, char*, xps_resource_t*, xps_item_t*, void*);
@@ -40,6 +26,7 @@ xps_paint_tiling_brush_clipped(struct tile_closure_s *c)
xps_context_t *ctx = c->ctx;
int code;
+#if 0
gs_moveto(ctx->pgs, c->viewbox.p.x, c->viewbox.p.y);
gs_lineto(ctx->pgs, c->viewbox.p.x, c->viewbox.q.y);
gs_lineto(ctx->pgs, c->viewbox.q.x, c->viewbox.q.y);
@@ -47,14 +34,16 @@ xps_paint_tiling_brush_clipped(struct tile_closure_s *c)
gs_closepath(ctx->pgs);
gs_clip(ctx->pgs);
gs_newpath(ctx->pgs);
+#endif
code = c->func(c->ctx, c->base_uri, c->dict, c->tag, c->user);
if (code < 0)
- return gs_rethrow(code, "cannot draw clipped tile");
+ return fz_rethrow(code, "cannot draw clipped tile");
return 0;
}
+#if 0
static int
xps_paint_tiling_brush(const gs_client_color *pcc, gs_state *pgs)
{
@@ -113,103 +102,14 @@ xps_paint_tiling_brush(const gs_client_color *pcc, gs_state *pgs)
cleanup:
gs_grestore(ctx->pgs);
ctx->pgs = saved_pgs;
- return gs_rethrow(code, "cannot draw tile");
-}
-
-int
-xps_high_level_pattern(xps_context_t *ctx)
-{
- gs_matrix m;
- gs_rect bbox;
- gs_fixed_rect clip_box;
- int code;
- gx_device_color *pdc = gs_currentdevicecolor_inline(ctx->pgs);
- const gs_client_pattern *ppat = gs_getpattern(&pdc->ccolor);
- gs_pattern1_instance_t *pinst =
- (gs_pattern1_instance_t *)gs_currentcolor(ctx->pgs)->pattern;
-
- code = gx_pattern_cache_add_dummy_entry((gs_imager_state *)ctx->pgs,
- pinst, ctx->pgs->device->color_info.depth);
- if (code < 0)
- return code;
-
- code = gs_gsave(ctx->pgs);
- if (code < 0)
- return code;
-
- dev_proc(ctx->pgs->device, get_initial_matrix)(ctx->pgs->device, &m);
- gs_setmatrix(ctx->pgs, &m);
- code = gs_bbox_transform(&ppat->BBox, &ctm_only(ctx->pgs), &bbox);
- if (code < 0) {
- gs_grestore(ctx->pgs);
- return code;
- }
- clip_box.p.x = float2fixed(bbox.p.x);
- clip_box.p.y = float2fixed(bbox.p.y);
- clip_box.q.x = float2fixed(bbox.q.x);
- clip_box.q.y = float2fixed(bbox.q.y);
- code = gx_clip_to_rectangle(ctx->pgs, &clip_box);
- if (code < 0) {
- gs_grestore(ctx->pgs);
- return code;
- }
- code = dev_proc(ctx->pgs->device, pattern_manage)(ctx->pgs->device, pinst->id, pinst,
- pattern_manage__start_accum);
- if (code < 0) {
- gs_grestore(ctx->pgs);
- return code;
- }
-
- code = xps_paint_tiling_brush(&pdc->ccolor, ctx->pgs);
- if (code) {
- gs_grestore(ctx->pgs);
- return gs_rethrow(code, "high level pattern brush function failed");
- }
-
- code = gs_grestore(ctx->pgs);
- if (code < 0)
- return code;
-
- code = dev_proc(ctx->pgs->device, pattern_manage)(ctx->pgs->device, gx_no_bitmap_id, NULL,
- pattern_manage__finish_accum);
-
- return code;
-}
-
-static int
-xps_remap_pattern(const gs_client_color *pcc, gs_state *pgs)
-{
- const gs_client_pattern *ppat = gs_getpattern(pcc);
- struct tile_closure_s *c = ppat->client_data;
- xps_context_t *ctx = c->ctx;
- int code;
-
- /* pgs->device is the newly created pattern accumulator, but we want to test the device
- * that is 'behind' that, the actual output device, so we use the one from
- * the saved XPS graphics state.
- */
- code = dev_proc(ctx->pgs->device, pattern_manage)(ctx->pgs->device, ppat->uid.id, ppat,
- pattern_manage__can_accum);
-
- if (code == 1) {
- /* Device handles high-level patterns, so return 'remap'.
- * This closes the internal accumulator device, as we no longer need
- * it, and the error trickles back up to the PDL client. The client
- * must then take action to start the device's accumulator, draw the
- * pattern, close the device's accumulator and generate a cache entry.
- */
- return gs_error_Remap_Color;
- } else {
- code = xps_paint_tiling_brush(pcc, pgs);
- if (code)
- return gs_rethrow(code, "remap pattern brush function failed");
- return 0;
- }
+ return fz_rethrow(code, "cannot draw tile");
}
+#endif
int
-xps_parse_tiling_brush(xps_context_t *ctx, char *base_uri, xps_resource_t *dict, xps_item_t *root,
- int (*func)(xps_context_t*, char*, xps_resource_t*, xps_item_t*, void*), void *user)
+xps_parse_tiling_brush(xps_context_t *ctx, fz_matrix ctm,
+ char *base_uri, xps_resource_t *dict, xps_item_t *root,
+ int (*func)(xps_context_t*, fz_matrix, char*, xps_resource_t*, xps_item_t*, void*), void *user)
{
xps_item_t *node;
int code;
@@ -224,9 +124,9 @@ xps_parse_tiling_brush(xps_context_t *ctx, char *base_uri, xps_resource_t *dict,
xps_item_t *transform_tag = NULL;
- gs_matrix transform;
- gs_rect viewbox;
- gs_rect viewport;
+ fz_matrix transform;
+ fz_rect viewbox;
+ fz_rect viewport;
float scalex, scaley;
int tile_mode;
@@ -248,30 +148,28 @@ xps_parse_tiling_brush(xps_context_t *ctx, char *base_uri, xps_resource_t *dict,
xps_resolve_resource_reference(ctx, dict, &transform_att, &transform_tag, NULL);
- gs_make_identity(&transform);
+ transform = fz_identity;
if (transform_att)
xps_parse_render_transform(ctx, transform_att, &transform);
if (transform_tag)
xps_parse_matrix_transform(ctx, transform_tag, &transform);
- viewbox.p.x = 0.0; viewbox.p.y = 0.0;
- viewbox.q.x = 1.0; viewbox.q.y = 1.0;
+ viewbox = fz_unitrect;
if (viewbox_att)
xps_parse_rectangle(ctx, viewbox_att, &viewbox);
- viewport.p.x = 0.0; viewport.p.y = 0.0;
- viewport.q.x = 1.0; viewport.q.y = 1.0;
+ viewport = fz_unitrect;
if (viewport_att)
xps_parse_rectangle(ctx, viewport_att, &viewport);
/* some sanity checks on the viewport/viewbox size */
- if (fabs(viewport.q.x - viewport.p.x) < 0.01) return 0;
- if (fabs(viewport.q.y - viewport.p.y) < 0.01) return 0;
- if (fabs(viewbox.q.x - viewbox.p.x) < 0.01) return 0;
- if (fabs(viewbox.q.y - viewbox.p.y) < 0.01) return 0;
+ if (fabs(viewport.x1 - viewport.x0) < 0.01) return 0;
+ if (fabs(viewport.y1 - viewport.y0) < 0.01) return 0;
+ if (fabs(viewbox.x1 - viewbox.x0) < 0.01) return 0;
+ if (fabs(viewbox.y1 - viewbox.y0) < 0.01) return 0;
- scalex = (viewport.q.x - viewport.p.x) / (viewbox.q.x - viewbox.p.x);
- scaley = (viewport.q.y - viewport.p.y) / (viewbox.q.y - viewbox.p.y);
+ scalex = (viewport.x1 - viewport.x0) / (viewbox.x1 - viewbox.x0);
+ scaley = (viewport.y1 - viewport.y0) / (viewbox.y1 - viewbox.y0);
tile_mode = TILE_NONE;
if (tile_mode_att)
@@ -288,24 +186,25 @@ xps_parse_tiling_brush(xps_context_t *ctx, char *base_uri, xps_resource_t *dict,
tile_mode = TILE_FLIP_X_Y;
}
- gs_gsave(ctx->pgs);
+// gs_gsave(ctx->pgs);
- code = xps_begin_opacity(ctx, base_uri, dict, opacity_att, NULL);
+ code = xps_begin_opacity(ctx, ctm, base_uri, dict, opacity_att, NULL);
if (code)
{
- gs_grestore(ctx->pgs);
- return gs_rethrow(code, "cannot create transparency group");
+// gs_grestore(ctx->pgs);
+ return fz_rethrow(code, "cannot create transparency group");
}
/* TODO(tor): check viewport and tiling to see if we can set it to TILE_NONE */
+#if 0
if (tile_mode != TILE_NONE)
{
struct tile_closure_s closure;
gs_client_pattern gspat;
gs_client_color gscolor;
- gs_color_space *cs;
+ fz_colorspace *cs;
closure.ctx = ctx;
closure.base_uri = base_uri;
@@ -346,9 +245,9 @@ xps_parse_tiling_brush(xps_context_t *ctx, char *base_uri, xps_resource_t *dict,
gspat.YStep *= 2;
}
- gs_matrix_translate(&transform, viewport.p.x, viewport.p.y, &transform);
- gs_matrix_scale(&transform, scalex, scaley, &transform);
- gs_matrix_translate(&transform, -viewbox.p.x, -viewbox.p.y, &transform);
+ fz_matrix_translate(&transform, viewport.p.x, viewport.p.y, &transform);
+ fz_matrix_scale(&transform, scalex, scaley, &transform);
+ fz_matrix_translate(&transform, -viewbox.p.x, -viewbox.p.y, &transform);
cs = ctx->srgb;
gs_setcolorspace(ctx->pgs, cs);
@@ -387,13 +286,14 @@ xps_parse_tiling_brush(xps_context_t *ctx, char *base_uri, xps_resource_t *dict,
{
xps_end_opacity(ctx, base_uri, dict, opacity_att, NULL);
gs_grestore(ctx->pgs);
- return gs_rethrow(code, "cannot draw tile");
+ return fz_rethrow(code, "cannot draw tile");
}
}
+#endif
xps_end_opacity(ctx, base_uri, dict, opacity_att, NULL);
- gs_grestore(ctx->pgs);
+// gs_grestore(ctx->pgs);
return 0;
}