/src/ghostpdl/base/gdevhit.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright (C) 2001-2023 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, |
8 | | modified or distributed except as expressly authorized under the terms |
9 | | of the license contained in the file LICENSE in this distribution. |
10 | | |
11 | | Refer to licensing information at http://www.artifex.com or contact |
12 | | Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, |
13 | | CA 94129, USA, for further information. |
14 | | */ |
15 | | |
16 | | /* Hit detection device */ |
17 | | #include "std.h" |
18 | | #include "gserrors.h" |
19 | | #include "gstypes.h" |
20 | | #include "gsmemory.h" |
21 | | #include "gxdevice.h" |
22 | | |
23 | | /* Define the value returned for a detected hit. */ |
24 | | const int gs_hit_detected = gs_error_hit_detected; |
25 | | |
26 | | /* |
27 | | * Define a minimal device for insideness testing. |
28 | | * It returns e_hit whenever it is asked to actually paint any pixels. |
29 | | */ |
30 | | static dev_proc_fill_rectangle(hit_fill_rectangle); |
31 | | static void |
32 | | hit_initialize_device_procs(gx_device *dev) |
33 | 0 | { |
34 | 0 | set_dev_proc(dev, fill_rectangle, hit_fill_rectangle); |
35 | 0 | set_dev_proc(dev, composite, gx_non_imaging_composite); |
36 | |
|
37 | 0 | set_dev_proc(dev, map_rgb_color, gx_default_map_rgb_color); |
38 | 0 | set_dev_proc(dev, map_color_rgb, gx_default_map_color_rgb); |
39 | 0 | set_dev_proc(dev, map_cmyk_color, gx_default_map_cmyk_color); |
40 | 0 | set_dev_proc(dev, get_page_device, gx_default_get_page_device); |
41 | 0 | set_dev_proc(dev, get_alpha_bits, gx_default_get_alpha_bits); |
42 | 0 | set_dev_proc(dev, fill_path, gx_default_fill_path); |
43 | 0 | set_dev_proc(dev, fill_trapezoid, gx_default_fill_trapezoid); |
44 | 0 | set_dev_proc(dev, fill_parallelogram, gx_default_fill_parallelogram); |
45 | 0 | set_dev_proc(dev, fill_triangle, gx_default_fill_triangle); |
46 | 0 | set_dev_proc(dev, draw_thin_line, gx_default_draw_thin_line); |
47 | 0 | set_dev_proc(dev, strip_tile_rectangle, gx_default_strip_tile_rectangle); |
48 | 0 | set_dev_proc(dev, strip_copy_rop2, gx_default_strip_copy_rop2); |
49 | 0 | set_dev_proc(dev, get_clipping_box, gx_get_largest_clipping_box); |
50 | 0 | set_dev_proc(dev, begin_typed_image, gx_default_begin_typed_image); |
51 | 0 | } |
52 | | const gx_device gs_hit_device = { |
53 | | std_device_std_body(gx_device, hit_initialize_device_procs, "hit detector", |
54 | | 0, 0, 1, 1) |
55 | | }; |
56 | | |
57 | | /* Test for a hit when filling a rectangle. */ |
58 | | static int |
59 | | hit_fill_rectangle(gx_device * dev, int x, int y, int w, int h, |
60 | | gx_color_index color) |
61 | 0 | { |
62 | 0 | if (w > 0 && h > 0) |
63 | 0 | return_error(gs_error_hit_detected); |
64 | 0 | return 0; |
65 | 0 | } |