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

  1. /* Copyright (C) 1989, 1992, 1993, 1994 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. /* igstate.h */
  20. /* Ghostscript interpreter graphics state definition */
  21. #include "gsstate.h"
  22. #include "gsstruct.h"            /* for extern_st */
  23.  
  24. /*
  25.  * From the interpreter's point of view, the graphics state is largely opaque,
  26.  * i.e., the interpreter is just another client of the library.
  27.  * The interpreter does require additional items in the graphics state;
  28.  * these are "client data" from the library's point of view.
  29.  * Most of the complexity in this added state comes from
  30.  * the parameters associated with the various Level 2 color spaces.
  31.  * Note that the added information consists entirely of refs.
  32.  */
  33.  
  34. /*
  35.  * The interpreter represents graphics state objects in the natural way,
  36.  * namely, by t_astruct refs of type st_gstate.  Because a number of
  37.  * different modules must test whether objects are of this type,
  38.  * we make an exception to our convention of declaring structure
  39.  * descriptors only in the place where the structure itself is defined
  40.  * (see gsstruct.h for more information on this).
  41.  */
  42. extern_st(st_gstate);
  43.  
  44. /* CIE transformation procedures */
  45. typedef struct ref_cie_procs_s {
  46.     union {
  47.         ref ABC;
  48.         ref A;
  49.     } Decode;
  50.     ref DecodeLMN;
  51. } ref_cie_procs;
  52. /* CIE rendering transformation procedures */
  53. typedef struct ref_cie_render_procs_s {
  54.     ref TransformPQR, EncodeLMN, EncodeABC, RenderTableT;
  55. } ref_cie_render_procs;
  56.  
  57. /* Separation name and tint transform */
  58. typedef struct ref_separation_params_s {
  59.     ref layer_name, tint_transform;
  60. } ref_separation_params;
  61.  
  62. /* All color space parameters. */
  63. /* All of these are optional. */
  64. /* Note that they may actually be the parameters for an underlying or */
  65. /* alternate space for a special space. */
  66. typedef struct ref_color_procs_s {
  67.     ref_cie_procs cie;
  68.     union {
  69.         ref_separation_params separation;
  70.         ref index_proc;
  71.     } special;
  72. } ref_color_procs;
  73. typedef struct ref_colorspace_s {
  74.     ref array;        /* color space (array), */
  75.         /* only relevant if the current */
  76.         /* color space has parameters associated with it. */
  77.     ref_color_procs procs;    /* associated procedures/parameters, */
  78.         /* only relevant for CIE, Separation, Indexed/CIE, */
  79.         /* Indexed with procedure, or a Pattern with one of these. */
  80. } ref_colorspace;
  81.  
  82. typedef struct int_gstate_s {
  83.     ref dash_pattern;        /* (array) */
  84.         /* Screen_procs are only relevant if setscreen was */
  85.         /* executed more recently than sethalftone */
  86.         /* (for this graphics context). */
  87.     union {
  88.         ref indexed[4];
  89.         struct {
  90.             ref red, green, blue, gray;
  91.         } colored;
  92.     } screen_procs,            /* halftone screen procedures */
  93.       transfer_procs;        /* transfer procedures */
  94.     ref black_generation;        /* (procedure) */
  95.     ref undercolor_removal;        /* (procedure) */
  96.     ref_colorspace colorspace;
  97.         /* Pattern is only relevant if the current color space */
  98.         /* is a pattern space. */
  99.     ref pattern;            /* pattern (dictionary) */
  100.     struct {
  101.         ref dict;        /* CIE color rendering dictionary */
  102.         ref_cie_render_procs procs;    /* (see above) */
  103.     } colorrendering;
  104.         /* Halftone is only relevant if sethalftone was executed */
  105.         /* more recently than setscreen for this graphics context. */
  106.         /* setscreen sets it to null. */
  107.     ref halftone;            /* halftone (dictionary) */
  108.         /* Pagedevice is only relevant if setpagedevice was */
  109.         /* executed more recently than nulldevice, setcachedevice, */
  110.         /* or setdevice with a non-page device (for this */
  111.         /* graphics context).  If irrelevant, it may be null. */
  112.     ref pagedevice;            /* page device (dictionary) */
  113. } int_gstate;
  114. /*
  115.  * Even though the interpreter's part of the graphics state actually
  116.  * consists of refs, allocating it as refs tends to create sandbars;
  117.  * since it is always allocated and freed as a unit, we can treat it
  118.  * as an ordinary structure.
  119.  */
  120. #define private_st_int_gstate()    /* in zgstate.c */\
  121.   gs_private_st_ref_struct(st_int_gstate, int_gstate, "int_gstate")
  122.  
  123. /* Enumerate the refs in an int_gstate. */
  124. /* Since all the elements of an int_gstate are refs, this is simple. */
  125. #define int_gstate_map_refs(p,m)\
  126.  { register ref *rp_ = (ref *)(p);\
  127.    register int i = sizeof(int_gstate) / sizeof(ref);\
  128.    do { m(rp_); ++rp_; } while ( --i );\
  129.  }
  130.  
  131. /* Get the int_gstate from a gs_state. */
  132. #define gs_int_gstate(pgs) ((int_gstate *)gs_state_client_data_inline(pgs))
  133.  
  134. /* The current instances. */
  135. extern gs_state *igs;
  136. #define istate gs_int_gstate(igs)
  137.