/* Initialize a bounding box device. */ void gx_device_bbox_init(gx_device_bbox * dev, gx_device * target, gs_memory_t *mem) { gx_device_init((gx_device *) dev, (const gx_device *)&gs_bbox_device, (target ? target->memory : mem), true); if (target) { gx_device_forward_fill_in_procs((gx_device_forward *) dev); set_dev_proc(dev, get_initial_matrix, gx_forward_get_initial_matrix); set_dev_proc(dev, map_rgb_color, gx_forward_map_rgb_color); set_dev_proc(dev, map_color_rgb, gx_forward_map_color_rgb); set_dev_proc(dev, map_cmyk_color, gx_forward_map_cmyk_color); set_dev_proc(dev, map_rgb_alpha_color, gx_forward_map_rgb_alpha_color); set_dev_proc(dev, get_color_mapping_procs, gx_forward_get_color_mapping_procs); set_dev_proc(dev, get_color_comp_index, gx_forward_get_color_comp_index); set_dev_proc(dev, encode_color, gx_forward_encode_color); set_dev_proc(dev, decode_color, gx_forward_decode_color); set_dev_proc(dev, dev_spec_op, gx_forward_dev_spec_op); set_dev_proc(dev, fill_rectangle_hl_color, gx_forward_fill_rectangle_hl_color); set_dev_proc(dev, include_color_space, gx_forward_include_color_space); set_dev_proc(dev, update_spot_equivalent_colors, gx_forward_update_spot_equivalent_colors); set_dev_proc(dev, get_page_device, gx_forward_get_page_device); set_dev_proc(dev, ret_devn_params, gx_forward_ret_devn_params); gx_device_set_target((gx_device_forward *)dev, target); } else { gx_device_fill_in_procs((gx_device *)dev); gx_device_forward_fill_in_procs((gx_device_forward *) dev); } dev->box_procs = box_procs_default; dev->box_proc_data = dev; bbox_copy_params(dev, false); dev->free_standing = false; /* being used as a component */ }
static int bbox_open_device(gx_device * dev) { gx_device_bbox *bdev = (gx_device_bbox *) dev; int code; if (bdev->free_standing) { gx_device_forward_fill_in_procs((gx_device_forward *) dev); bdev->box_procs = box_procs_default; bdev->box_proc_data = bdev; code = install_internal_subclass_devices((gx_device **)&bdev, NULL); if (code < 0) return code; } if (bdev->box_procs.init_box == box_procs_default.init_box) BBOX_INIT_BOX(bdev); /* gx_forward_open_device doesn't exist */ { gx_device *tdev = bdev->target; int code = (tdev && bdev->forward_open_close ? gs_opendevice(tdev) : 0); bbox_copy_params(bdev, true); return code; } }
/* from PageBoundingBox. */ static int bbox_put_params(gx_device * dev, gs_param_list * plist) { gx_device_bbox *const bdev = (gx_device_bbox *) dev; int code; int ecode = 0; bool white_is_opaque = bdev->white_is_opaque; gs_param_name param_name; gs_param_float_array bba; code = param_read_float_array(plist, (param_name = "PageBoundingBox"), &bba); switch (code) { case 0: if (bba.size != 4) { ecode = gs_note_error(gs_error_rangecheck); goto e; } break; default: ecode = code; e:param_signal_error(plist, param_name, ecode); case 1: bba.data = 0; } switch (code = param_read_bool(plist, (param_name = "WhiteIsOpaque"), &white_is_opaque)) { default: ecode = code; param_signal_error(plist, param_name, ecode); case 0: case 1: break; } code = gx_forward_put_params(dev, plist); if (ecode < 0) code = ecode; if (code >= 0) { if( bba.data != 0) { BBOX_INIT_BOX(bdev); BBOX_ADD_RECT(bdev, float2fixed(bba.data[0]), float2fixed(bba.data[1]), float2fixed(bba.data[2]), float2fixed(bba.data[3])); } bdev->white_is_opaque = white_is_opaque; } bbox_copy_params(bdev, bdev->is_open); return code; }