1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: gxmclip.c 8250 2007-09-25 13:31:24Z giles $ */
15
/* Mask clipping support */
22
/* Structure descriptor */
23
public_st_device_mask_clip();
26
static ENUM_PTRS_WITH(device_mask_clip_enum_ptrs, gx_device_mask_clip *mcdev)
28
if (index < st_gx_strip_bitmap_max_ptrs) {
29
return ENUM_USING(st_gx_strip_bitmap, &mcdev->tiles,
30
sizeof(mcdev->tiles), index);
32
index -= st_gx_strip_bitmap_max_ptrs;
33
if (index < st_device_memory_max_ptrs) {
34
return ENUM_USING(st_device_memory, &mcdev->mdev,
35
sizeof(mcdev->mdev), index);
37
ENUM_PREFIX(st_device_forward, st_device_memory_max_ptrs);
40
static RELOC_PTRS_WITH(device_mask_clip_reloc_ptrs, gx_device_mask_clip *mcdev)
42
RELOC_PREFIX(st_device_forward);
43
RELOC_USING(st_gx_strip_bitmap, &mcdev->tiles, sizeof(mcdev->tiles));
44
RELOC_USING(st_device_memory, &mcdev->mdev, sizeof(mcdev->mdev));
45
if (mcdev->mdev.base != 0) {
47
* Update the line pointers specially, since they point into the
48
* buffer that is part of the mask clipping device itself.
50
long diff = (char *)RELOC_OBJ(mcdev) - (char *)mcdev;
53
for (i = 0; i < mcdev->mdev.height; ++i)
54
mcdev->mdev.line_ptrs[i] += diff;
55
mcdev->mdev.base = mcdev->mdev.line_ptrs[0];
56
mcdev->mdev.line_ptrs =
57
(void *)((char *)(mcdev->mdev.line_ptrs) + diff);
62
/* Initialize a mask clipping device. */
64
gx_mask_clip_initialize(gx_device_mask_clip * cdev,
65
const gx_device_mask_clip * proto,
66
const gx_bitmap * bits, gx_device * tdev,
67
int tx, int ty, gs_memory_t *mem)
69
int buffer_width = bits->size.x;
71
tile_clip_buffer_size / (bits->raster + sizeof(byte *));
73
gx_device_init((gx_device *)cdev, (const gx_device *)proto,
75
cdev->width = tdev->width;
76
cdev->height = tdev->height;
77
cdev->color_info = tdev->color_info;
78
gx_device_set_target((gx_device_forward *)cdev, tdev);
81
if (buffer_height > bits->size.y)
82
buffer_height = bits->size.y;
83
gs_make_mem_mono_device(&cdev->mdev, 0, 0);
85
ulong bitmap_size = max_ulong;
87
if (buffer_height <= 0) {
89
* The tile is too wide to buffer even one scan line.
90
* We could do copy_mono in chunks, but for now, we punt.
93
return_error(gs_error_VMerror);
95
cdev->mdev.width = buffer_width;
96
cdev->mdev.height = buffer_height;
97
gdev_mem_bitmap_size(&cdev->mdev, &bitmap_size);
98
if (bitmap_size <= tile_clip_buffer_size)
102
cdev->mdev.base = cdev->buffer.bytes;
103
return (*dev_proc(&cdev->mdev, open_device))((gx_device *)&cdev->mdev);