gdevhit.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Copyright (C) 1998, 1999 Aladdin Enterprises. All rights reserved.
  2. This file is part of AFPL Ghostscript.
  3. AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  4. distributor accepts any responsibility for the consequences of using it, or
  5. for whether it serves any particular purpose or works at all, unless he or
  6. she says so in writing. Refer to the Aladdin Free Public License (the
  7. "License") for full details.
  8. Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. in a plain ASCII text file named PUBLIC. The License grants you the right
  10. to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. conditions described in the License. Among other things, the License
  12. requires that the copyright notice and this notice be preserved on all
  13. copies.
  14. */
  15. /*$Id: gdevhit.c,v 1.2 2000/09/19 19:00:13 lpd Exp $ */
  16. /* Hit detection device */
  17. #include "std.h"
  18. #include "gserror.h"
  19. #include "gserrors.h"
  20. #include "gstypes.h"
  21. #include "gsmemory.h"
  22. #include "gxdevice.h"
  23. /* Define the value returned for a detected hit. */
  24. const int gs_hit_detected = gs_error_hit_detected;
  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. private 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. /* Test for a hit when filling a rectangle. */
  78. private int
  79. hit_fill_rectangle(gx_device * dev, int x, int y, int w, int h,
  80. gx_color_index color)
  81. {
  82. if (w > 0 && h > 0)
  83. return_error(gs_error_hit_detected);
  84. return 0;
  85. }