1 /* Copyright (C) 1998, 1999 artofcode LLC. All rights reserved. 2 3 This program is free software; you can redistribute it and/or modify it 4 under the terms of the GNU General Public License as published by the 5 Free Software Foundation; either version 2 of the License, or (at your 6 option) any later version. 7 8 This program is distributed in the hope that it will be useful, but 9 WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along 14 with this program; if not, write to the Free Software Foundation, Inc., 15 59 Temple Place, Suite 330, Boston, MA, 02111-1307. 16 17 */ 18 19 /*$Id: gxmclip.h,v 1.2.6.1.2.1 2003/01/17 00:49:04 giles Exp $ */ 20 /* Mask clipping device and interface */ 21 /* Requires gxdevice.h, gxdevmem.h */ 22 23 #ifndef gxmclip_INCLUDED 24 # define gxmclip_INCLUDED 25 26 #include "gxclip.h" 27 28 /* 29 * ImageType 3 images and Patterns that don't completely fill their 30 * bounding box require the ability to clip against a mask. 31 * The interface declared here doesn't take a position on whether 32 * the mask will be used only in one position (ImageType 3) or in 33 * multiple positions for tiling (Patterns). 34 * 35 * All the information in this file is logically private, but we must expose 36 * the structure definition so that clients can allocate instances in the 37 * stack frame. 38 */ 39 40 #define tile_clip_buffer_request 300 41 #define tile_clip_buffer_size\ 42 ((tile_clip_buffer_request / arch_sizeof_long) * arch_sizeof_long) 43 typedef struct gx_device_mask_clip_s { 44 gx_device_forward_common; /* target is set by client */ 45 gx_strip_bitmap tiles; 46 gx_device_memory mdev; /* for tile buffer for copy_mono */ 47 gs_int_point phase; /* device space origin relative */ 48 /* to tile (backwards from gstate phase) */ 49 /* Ensure that the buffer is long-aligned. */ 50 union _b { 51 byte bytes[tile_clip_buffer_size]; 52 ulong longs[tile_clip_buffer_size / arch_sizeof_long]; 53 } buffer; 54 } gx_device_mask_clip; 55 56 extern_st(st_device_mask_clip); 57 #define public_st_device_mask_clip() /* in gxmclip.c */\ 58 gs_public_st_composite_use_final(st_device_mask_clip, gx_device_mask_clip,\ 59 "gx_device_mask_clip", device_mask_clip_enum_ptrs,\ 60 device_mask_clip_reloc_ptrs, gx_device_finalize) 61 62 /* 63 * Internal routine to initialize a mask clipping device. 64 * We supply an explicit device space origin or phase. 65 * Note that this procedure does not set cdev->tiles. 66 */ 67 int gx_mask_clip_initialize(P7(gx_device_mask_clip * cdev, 68 const gx_device_mask_clip * proto, 69 const gx_bitmap * bits, gx_device * tdev, 70 int tx, int ty, gs_memory_t *mem)); 71 72 /* 73 * Prepare colors for a copy_mono operation. 74 * The arguments of copy_mono are free variables: 75 * dev, data, sourcex, raster, id, x, y, w, y, color0, color1. 76 */ 77 #define setup_mask_copy_mono(cdev, color, mcolor0, mcolor1)\ 78 BEGIN\ 79 if ( cdev->mdev.base == 0 ) {\ 80 /*\ 81 * The tile was too large for us to buffer even one scan line.\ 82 * Punt to the very, very slow default implementation of\ 83 * copy_mono.\ 84 */\ 85 return gx_default_copy_mono(dev, data, sourcex, raster, id,\ 86 x, y, w, h, color0, color1);\ 87 }\ 88 if ( color1 != gx_no_color_index ) {\ 89 if ( color0 != gx_no_color_index ) {\ 90 /* Pre-fill with color0. */\ 91 code =\ 92 (*dev_proc(dev, fill_rectangle))(dev, x, y, w, h, color0);\ 93 if ( code < 0 )\ 94 return code;\ 95 }\ 96 color = color1;\ 97 mcolor0 = 0, mcolor1 = gx_no_color_index;\ 98 } else if ( color0 != gx_no_color_index ) {\ 99 color = color0;\ 100 mcolor0 = gx_no_color_index, mcolor1 = 0;\ 101 } else\ 102 return 0;\ 103 END 104 105 #endif /* gxmclip_INCLUDED */ 106