Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/* Copyright (C) 1998, 1999 Aladdin Enterprises.  All rights reserved.
2
 
3
  This software is provided AS-IS with no warranty, either express or
4
  implied.
5
 
6
  This software is distributed under license and may not be copied,
7
  modified or distributed except as expressly authorized under the terms
8
  of the license contained in the file LICENSE in this distribution.
9
 
10
  For more information about licensing, please refer to
11
  http://www.ghostscript.com/licensing/. For information on
12
  commercial licensing, go to http://www.artifex.com/licensing/ or
13
  contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
  San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
*/
16
 
17
/* $Id: gxmclip.h,v 1.5 2002/06/16 08:45:43 lpd Exp $ */
18
/* Mask clipping device and interface */
19
/* Requires gxdevice.h, gxdevmem.h */
20
 
21
#ifndef gxmclip_INCLUDED
22
#  define gxmclip_INCLUDED
23
 
24
#include "gxclip.h"
25
 
26
/*
27
 * ImageType 3 images and Patterns that don't completely fill their
28
 * bounding box require the ability to clip against a mask.
29
 * The interface declared here doesn't take a position on whether
30
 * the mask will be used only in one position (ImageType 3) or in
31
 * multiple positions for tiling (Patterns).
32
 *
33
 * All the information in this file is logically private, but we must expose
34
 * the structure definition so that clients can allocate instances in the
35
 * stack frame.
36
 */
37
 
38
#define tile_clip_buffer_request 300
39
#define tile_clip_buffer_size\
40
  ((tile_clip_buffer_request / arch_sizeof_long) * arch_sizeof_long)
41
typedef struct gx_device_mask_clip_s {
42
    gx_device_forward_common;	/* target is set by client */
43
    gx_strip_bitmap tiles;
44
    gx_device_memory mdev;	/* for tile buffer for copy_mono */
45
    gs_int_point phase;		/* device space origin relative */
46
				/* to tile (backwards from gstate phase) */
47
    /* Ensure that the buffer is long-aligned. */
48
    union _b {
49
	byte bytes[tile_clip_buffer_size];
50
	ulong longs[tile_clip_buffer_size / arch_sizeof_long];
51
    } buffer;
52
} gx_device_mask_clip;
53
 
54
extern_st(st_device_mask_clip);
55
#define public_st_device_mask_clip()	/* in gxmclip.c */\
56
  gs_public_st_composite_use_final(st_device_mask_clip, gx_device_mask_clip,\
57
    "gx_device_mask_clip", device_mask_clip_enum_ptrs,\
58
    device_mask_clip_reloc_ptrs, gx_device_finalize)
59
 
60
/*
61
 * Internal routine to initialize a mask clipping device.
62
 * We supply an explicit device space origin or phase.
63
 * Note that this procedure does not set cdev->tiles.
64
 */
65
int gx_mask_clip_initialize(gx_device_mask_clip * cdev,
66
			    const gx_device_mask_clip * proto,
67
			    const gx_bitmap * bits, gx_device * tdev,
68
			    int tx, int ty, gs_memory_t *mem);
69
 
70
/*
71
 * Prepare colors for a copy_mono operation.
72
 * The arguments of copy_mono are free variables:
73
 *   dev, data, sourcex, raster, id, x, y, w, y, color0, color1.
74
 */
75
#define setup_mask_copy_mono(cdev, color, mcolor0, mcolor1)\
76
	BEGIN\
77
	  if ( cdev->mdev.base == 0 ) {\
78
	    /*\
79
	     * The tile was too large for us to buffer even one scan line.\
80
	     * Punt to the very, very slow default implementation of\
81
	     * copy_mono.\
82
	     */\
83
	    return gx_default_copy_mono(dev, data, sourcex, raster, id,\
84
					x, y, w, h, color0, color1);\
85
	  }\
86
	  if ( color1 != gx_no_color_index ) {\
87
	    if ( color0 != gx_no_color_index ) {\
88
	      /* Pre-fill with color0. */\
89
	      code =\
90
		(*dev_proc(dev, fill_rectangle))(dev, x, y, w, h, color0);\
91
	      if ( code < 0 )\
92
		return code;\
93
	    }\
94
	    color = color1;\
95
	    mcolor0 = 0, mcolor1 = gx_no_color_index;\
96
	  } else if ( color0 != gx_no_color_index ) {\
97
	    color = color0;\
98
	    mcolor0 = gx_no_color_index, mcolor1 = 0;\
99
	  } else\
100
	    return 0;\
101
	END
102
 
103
#endif /* gxmclip_INCLUDED */