1 /* Copyright (C) 2001-2006 Artifex Software, Inc.
2    All Rights Reserved.
3 
4    This software is provided AS-IS with no warranty, either express or
5    implied.
6 
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.
12 */
13 /* $Id: gdevhit.c 8250 2007-09-25 13:31:24Z giles $ */
14 /* Hit detection device */
15 #include "std.h"
16 #include "gserror.h"
17 #include "gserrors.h"
18 #include "gstypes.h"
19 #include "gsmemory.h"
20 #include "gxdevice.h"
21 
22 /* Define the value returned for a detected hit. */
23 const int gs_hit_detected = gs_error_hit_detected;
24 
25 /*
26  * Define a minimal device for insideness testing.
27  * It returns e_hit whenever it is asked to actually paint any pixels.
28  */
29 static dev_proc_fill_rectangle(hit_fill_rectangle);
30 const gx_device gs_hit_device = {
31  std_device_std_body(gx_device, 0, "hit detector",
32 		     0, 0, 1, 1),
33  {NULL,				/* open_device */
34   NULL,				/* get_initial_matrix */
35   NULL,				/* sync_output */
36   NULL,				/* output_page */
37   NULL,				/* close_device */
38   gx_default_map_rgb_color,
39   gx_default_map_color_rgb,
40   hit_fill_rectangle,
41   NULL,				/* tile_rectangle */
42   NULL,				/* copy_mono */
43   NULL,				/* copy_color */
44   gx_default_draw_line,
45   NULL,				/* get_bits */
46   NULL,				/* get_params */
47   NULL,				/* put_params */
48   gx_default_map_cmyk_color,
49   NULL,				/* get_xfont_procs */
50   NULL,				/* get_xfont_device */
51   gx_default_map_rgb_alpha_color,
52   gx_default_get_page_device,
53   gx_default_get_alpha_bits,
54   NULL,				/* copy_alpha */
55   gx_default_get_band,
56   NULL,				/* copy_rop */
57   gx_default_fill_path,
58   NULL,				/* stroke_path */
59   NULL,				/* fill_mask */
60   gx_default_fill_trapezoid,
61   gx_default_fill_parallelogram,
62   gx_default_fill_triangle,
63   gx_default_draw_thin_line,
64   gx_default_begin_image,
65   gx_default_image_data,
66   gx_default_end_image,
67   gx_default_strip_tile_rectangle,
68   gx_default_strip_copy_rop,
69   gx_get_largest_clipping_box,
70   gx_default_begin_typed_image,
71   NULL,				/* get_bits_rectangle */
72   gx_default_map_color_rgb_alpha,
73   gx_non_imaging_create_compositor,
74   NULL				/* get_hardware_params */
75  }
76 };
77 
78 /* Test for a hit when filling a rectangle. */
79 static int
hit_fill_rectangle(gx_device * dev,int x,int y,int w,int h,gx_color_index color)80 hit_fill_rectangle(gx_device * dev, int x, int y, int w, int h,
81 		   gx_color_index color)
82 {
83     if (w > 0 && h > 0)
84 	return_error(gs_error_hit_detected);
85     return 0;
86 }
87