home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / sharewar / dos / program / gs300sr1 / gs300sr1.exe / GXPCOLOR.H < prev    next >
C/C++ Source or Header  |  1994-07-27  |  5KB  |  113 lines

  1. /* Copyright (C) 1993 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gxpcolor.h */
  20. /* Internal definitions for Pattern colors */
  21. /* Requires gxdevice.h, gxdevmem.h, gxcolor2.h, gxdcolor.h */
  22.  
  23. /*
  24.  * Define the Pattern device color types.  There is one type for
  25.  * colored patterns, and one uncolored pattern type for each non-Pattern
  26.  * device color type.
  27.  */
  28. extern const gx_device_color_procs
  29.     gx_dc_pattern, gx_dc_pure_masked,
  30.     gx_dc_binary_masked, gx_dc_colored_masked;
  31.  
  32. /*
  33.  * Define a color tile, an entry in the rendered Pattern cache (and
  34.  * eventually in the colored halftone cache).  Note that the depth is
  35.  * not sufficient to ensure that the rendering matches a given device;
  36.  * however, we don't currently have an object that represents the
  37.  * abstraction of a 'color representation'.
  38.  */
  39. struct gx_color_tile_s {
  40.         /* The following are the 'key' in the cache. */
  41.     gx_bitmap_id id;
  42.     int depth;
  43.         /* The following are the 'value'. */
  44.     gx_tile_bitmap bits;        /* data = 0 if uncolored */
  45.     gx_tile_bitmap mask;        /* data = 0 if no mask */
  46.     /* XStep and YStep will appear here eventually. */
  47. };
  48. #define private_st_color_tile()    /* in gxpcmap.c */\
  49.   gs_private_st_ptrs2(st_color_tile, gx_color_tile, "gx_color_tile",\
  50.     color_tile_enum_ptrs, color_tile_reloc_ptrs, bits.data, mask.data)
  51. #define private_st_color_tile_element()    /* in gxpcmap.c */\
  52.   gs_private_st_element(st_color_tile_element, gx_color_tile,\
  53.     "gx_color_tile[]", color_tile_elt_enum_ptrs, color_tile_elt_reloc_ptrs,\
  54.     st_color_tile)
  55.  
  56. /*
  57.  * Define a cache for rendered Patterns.  This is currently an open
  58.  * hash table with linear reprobing and round-robin replacement.
  59.  * Obviously, we can do better in both areas.
  60.  */
  61. typedef struct gx_pattern_cache_s {
  62.     gs_memory_t *memory;
  63.     gx_color_tile *tiles;
  64.     uint num_tiles;
  65.     uint tiles_used;
  66.     uint next;        /* round-robin index */
  67.     ulong bits_used;
  68.     ulong max_bits;
  69. } gx_pattern_cache;
  70. #define private_st_pattern_cache() /* in gxpcmap.c */\
  71.   gs_private_st_ptrs1(st_pattern_cache, gx_pattern_cache,\
  72.     "gx_pattern_cache", pattern_cache_enum, pattern_cache_reloc, tiles)
  73.  
  74. /* Allocate a Pattern cache. */
  75. extern const uint pattern_cache_default_max_tiles;
  76. extern const ulong pattern_cache_default_max_bits;
  77. gx_pattern_cache *gx_pattern_alloc_cache(P3(gs_memory_t *, uint, ulong));
  78.  
  79. /* Get or set the Pattern cache in a gstate. */
  80. gx_pattern_cache *gstate_pattern_cache(P1(gs_state *));
  81. void gstate_set_pattern_cache(P2(gs_state *, gx_pattern_cache *));
  82.  
  83. /*
  84.  * Define a device for accumulating the rendering of a Pattern.
  85.  * This is actually a wrapper for two other devices: one that accumulates
  86.  * the actual pattern image (if this is a colored pattern), and one that
  87.  * accumulates a mask defining which pixels in the image are set.
  88.  */
  89. typedef struct gx_device_pattern_accum_s {
  90.     gx_device_forward_common;
  91.         /* Client sets these before opening */
  92.     gs_memory_t *bitmap_memory;
  93.     const gs_pattern_instance *instance;
  94.         /* open sets these */
  95.     gx_device_memory *bits;        /* target also points to bits */
  96.     gx_device_memory *mask;
  97. } gx_device_pattern_accum;
  98. #define private_st_device_pattern_accum() /* in gxpcmap.c */\
  99.   gs_private_st_suffix_add3(st_device_pattern_accum, gx_device_pattern_accum,\
  100.     "pattern accumulator", pattern_accum_enum, pattern_accum_reloc,\
  101.     (*st_device_forward.enum_ptrs), (*st_device_forward.reloc_ptrs),\
  102.     instance, bits, mask)
  103.  
  104. /* Allocate a pattern accumulator. */
  105. gx_device_pattern_accum *gx_pattern_accum_alloc(P2(gs_memory_t *memory, client_name_t));
  106.  
  107. /* Add an accumulated pattern to the cache. */
  108. int gx_pattern_cache_add_entry(P3(gs_state *, gx_device_pattern_accum *,
  109.   gx_color_tile **));
  110.  
  111. /* Look up a pattern color in the cache. */
  112. bool gx_pattern_cache_lookup(P2(gx_device_color *, const gs_state *));
  113.