home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / sharewar / dos / program / gs300sr1 / gs300sr1.exe / DEVARCH.DOC < prev    next >
Text File  |  1994-07-27  |  14KB  |  342 lines

  1.    Copyright (C) 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.  
  20. This file, devarch.doc, contains notes about the architecture of
  21. device handling in Ghostscript.  It is intended only for developers
  22. with a fairly deep understanding of Level 2 PostScript.
  23.  
  24. For an overview of Ghostscript and a list of the documentation files, see
  25. README.
  26.  
  27. ----------------------------------------------------------------
  28.  
  29. Background
  30. ==========
  31.  
  32. PostScript language
  33. -------------------
  34.  
  35. Adobe's Level 1 PostScript specification ignored, except for a few
  36. now-obsolete operators, the possibility of a single PostScript system that
  37. had multiple hardware devices attached to it; Level 1 also did not deal, in
  38. a systematic way, with control of printing features such as page size and
  39. output finishing.  In contrast, the available Level 2 specifications (the
  40. PostScript Language Reference Manual, Second Edition, and subsequent
  41. documentation obtained from the Adobe file server describing Adobe
  42. PostScript products through PostScript version 2013) include extensive
  43. facilities in this area.
  44.  
  45. Adobe's documentation refers explicitly to three concepts of "device":
  46.  
  47.     - A physical device such as a file system, a communication port, or
  48. a printing engine.  The IODevice resource enumerates these devices without
  49. providing any other information about them.  Each IODevice may have a set
  50. of state variables specific to it; the setdevparams and currentdevparams
  51. operators control the state of individual IODevices.  (In the rest of this
  52. document, we are not concerned with IODevices.)
  53.  
  54.     - A class of destination for rendering.  The OutputDevice resource
  55. enumerates these, and gives some further information (available page sizes
  56. and resolutions).  OutputDevices do not have state.
  57.  
  58.     - An actual destination for rendering.  This may be a special
  59. destination like the null device or a cache device, a display (for which
  60. the documentation specifies no further details), or an instance of an
  61. OutputDevice.  OutputDevice instances are called "page devices".  The only
  62. directly visible, program-controlled state of an OutputDevice is the
  63. contents of the current page.  However, OutputDevices also have a very
  64. large set of optional parameters that may be set when setpagedevice creates
  65. the instance, and read by currentpagedevice; some of these parameters may
  66. change from time to time as a result of external events or conditions.  The
  67. parameters control both external hardware (e.g., duplex or collation) and
  68. internally implemented facilities such as portrait vs. landscape
  69. orientation.
  70.  
  71. Ghostscript
  72. -----------
  73.  
  74. Ghostscript generalizes the Adobe model in several areas at the level of
  75. the PostScript program.
  76.  
  77.     - In addition to hard copy devices, Ghostscript can produce output
  78. on physical displays, window systems, raster files, or RAM; a typical
  79. Ghostscript configuration supports more than one of these.  Ghostscript
  80. models this by providing new OutputDevices, and a new concept called an
  81. OutputDevice family for grouping them.
  82.  
  83.     - Ghostscript normally includes multiple drivers that can write to
  84. the same physical device (for example, multiple raster file format
  85. generators, or multiple printer drivers).  Ghostscript models this by
  86. making each driver a different OutputDevice.
  87.  
  88.     - Ghostscript explicitly makes visible the objects that represent
  89. OutputDevice instances (page devices and their display, file, and RAM
  90. analogues) as new PostScript objects of type /devicetype.
  91.  
  92. In the remainder of this document, we describe Ghostscript's handling of
  93. devices from four viewpoints: that of an ordinary PostScript program, that
  94. of the Ghostscript implementation at the PostScript level, that of the
  95. Ghostscript implementation at the C level, and that of the Ghostscript
  96. device driver.
  97.  
  98. PostScript programs
  99. ===================
  100.  
  101. OutputDevice resource
  102. ---------------------
  103.  
  104. The OutputDevice resource is described in Adobe documentation as having
  105. been added in Adobe interpreter version 2011.  Briefly, the resource names
  106. are the same as the allowed values of the /OutputDevice page device
  107. parameter, and the resource values are dictionaries giving properties of
  108. the output device.  The defined properties as of version 2012 are
  109. HWResolution, ManualSize, and PageSize.
  110.  
  111. Ghostscript provides one OutputDevice for each available driver.  This
  112. includes file formats (e.g., /gifmono) and display or window systems (e.g.,
  113. /x11) as well as printer types (e.g., /ljet3).  It provides a special
  114. OutputDevice called /RAM whose instances simply accumulate a bitmap in RAM
  115. for later readout.  In addition, if the available drivers include any
  116. printer, fax, or display driver, Ghostscript provides OutputDevice entries
  117. called /Printer, /Fax, and /Display respectively that are aliases for the
  118. default driver in the respective family.  (There is nothing special about
  119. these three names.  Any driver can declare that it belongs to a particular
  120. family, and the driver of any given family that appears earliest in the
  121. build list becomes the default driver with that family name.)  Finally,
  122. Ghostscript always provides an OutputDevice called /Default that is an
  123. alias for the default OutputDevice (the one used if setpagedevice is
  124. invoked with no current page device and no OutputDevice key in the
  125. parameter dictionary).
  126.  
  127. Operators
  128. ---------
  129.  
  130. Ghostscript provides the setpagedevice and currentpagedevice operators, as
  131. required by the Level 2 PostScript specifications.  Ghostscript also
  132. provides a few other operators that implement increased functionality.
  133.  
  134. <int> .indexdevicename <outdevname>
  135.  
  136.     Returns the name of the int'th driver in the build list.  The first
  137. driver is numbered 0.
  138.  
  139. <outdevname> .selectdevice
  140.  
  141.     Creates and makes current a default instance of a given
  142. OutputDevice.
  143.  
  144. - .currentdevice <device>
  145.  
  146.     Returns the current device, which may be a page device or a special
  147. device.
  148.  
  149. <outdevname> .getoutputparams <mark> <name1> <value1> ... <nameN> <valueN>
  150.  
  151.     Returns the parameters of a default instance of the given
  152. OutputDevice.  Also returns the information for the OutputDevice resource
  153. dictionary.
  154.  
  155. <device> .getoutputparams <mark> <name1> <value1> ... <nameN> <valueN>
  156.  
  157.     Returns the parameters of a given device.
  158.  
  159. Page device parameters
  160. ----------------------
  161.  
  162. Most of the page device parameters documented by Adobe (either in the New
  163. Red Book or in the post-Book notes) are specific to particular devices.
  164. Ghostscript leaves these up to the device driver to process, and only
  165. provides the Policies and PolicyReport mechanism to handle those that are
  166. unknown or out of range.  Here are the parameters documented by Adobe that
  167. Ghostscript knows about specifically:
  168.  
  169.     BeginPage, EndPage, Install - per Red Book documentation.
  170.  
  171.     Policies - per Red Book documentation.  The PageSize policy value
  172.     of 7 (in later documentation) is not supported.
  173.  
  174.     HWResolution, Margins, PageSize - per Red Book documentation.
  175.     Margins are given in device-specific units, per later
  176.     documentation.
  177.  
  178.     OutputDevice - per later documentation.
  179.  
  180.     InputAttributes, OutputAttributes - per Red Book documentation.
  181.     The feature whereby if InputAttributes is null, the interpreter
  182.     consults the driver directly for media selection (per later
  183.     documentation) is not implemented.
  184.  
  185.     Orientation - per Red Book documentation, also supported for RAM
  186.     and display devices.  We aren't sure yet how Orientation will
  187.     affect raster file output devices.
  188.  
  189.     ProcessColorModel - per later documentation, but read-only for
  190.     all but RAM devices.  For RAM devices, only DeviceGray,
  191.     DeviceRGB, and DeviceCMYK are supported.
  192.  
  193.     InsertSheet, OutputPage, SeparationColorNames, SeparationOrder -
  194.     not currently supported.
  195.  
  196.     Collate and the concept of a "set" - not currently supported.
  197.  
  198. Ghostscript also implements the following parameters that are not
  199. documented by Adobe:
  200.  
  201.     .HWBitsPerPixel - the number of bits per pixel, an integer between 1
  202.     and 32.  This is read-only for all but RAM devices and a few file
  203.     formats.
  204.  
  205.     GrayValues, RedValues, GreenValues, BlueValues, ColorValues -
  206.     as defined by Adobe for the deviceinfo operator.  These are
  207.     read-only for all but RAM devices and a few file formats.
  208.  
  209.     .HWGrayMap, .HWRedMap, .HWGreenMap, .HWBlueMap, .HWColorMap -
  210.     the maps of the realizable device colors.  Each map is a string of
  211.     M x xxxValues bytes; each entry is M bytes, where M = 1 for the
  212.     first 4 maps and 1, 3, or 4 bytes according to the
  213.     ProcessColorModel for HWColorMap.  (I.e., the maps are like the
  214.     lookup table for an Indexed color space.)  If a map is missing, the
  215.     realizable colors are 0, 1/N, ..., 1, where N is xxxValues-1.
  216.     The Map parameters are read-only for all but RAM devices and a few
  217.     file formats.  Also, the strings returned are themselves always
  218.     read-only; the only way to change a Map is to set the parameter.
  219.  
  220.     MaxRasterMemory - the maximum amount of RAM that can be allocated
  221.     for raster memory.  This is a constraint in addition to that
  222.     imposed by the MaxRasterMemory system parameter.
  223.  
  224.     .PageCount - the number of times that the EndPage routine of this
  225.     page device returned true.  Normally, this is the same as the
  226.     number of executions of showpage or copypage.
  227.  
  228.     .ShowpageCount - the number of times that showpage was executed
  229.     with this page device; this is the value supplied to the BeginPage
  230.     and EndPage procedures.
  231.  
  232. All other documented page device parameters, including Details
  233. dictionaries, are simply passed to the driver.
  234.  
  235. Implementation - PostScript level
  236. =================================
  237.  
  238. Operators
  239. ---------
  240.  
  241. <device> .setdevice -
  242.  
  243.     Sets the current device without doing of the things required by
  244. setpagedevice.
  245.  
  246. Implementation - C level
  247. ========================
  248.  
  249. Driver interface
  250. ================
  251.  
  252. Appendix: Relationship to older Ghostscript versions
  253. ====================================================
  254.  
  255. Operators
  256. ---------
  257.  
  258. Previous Ghostscript versions provided a set of device handling operators
  259. that were designed before the newer Adobe specifications were available.
  260. We now indicate how these map to newer facilities.
  261.  
  262. .getdevice
  263.     This low-level operator, renamed .indexdevice, still exists to
  264. allow enumerating the output devices.  The standard way to enumerate
  265. OutputDevices is now (*) {...} /OutputDevice resourceforall.
  266.  
  267. selectdevice
  268.     This has been renamed .selectdevice, in keeping with Ghostscript
  269. practice of preceding all Ghostscript-specific operators with a dot.
  270. /outdevname selectdevice is essentially the same as << /OutputDevice
  271. /outdevname >> setpagedevice.
  272.  
  273. currentdevice
  274.     This has been renamed .currentdevice.
  275.  
  276. setdevice
  277.     We aren't sure what will happen to this.
  278.  
  279. copydevice
  280.     This is essentially equivalent to
  281.         gsave .setdevice << >> setpagedevice
  282.           .currentdevice grestore
  283. since setpagedevice always creates a new device.
  284.  
  285. getdeviceprops
  286.     Renamed .getoutputparams.
  287.  
  288. devicename
  289.     This can be implemented using .getoutputparams.
  290.  
  291. deviceinitialmatrix
  292.     This can be determined by selecting the device and then reading out
  293. the defaultmatrix.
  294.  
  295. putdeviceprops
  296.     This has been renamed .putoutputparams.  Its status in the new
  297. scheme of things, like the status of setdevice, is unclear.
  298.  
  299. makeimagedevice
  300.     Replaced by setpagedevice with << /OutputDevice /RAM >>.  The
  301. matrix, width, height, and palette arguments are replaced by parameters in
  302. the device dictionary.  The default matrix is the identity matrix, the
  303. default width and height are 0, the default depth is 1, and the default
  304. palette is <ff 00>.
  305.  
  306. copyscanlines
  307.     We aren't sure whether to retain this or to replace it with an
  308. .imagefilter operator that provides a stream to read out the bits of a
  309. memory device.
  310.  
  311. Page device parameters
  312. ----------------------
  313.  
  314. Previous Ghostscript versions had a concept of "device properties", which
  315. correspond to configuration parameters in the current architecture.  Here
  316. we list the correspondence between former Ghostscript device properties and
  317. current Ghostscript parameters.
  318.  
  319.     Prior Ghostscript        Current Ghostscript
  320.     -----------------        -------------------
  321.  
  322. Size and shape:
  323.  
  324.     InitialMatrix            Margins, Orientation, Install
  325.  
  326. Color:
  327.  
  328.     Colors                [color]Values
  329.  
  330.     HWColorMap            HW[color]Map
  331.  
  332. Other:
  333.  
  334.     Name                OutputDevice
  335.  
  336.     BufferSpace, MaxBitmap        MaxRasterMemory
  337.  
  338. Orientation, HWResolution, and Margins, together with the ability of the
  339. Install procedure to set the default CTM, are sufficient to specify all
  340. possible legal values of the initial transformation matrix.  ****** Not
  341. sufficient to handle an inverted Y axis.
  342.