/* 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 */ }
/* Obtain a spot analyzer device. */ int gx_san__obtain(gs_memory_t *mem, gx_device_spot_analyzer **ppadev) { gx_device_spot_analyzer *padev; int code; if (*ppadev != 0) { (*ppadev)->lock++; return 0; } padev = gs_alloc_struct(mem, gx_device_spot_analyzer, &st_device_spot_analyzer, "gx_san__obtain"); if (padev == 0) return_error(gs_error_VMerror); gx_device_init((gx_device *)padev, (const gx_device *)&gx_spot_analyzer_device, mem, false); code = gs_opendevice((gx_device *)padev); if (code < 0) { gs_free_object(mem, padev, "gx_san__obtain"); return code; } padev->lock = 1; *ppadev = padev; return 0; }
/* Set up a clipping path and device for insideness testing. */ static int in_path(os_ptr oppath, i_ctx_t *i_ctx_p, gx_device * phdev) { int code = gs_gsave(igs); int npop; double uxy[2]; if (code < 0) return code; code = num_params(oppath, 2, uxy); if (code >= 0) { /* Aperture is a single pixel. */ gs_point dxy; gs_fixed_rect fr; gs_transform(igs, uxy[0], uxy[1], &dxy); fr.p.x = fixed_floor(float2fixed(dxy.x)); fr.p.y = fixed_floor(float2fixed(dxy.y)); fr.q.x = fr.p.x + fixed_1; fr.q.y = fr.p.y + fixed_1; code = gx_clip_to_rectangle(igs, &fr); npop = 2; } else if (code == e_stackunderflow) { /* If 0 elements, definitely a stackunderflow; otherwise, */ /* only 1 number, also a stackunderflow. */ npop = code; } else { /* Aperture is a user path. */ /* We have to set the clipping path without disturbing */ /* the current path. */ gx_path *ipath = igs->path; gx_path save; gx_path_init_local(&save, imemory); gx_path_assign_preserve(&save, ipath); gs_newpath(igs); code = upath_append(oppath, i_ctx_p, false); if (code >= 0) code = gx_clip_to_path(igs); gx_path_assign_free(igs->path, &save); npop = 1; } if (code < 0) { gs_grestore(igs); return code; } /* Install the hit detection device. */ gx_set_device_color_1(igs); gx_device_init((gx_device *) phdev, (const gx_device *)&gs_hit_device, NULL, true); phdev->width = phdev->height = max_int; gx_device_fill_in_procs(phdev); gx_set_device_only(igs, phdev); return npop; }
/* 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; }
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); }
/* 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; }