10
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
13
/*$Id: gdevbbox.c 8022 2007-06-05 22:23:38Z giles $ */
13
/*$Id: gdevbbox.c 8250 2007-09-25 13:31:24Z giles $ */
14
14
/* Device for tracking bounding box */
16
16
#include "memory_.h"
31
31
public_st_device_bbox();
33
33
/* Device procedures */
34
private dev_proc_open_device(bbox_open_device);
35
private dev_proc_close_device(bbox_close_device);
36
private dev_proc_output_page(bbox_output_page);
37
private dev_proc_fill_rectangle(bbox_fill_rectangle);
38
private dev_proc_copy_mono(bbox_copy_mono);
39
private dev_proc_copy_color(bbox_copy_color);
40
private dev_proc_get_params(bbox_get_params);
41
private dev_proc_put_params(bbox_put_params);
42
private dev_proc_copy_alpha(bbox_copy_alpha);
43
private dev_proc_fill_path(bbox_fill_path);
44
private dev_proc_stroke_path(bbox_stroke_path);
45
private dev_proc_fill_mask(bbox_fill_mask);
46
private dev_proc_fill_trapezoid(bbox_fill_trapezoid);
47
private dev_proc_fill_parallelogram(bbox_fill_parallelogram);
48
private dev_proc_fill_triangle(bbox_fill_triangle);
49
private dev_proc_draw_thin_line(bbox_draw_thin_line);
50
private dev_proc_strip_tile_rectangle(bbox_strip_tile_rectangle);
51
private dev_proc_strip_copy_rop(bbox_strip_copy_rop);
52
private dev_proc_begin_typed_image(bbox_begin_typed_image);
53
private dev_proc_create_compositor(bbox_create_compositor);
54
private dev_proc_text_begin(bbox_text_begin);
34
static dev_proc_open_device(bbox_open_device);
35
static dev_proc_close_device(bbox_close_device);
36
static dev_proc_output_page(bbox_output_page);
37
static dev_proc_fill_rectangle(bbox_fill_rectangle);
38
static dev_proc_copy_mono(bbox_copy_mono);
39
static dev_proc_copy_color(bbox_copy_color);
40
static dev_proc_get_params(bbox_get_params);
41
static dev_proc_put_params(bbox_put_params);
42
static dev_proc_copy_alpha(bbox_copy_alpha);
43
static dev_proc_fill_path(bbox_fill_path);
44
static dev_proc_stroke_path(bbox_stroke_path);
45
static dev_proc_fill_mask(bbox_fill_mask);
46
static dev_proc_fill_trapezoid(bbox_fill_trapezoid);
47
static dev_proc_fill_parallelogram(bbox_fill_parallelogram);
48
static dev_proc_fill_triangle(bbox_fill_triangle);
49
static dev_proc_draw_thin_line(bbox_draw_thin_line);
50
static dev_proc_strip_tile_rectangle(bbox_strip_tile_rectangle);
51
static dev_proc_strip_copy_rop(bbox_strip_copy_rop);
52
static dev_proc_begin_typed_image(bbox_begin_typed_image);
53
static dev_proc_create_compositor(bbox_create_compositor);
54
static dev_proc_text_begin(bbox_text_begin);
56
56
/* The device prototype */
58
* Normally this would be private, but if the device is going to be used
58
* Normally this would be static, but if the device is going to be used
59
59
* stand-alone, it has to be public.
63
63
* The bbox device sets the resolution to some value R (currently 4000), and
64
64
* the page size in device pixels to slightly smaller than the largest
200
200
#define BBOX_IN_RECT(bdev, pbox)\
201
201
bdev->box_procs.in_rect(bdev->box_proc_data, pbox)
203
private const gx_device_bbox_procs_t box_procs_default = {
203
static const gx_device_bbox_procs_t box_procs_default = {
204
204
bbox_default_init_box, bbox_default_get_box, bbox_default_add_rect,
205
205
bbox_default_in_rect
402
402
bbox_copy_mono(gx_device * dev, const byte * data,
403
403
int dx, int raster, gx_bitmap_id id, int x, int y, int w, int h,
404
404
gx_color_index zero, gx_color_index one)
438
438
bbox_copy_alpha(gx_device * dev, const byte * data, int data_x,
439
439
int raster, gx_bitmap_id id, int x, int y, int w, int h,
440
440
gx_color_index color, int depth)
585
585
/* ---------------- Polygon drawing ---------------- */
588
588
edge_x_at_y(const gs_fixed_edge * edge, fixed y)
590
590
return fixed_mult_quo(edge->end.x - edge->start.x,
591
591
y - edge->start.y,
592
592
edge->end.y - edge->start.y) + edge->start.x;
595
595
bbox_fill_trapezoid(gx_device * dev,
596
596
const gs_fixed_edge * left, const gs_fixed_edge * right,
597
597
fixed ybot, fixed ytop, bool swap_axes,
743
743
((pbox)->p.x -= (adj).x, (pbox)->p.y -= (adj).y,\
744
744
(pbox)->q.x += (adj).x, (pbox)->q.y += (adj).y)
747
747
bbox_fill_path(gx_device * dev, const gs_imager_state * pis, gx_path * ppath,
748
748
const gx_fill_params * params, const gx_device_color * pdevc,
749
749
const gx_clip_path * pcpath)
803
803
return fill_path(tdev, pis, ppath, params, pdevc, pcpath);
807
807
bbox_stroke_path(gx_device * dev, const gs_imager_state * pis, gx_path * ppath,
808
808
const gx_stroke_params * params,
809
809
const gx_drawing_color * pdevc, const gx_clip_path * pcpath)
916
916
"bbox_image_enum", bbox_image_enum_enum_ptrs, bbox_image_enum_reloc_ptrs,
917
917
st_gx_image_enum_common, pcpath, target_info);
919
private image_enum_proc_plane_data(bbox_image_plane_data);
920
private image_enum_proc_end_image(bbox_image_end_image);
921
private image_enum_proc_flush(bbox_image_flush);
922
private image_enum_proc_planes_wanted(bbox_image_planes_wanted);
923
private const gx_image_enum_procs_t bbox_image_enum_procs = {
919
static image_enum_proc_plane_data(bbox_image_plane_data);
920
static image_enum_proc_end_image(bbox_image_end_image);
921
static image_enum_proc_flush(bbox_image_flush);
922
static image_enum_proc_planes_wanted(bbox_image_planes_wanted);
923
static const gx_image_enum_procs_t bbox_image_enum_procs = {
924
924
bbox_image_plane_data, bbox_image_end_image,
925
925
bbox_image_flush, bbox_image_planes_wanted
929
929
bbox_image_begin(const gs_imager_state * pis, const gs_matrix * pmat,
930
930
const gs_image_common_t * pic, const gs_int_rect * prect,
931
931
const gx_clip_path * pcpath, gs_memory_t * memory,
1076
1076
fixed x0 = float2fixed(corners[0].x), y0 = float2fixed(corners[0].y);
1077
1077
fixed bx2 = float2fixed(corners[2].x) - x0, by2 = float2fixed(corners[2].y) - y0;
1079
gx_make_clip_path_device(&cdev, pcpath);
1081
(*dev_proc(&cdev, open_device)) ((gx_device *) & cdev);
1079
gx_make_clip_device_on_stack(&cdev, pcpath, dev);
1082
1080
set_nonclient_dev_color(&devc, bdev->black); /* any non-white color will do */
1083
1081
bdev->target = NULL;
1084
1082
gx_default_fill_triangle((gx_device *) & cdev, x0, y0,
1128
1126
/* Compositing */
1131
1129
bbox_forward_init_box(void *pdata)
1133
1131
gx_device_bbox *const bdev = (gx_device_bbox *)pdata;
1135
1133
return BBOX_INIT_BOX(bdev);
1138
1136
bbox_forward_get_box(const void *pdata, gs_fixed_rect *pbox)
1140
1138
const gx_device_bbox *const bdev = (const gx_device_bbox *)pdata;
1142
1140
BBOX_GET_BOX(bdev, pbox);
1145
1143
bbox_forward_add_rect(void *pdata, fixed x0, fixed y0, fixed x1, fixed y1)
1147
1145
gx_device_bbox *const bdev = (gx_device_bbox *)pdata;
1149
1147
BBOX_ADD_RECT(bdev, x0, y0, x1, y1);
1152
1150
bbox_forward_in_rect(const void *pdata, const gs_fixed_rect *pbox)
1154
1152
const gx_device_bbox *const bdev = (const gx_device_bbox *)pdata;
1156
1154
return BBOX_IN_RECT(bdev, pbox);
1158
private const gx_device_bbox_procs_t box_procs_forward = {
1156
static const gx_device_bbox_procs_t box_procs_forward = {
1159
1157
bbox_forward_init_box, bbox_forward_get_box, bbox_forward_add_rect,
1160
1158
bbox_forward_in_rect
1164
1162
bbox_create_compositor(gx_device * dev,
1165
1163
gx_device ** pcdev, const gs_composite_t * pcte,
1166
1164
gs_imager_state * pis, gs_memory_t * memory)