gxpaint.c 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* Copyright (C) 1995, 1996, 1998, 1999 Aladdin Enterprises. All rights reserved.
  2. This software is provided AS-IS with no warranty, either express or
  3. implied.
  4. This software is distributed under license and may not be copied,
  5. modified or distributed except as expressly authorized under the terms
  6. of the license contained in the file LICENSE in this distribution.
  7. For more information about licensing, please refer to
  8. http://www.ghostscript.com/licensing/. For information on
  9. commercial licensing, go to http://www.artifex.com/licensing/ or
  10. contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  12. */
  13. /* $Id: gxpaint.c,v 1.5 2004/09/09 21:01:31 igor Exp $ */
  14. /* Graphics-state-aware fill and stroke procedures */
  15. #include "gx.h"
  16. #include "gzstate.h"
  17. #include "gxdevice.h"
  18. #include "gxhttile.h"
  19. #include "gxpaint.h"
  20. #include "gxpath.h"
  21. #include "gxfont.h"
  22. private bool caching_an_outline_font(const gs_state * pgs)
  23. {
  24. return pgs->in_cachedevice > 1 &&
  25. pgs->font != NULL &&
  26. pgs->font->FontType != ft_user_defined &&
  27. pgs->font->FontType != ft_CID_user_defined;
  28. }
  29. /* Fill a path. */
  30. int
  31. gx_fill_path(gx_path * ppath, gx_device_color * pdevc, gs_state * pgs,
  32. int rule, fixed adjust_x, fixed adjust_y)
  33. {
  34. gx_device *dev = gs_currentdevice_inline(pgs);
  35. gx_clip_path *pcpath;
  36. int code = gx_effective_clip_path(pgs, &pcpath);
  37. gx_fill_params params;
  38. if (code < 0)
  39. return code;
  40. params.rule = rule;
  41. params.adjust.x = adjust_x;
  42. params.adjust.y = adjust_y;
  43. params.flatness = (caching_an_outline_font(pgs) ? 0.0 : pgs->flatness);
  44. params.fill_zero_width = (adjust_x | adjust_y) != 0;
  45. return (*dev_proc(dev, fill_path))
  46. (dev, (const gs_imager_state *)pgs, ppath, &params, pdevc, pcpath);
  47. }
  48. /* Stroke a path for drawing or saving. */
  49. int
  50. gx_stroke_fill(gx_path * ppath, gs_state * pgs)
  51. {
  52. gx_device *dev = gs_currentdevice_inline(pgs);
  53. gx_clip_path *pcpath;
  54. int code = gx_effective_clip_path(pgs, &pcpath);
  55. gx_stroke_params params;
  56. if (code < 0)
  57. return code;
  58. params.flatness = (caching_an_outline_font(pgs) ? 0.0 : pgs->flatness);
  59. return (*dev_proc(dev, stroke_path))
  60. (dev, (const gs_imager_state *)pgs, ppath, &params,
  61. pgs->dev_color, pcpath);
  62. }
  63. int
  64. gx_stroke_add(gx_path * ppath, gx_path * to_path,
  65. const gs_state * pgs)
  66. {
  67. gx_stroke_params params;
  68. params.flatness = (caching_an_outline_font(pgs) ? 0.0 : pgs->flatness);
  69. return gx_stroke_path_only(ppath, to_path, pgs->device,
  70. (const gs_imager_state *)pgs,
  71. &params, NULL, NULL);
  72. }
  73. int
  74. gx_imager_stroke_add(gx_path *ppath, gx_path *to_path,
  75. gx_device *dev, const gs_imager_state *pis)
  76. {
  77. gx_stroke_params params;
  78. params.flatness = pis->flatness;
  79. return gx_stroke_path_only(ppath, to_path, dev, pis,
  80. &params, NULL, NULL);
  81. }