Ejemplo n.º 1
0
/* 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 */
}
Ejemplo n.º 2
0
/* Initialize a RasterOp source device. */
void
gx_make_rop_texture_device(gx_device_rop_texture * dev, gx_device * target,
	     gs_logical_operation_t log_op, const gx_device_color * texture)
{
    gx_device_init((gx_device *) dev,
		   (const gx_device *)&gs_rop_texture_device,
		   NULL, true);
    gx_device_set_target((gx_device_forward *)dev, target);
    /* Drawing operations are defaulted, non-drawing are forwarded. */
    check_device_separable((gx_device *) dev);
    gx_device_fill_in_procs((gx_device *) dev);
    gx_device_copy_params((gx_device *)dev, target);
    dev->log_op = log_op;
    dev->texture = *texture;
}
Ejemplo n.º 3
0
static int
bbox_create_compositor(gx_device * dev,
		       gx_device ** pcdev, const gs_composite_t * pcte,
		       gs_imager_state * pis, gs_memory_t * memory, gx_device *cindev)
{
    gx_device_bbox *const bdev = (gx_device_bbox *) dev;
    gx_device *target = bdev->target;

    /*
     * If there isn't a target, all we care about is the bounding box,
     * so don't bother with actually compositing.
     */
    if (target == 0) {
	*pcdev = dev;
	return 0;
    }
    /*
     * Create a compositor for the target, and then wrap another
     * bbox device around it, but still accumulating the bounding
     * box in the same place.
     */
    {
	gx_device *temp_cdev;
	gx_device_bbox *bbcdev;
	int code = (*dev_proc(target, create_compositor))
	    (target, &temp_cdev, pcte, pis, memory, cindev);

	/* If the target did not create a new compositor then we are done. */
	if (code < 0 || target == temp_cdev) {
	    *pcdev = dev;
	    return code;
	}
	bbcdev = gs_alloc_struct_immovable(memory, gx_device_bbox,
					   &st_device_bbox,
					   "bbox_create_compositor");
	if (bbcdev == 0) {
	    (*dev_proc(temp_cdev, close_device)) (temp_cdev);
	    return_error(gs_error_VMerror);
	}
	gx_device_bbox_init(bbcdev, target, memory);
	gx_device_set_target((gx_device_forward *)bbcdev, temp_cdev);
	bbcdev->box_procs = box_procs_forward;
	bbcdev->box_proc_data = bdev;
	*pcdev = (gx_device *) bbcdev;
	return 0;
    }
}
Ejemplo n.º 4
0
RELOC_PTRS_END

/* Initialize a mask clipping device. */
int
gx_mask_clip_initialize(gx_device_mask_clip * cdev,
			const gx_device_mask_clip * proto,
			const gx_bitmap * bits, gx_device * tdev,
			int tx, int ty, gs_memory_t *mem)
{
    int buffer_width = bits->size.x;
    int buffer_height =
	tile_clip_buffer_size / (bits->raster + sizeof(byte *));

    gx_device_init((gx_device *)cdev, (const gx_device *)proto,
		   mem, true);
    cdev->width = tdev->width;
    cdev->height = tdev->height;
    cdev->color_info = tdev->color_info;
    gx_device_set_target((gx_device_forward *)cdev, tdev);
    cdev->phase.x = -tx;
    cdev->phase.y = -ty;
    if (buffer_height > bits->size.y)
	buffer_height = bits->size.y;
    gs_make_mem_mono_device(&cdev->mdev, 0, 0);
    for (;;) {
	ulong bitmap_size = max_ulong;

	if (buffer_height <= 0) {
	    /*
	     * The tile is too wide to buffer even one scan line.
	     * We could do copy_mono in chunks, but for now, we punt.
	     */
	    cdev->mdev.base = 0;
	    return_error(gs_error_VMerror);
	}
	cdev->mdev.width = buffer_width;
	cdev->mdev.height = buffer_height;
	gdev_mem_bitmap_size(&cdev->mdev, &bitmap_size);
	if (bitmap_size <= tile_clip_buffer_size)
	    break;
	buffer_height--;
    }
    cdev->mdev.base = cdev->buffer.bytes;
    return (*dev_proc(&cdev->mdev, open_device))((gx_device *)&cdev->mdev);
}
Ejemplo n.º 5
0
/* Create an alpha compositor. */
static int
c_alpha_create_default_compositor(const gs_composite_t * pcte,
	   gx_device ** pcdev, gx_device * dev, gs_imager_state * pis,
	   gs_memory_t * mem)
{
    gx_device_composite_alpha *cdev;

    if (pacte->params.op == composite_Copy) {
	/* Just use the original device. */
	*pcdev = dev;
	return 0;
    }
    cdev =
	gs_alloc_struct_immovable(mem, gx_device_composite_alpha,
				  &st_device_composite_alpha,
				  "create default alpha compositor");
    *pcdev = (gx_device *)cdev;
    if (cdev == 0)
	return_error(gs_error_VMerror);
    gx_device_init((gx_device *)cdev,
		   (const gx_device *)&gs_composite_alpha_device, mem, true);
    gx_device_copy_params((gx_device *)cdev, dev);
    /*
     * Set the color_info and depth to be compatible with the target,
     * but using standard chunky color storage, including alpha.
     ****** CURRENTLY ALWAYS USE 8-BIT COLOR ******
     */
    cdev->color_info.depth =
	(dev->color_info.num_components == 4 ? 32 /* CMYK, no alpha */ :
	 (dev->color_info.num_components + 1) * 8);
    cdev->color_info.max_gray = cdev->color_info.max_color = 255;
    /* No halftoning will occur, but we fill these in anyway.... */
    cdev->color_info.dither_grays = cdev->color_info.dither_colors = 256;
    /*
     * We could speed things up a little by tailoring the procedures in
     * the device to the specific num_components, but for simplicity,
     * we'll defer considering that until there is a demonstrated need.
     */
    gx_device_set_target((gx_device_forward *)cdev, dev);
    cdev->params = pacte->params;
    return 0;
}
Ejemplo n.º 6
0
/* Release a bounding box device. */
void
gx_device_bbox_release(gx_device_bbox *dev)
{
    /* Just release the reference to the target. */
    gx_device_set_target((gx_device_forward *)dev, NULL);
}