gxdevcli.h 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  1. /* Copyright (C) 1997, 2000 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: gxdevcli.h,v 1.5.2.1 2002/01/25 06:33:09 rayjj Exp $ */
  16. /* Definitions for device clients */
  17. #ifndef gxdevcli_INCLUDED
  18. # define gxdevcli_INCLUDED
  19. #include "std.h" /* for FILE */
  20. #include "gscompt.h"
  21. #include "gsdcolor.h"
  22. #include "gsmatrix.h"
  23. #include "gsiparam.h" /* requires gsmatrix.h */
  24. #include "gsrefct.h"
  25. #include "gsropt.h"
  26. #include "gsstruct.h"
  27. #include "gstparam.h"
  28. #include "gsxfont.h"
  29. #include "gxbitmap.h"
  30. #include "gxcindex.h"
  31. #include "gxcvalue.h"
  32. #include "gxfixed.h"
  33. #include "gxtext.h"
  34. /* See Drivers.htm for documentation of the driver interface. */
  35. #ifndef gx_device_DEFINED
  36. # define gx_device_DEFINED
  37. typedef struct gx_device_s gx_device;
  38. #endif
  39. /* ---------------- Memory management ---------------- */
  40. /*
  41. * NOTE: if you write code that creates device instances (either with
  42. * gs_copydevice or by allocating them explicitly), allocates device
  43. * instances as either local or static variables (actual instances, not
  44. * pointers to instances), or sets the target of forwarding devices, please
  45. * read the following documentation carefully. The rules for doing these
  46. * things changed substantially in release 5.68, in a
  47. * non-backward-compatible way, and unfortunately we could not find a way to
  48. * make the compiler give an error at places that need changing.
  49. */
  50. /*
  51. * Device instances are managed with reference counting: when the last
  52. * reference to a device from a graphics state or the target field of a
  53. * forwarding device is removed, the device is normally freed. However,
  54. * some device instances are referenced in other ways (for example, from
  55. * objects in the PostScript interpreter, or from library client code) and
  56. * will be freed by the garbage collector (if any) or explicitly: they
  57. * should not be freed by reference counting. These are called "retained"
  58. * device instances. Every device instance remembers whether or not it is
  59. * retained, and an instance is freed iff its reference count is zero and it
  60. * is not retained.
  61. *
  62. * Normally devices are initialized as not retained. However, devices
  63. * initialized by calling gx_device_init(pdev, proto, memory, false), or
  64. * created by gs_copydevice are marked as retained. You can also set the
  65. * retention status of a device explicitly with gx_device_retain(pdev,
  66. * true-or-false). Note that if you change a retained device to
  67. * non-retained, if there are no references to it from graphics states or
  68. * targets, it will be freed immediately.
  69. *
  70. * The preferred technique for creating a new device is now gs_copydevice.
  71. * There are a number of places in the code where memory is explicitly
  72. * allocated, then initialized with gx_device_init. These should gradually
  73. * be replaced.
  74. *
  75. * There are 3 ways that a device structure might be allocated:
  76. * 1) Allocated dynamically, e.g.,
  77. * gx_device *pdev_new;
  78. * gs_copydevice(&pdev_new, pdev_old, memory);
  79. * 2) Declared as a local or static variable, e.g.,
  80. * gx_device devv;
  81. * or
  82. * const gx_device devc = ...;
  83. * 3) Embedded in an object allocated in one of the above ways.
  84. * If you allocate a device using #2 or #3, you must either mark it as
  85. * retained by calling gx_device_retain(pdev, true) or initialize it with a
  86. * NULL memory. If you do not do this, an attempt will be made to free the
  87. * device, corrupting memory. Note that when memory is NULL, the finalize
  88. * method of the device will not be called when it is freed, so you cannot
  89. * use it for cleanup. */
  90. /*
  91. * Do not set the target of a forwarding device with an assignment like
  92. * fdev->target = tdev;
  93. * You must use the procedure
  94. * gx_device_set_target(fdev, tdev);
  95. * Note that the first argument is a gx_device_forward *, not a gx_device *.
  96. *
  97. * We could have changed the member name "target" when this became
  98. * necessary, so the compiler would flag places that needed editing, but
  99. * there were literally hundreds of places that only read the target member
  100. * that we would have had to change, so we decided to leave the name alone.
  101. */
  102. /* ---------------- Auxiliary types and structures ---------------- */
  103. /* We need at least an abstract type for a graphics state, */
  104. /* which is passed to the page device procedures. */
  105. #ifndef gs_state_DEFINED
  106. # define gs_state_DEFINED
  107. typedef struct gs_state_s gs_state;
  108. #endif
  109. /* We need abstract types for paths and fill/stroke parameters, */
  110. /* for the path-oriented device procedures. */
  111. #ifndef gx_path_DEFINED
  112. # define gx_path_DEFINED
  113. typedef struct gx_path_s gx_path;
  114. #endif
  115. #ifndef gx_clip_path_DEFINED
  116. # define gx_clip_path_DEFINED
  117. typedef struct gx_clip_path_s gx_clip_path;
  118. #endif
  119. #ifndef gx_fill_params_DEFINED
  120. # define gx_fill_params_DEFINED
  121. typedef struct gx_fill_params_s gx_fill_params;
  122. #endif
  123. #ifndef gx_stroke_params_DEFINED
  124. # define gx_stroke_params_DEFINED
  125. typedef struct gx_stroke_params_s gx_stroke_params;
  126. #endif
  127. #ifndef gs_imager_state_DEFINED
  128. # define gs_imager_state_DEFINED
  129. typedef struct gs_imager_state_s gs_imager_state;
  130. #endif
  131. /* We need an abstract type for the image enumeration state, */
  132. /* for begin[_typed]_image. */
  133. #ifndef gx_image_enum_common_t_DEFINED
  134. # define gx_image_enum_common_t_DEFINED
  135. typedef struct gx_image_enum_common_s gx_image_enum_common_t;
  136. #endif
  137. /* Define the type for colors passed to the higher-level procedures. */
  138. typedef gx_device_color gx_drawing_color;
  139. /* Define a type for telling get_alpha_bits what kind of object */
  140. /* is being rendered. */
  141. typedef enum {
  142. go_text,
  143. go_graphics
  144. } graphics_object_type;
  145. /* Define an edge of a trapezoid. Requirement: end.y >= start.y. */
  146. typedef struct gs_fixed_edge_s {
  147. gs_fixed_point start;
  148. gs_fixed_point end;
  149. } gs_fixed_edge;
  150. /* Define the parameters passed to get_bits_rectangle. */
  151. #ifndef gs_get_bits_params_DEFINED
  152. # define gs_get_bits_params_DEFINED
  153. typedef struct gs_get_bits_params_s gs_get_bits_params_t;
  154. #endif
  155. /* Define the structure for device color capabilities. */
  156. typedef struct gx_device_anti_alias_info_s {
  157. int text_bits; /* 1,2,4 */
  158. int graphics_bits; /* ditto */
  159. } gx_device_anti_alias_info;
  160. typedef struct gx_device_color_info_s {
  161. int num_components; /* doesn't include alpha: */
  162. /* 0 = alpha only, 1 = gray only, */
  163. /* 3 = RGB, 4 = CMYK */
  164. int depth; /* # of bits per pixel */
  165. gx_color_value max_gray; /* # of distinct gray levels -1 */
  166. gx_color_value max_color; /* # of distinct color levels -1 */
  167. /* (only relevant if num_comp. > 1) */
  168. gx_color_value dither_grays; /* size of gray ramp for dithering */
  169. gx_color_value dither_colors; /* size of color cube ditto */
  170. /* (only relevant if num_comp. > 1) */
  171. gx_device_anti_alias_info anti_alias;
  172. } gx_device_color_info;
  173. #define dci_alpha_values(nc,depth,mg,mc,dg,dc,ta,ga)\
  174. { nc, depth, mg, mc, dg, dc, { ta, ga } }
  175. #define dci_values(nc,depth,mg,mc,dg,dc)\
  176. dci_alpha_values(nc, depth, mg, mc, dg, dc, 1, 1)
  177. #define dci_std_color(color_bits)\
  178. dci_values(\
  179. (color_bits == 32 ? 4 : color_bits > 1 ? 3 : 1),\
  180. ((color_bits > 1) & (color_bits < 8) ? 8 : color_bits),\
  181. (color_bits >= 8 ? 255 : 1),\
  182. (color_bits >= 8 ? 255 : color_bits > 1 ? 1 : 0),\
  183. (color_bits >= 8 ? 5 : 2),\
  184. (color_bits >= 8 ? 5 : color_bits > 1 ? 2 : 0)\
  185. )
  186. #define dci_black_and_white dci_std_color(1)
  187. #define dci_black_and_white_() dci_black_and_white
  188. #define dci_color(depth,maxv,dither)\
  189. dci_values(3, depth, maxv, maxv, dither, dither)
  190. #define gx_device_has_color(dev) ((dev)->color_info.num_components > 1)
  191. /* Structure for device procedures. */
  192. typedef struct gx_device_procs_s gx_device_procs;
  193. /* Structure for page device procedures. */
  194. /* Note that these take the graphics state as a parameter. */
  195. typedef struct gx_page_device_procs_s {
  196. #define dev_page_proc_install(proc)\
  197. int proc(P2(gx_device *dev, gs_state *pgs))
  198. dev_page_proc_install((*install));
  199. #define dev_page_proc_begin_page(proc)\
  200. int proc(P2(gx_device *dev, gs_state *pgs))
  201. dev_page_proc_begin_page((*begin_page));
  202. #define dev_page_proc_end_page(proc)\
  203. int proc(P3(gx_device *dev, int reason, gs_state *pgs))
  204. dev_page_proc_end_page((*end_page));
  205. } gx_page_device_procs;
  206. /* Default procedures */
  207. dev_page_proc_install(gx_default_install);
  208. dev_page_proc_begin_page(gx_default_begin_page);
  209. dev_page_proc_end_page(gx_default_end_page);
  210. /* ---------------- Device structure ---------------- */
  211. /*
  212. * Define the generic device structure. The device procedures can
  213. * have two different configurations:
  214. *
  215. * - Statically initialized devices predating release 2.8.1
  216. * set the static_procs pointer to point to a separate procedure record,
  217. * and do not initialize procs.
  218. *
  219. * - Statically initialized devices starting with release 2.8.1,
  220. * and all dynamically created device instances,
  221. * set the static_procs pointer to 0, and initialize procs.
  222. *
  223. * The gx_device_set_procs procedure converts the first of these to
  224. * the second, which is what all client code starting in 2.8.1 expects
  225. * (using the procs record, not the static_procs pointer, to call the
  226. * driver procedures).
  227. *
  228. * The choice of the name Margins (rather than, say, HWOffset), and the
  229. * specification in terms of a default device resolution rather than
  230. * 1/72" units, are due to Adobe.
  231. *
  232. * ****** NOTE: If you define any subclasses of gx_device, you *must* define
  233. * ****** the finalization procedure as gx_device_finalize. Finalization
  234. * ****** procedures are not automatically inherited.
  235. */
  236. typedef struct gx_device_cached_colors_s {
  237. gx_color_index black, white;
  238. } gx_device_cached_colors_t;
  239. #define gx_device_common\
  240. int params_size; /* OBSOLETE if stype != 0: */\
  241. /* size of this structure */\
  242. const gx_device_procs *static_procs; /* OBSOLETE */\
  243. /* pointer to procs */\
  244. const char *dname; /* the device name */\
  245. gs_memory_t *memory; /* (0 iff static prototype) */\
  246. gs_memory_type_ptr_t stype; /* memory manager structure type, */\
  247. /* may be 0 if static prototype */\
  248. bool stype_is_dynamic; /* if true, free the stype when */\
  249. /* freeing the device */\
  250. void (*finalize)(P1(gx_device *)); /* finalization to execute */\
  251. /* before closing device, if any */\
  252. rc_header rc; /* reference count from gstates */\
  253. /* and targets, +1 if retained */\
  254. bool retained; /* true if retained */\
  255. bool is_open; /* true if device has been opened */\
  256. int max_fill_band; /* limit on band size for fill, */\
  257. /* must be 0 or a power of 2 */\
  258. /* (see gdevabuf.c for more info) */\
  259. gx_device_color_info color_info; /* color information */\
  260. gx_device_cached_colors_t cached_colors;\
  261. int width; /* width in pixels */\
  262. int height; /* height in pixels */\
  263. float MediaSize[2]; /* media dimensions in points */\
  264. float ImagingBBox[4]; /* imageable region in points */\
  265. bool ImagingBBox_set;\
  266. float HWResolution[2]; /* resolution, dots per inch */\
  267. float MarginsHWResolution[2]; /* resolution for Margins */\
  268. float Margins[2]; /* offset of physical page corner */\
  269. /* from device coordinate (0,0), */\
  270. /* in units given by MarginsHWResolution */\
  271. float HWMargins[4]; /* margins around imageable area, */\
  272. /* in default user units ("points") */\
  273. long PageCount; /* number of pages written */\
  274. long ShowpageCount; /* number of calls on showpage */\
  275. int NumCopies;\
  276. bool NumCopies_set;\
  277. bool IgnoreNumCopies; /* if true, force num_copies = 1 */\
  278. bool UseCIEColor; /* for PS LL3 */\
  279. bool LockSafetyParams; /* If true, prevent unsafe changes */\
  280. gx_page_device_procs page_procs; /* must be last */\
  281. /* end of std_device_body */\
  282. gx_device_procs procs /* object procedures */
  283. /*
  284. * Note: x/y_pixels_per_inch are here only for backward compatibility.
  285. * They should not be used in new code.
  286. */
  287. #define x_pixels_per_inch HWResolution[0]
  288. #define y_pixels_per_inch HWResolution[1]
  289. #define offset_margin_values(x, y, left, bot, right, top)\
  290. {x, y}, {left, bot, right, top}
  291. #define margin_values(left, bot, right, top)\
  292. offset_margin_values(0, 0, left, bot, right, top)
  293. #define no_margins margin_values(0, 0, 0, 0)
  294. #define no_margins_() no_margins
  295. /* Define macros that give the page offset ("Margins") in inches. */
  296. #define dev_x_offset(dev) ((dev)->Margins[0] / (dev)->MarginsHWResolution[0])
  297. #define dev_y_offset(dev) ((dev)->Margins[1] / (dev)->MarginsHWResolution[1])
  298. #define dev_y_offset_points(dev) (dev_y_offset(dev) * 72.0)
  299. /* Note that left/right/top/bottom are defined relative to */
  300. /* the physical paper, not the coordinate system. */
  301. /* For backward compatibility, we define macros that give */
  302. /* the margins in inches. */
  303. #define dev_l_margin(dev) ((dev)->HWMargins[0] / 72.0)
  304. #define dev_b_margin(dev) ((dev)->HWMargins[1] / 72.0)
  305. #define dev_b_margin_points(dev) ((dev)->HWMargins[1])
  306. #define dev_r_margin(dev) ((dev)->HWMargins[2] / 72.0)
  307. #define dev_t_margin(dev) ((dev)->HWMargins[3] / 72.0)
  308. #define dev_t_margin_points(dev) ((dev)->HWMargins[3])
  309. /* The extra () are to prevent premature expansion. */
  310. #define open_init_closed() 0 /*false*/, 0 /* max_fill_band */
  311. #define open_init_open() 1 /*true*/, 0 /* max_fill_band */
  312. /* Accessors for device procedures */
  313. #define dev_proc(dev, p) ((dev)->procs.p)
  314. #define set_dev_proc(dev, p, proc) ((dev)->procs.p = (proc))
  315. #define fill_dev_proc(dev, p, dproc)\
  316. if ( dev_proc(dev, p) == 0 ) set_dev_proc(dev, p, dproc)
  317. #define assign_dev_procs(todev, fromdev)\
  318. ((todev)->procs = (fromdev)->procs)
  319. /* ---------------- Device procedures ---------------- */
  320. /* Define an opaque type for parameter lists. */
  321. #ifndef gs_param_list_DEFINED
  322. # define gs_param_list_DEFINED
  323. typedef struct gs_param_list_s gs_param_list;
  324. #endif
  325. /*
  326. * Definition of device procedures.
  327. * Note that the gx_device * argument is not declared const,
  328. * because many drivers maintain dynamic state in the device structure.
  329. * Note also that the structure is defined as a template, so that
  330. * we can instantiate it with device subclasses.
  331. * Because C doesn't have real templates, we must do this with macros.
  332. */
  333. /* Define macros for declaring device procedures. */
  334. #define dev_t_proc_open_device(proc, dev_t)\
  335. int proc(P1(dev_t *dev))
  336. #define dev_proc_open_device(proc)\
  337. dev_t_proc_open_device(proc, gx_device)
  338. #define dev_t_proc_get_initial_matrix(proc, dev_t)\
  339. void proc(P2(dev_t *dev, gs_matrix *pmat))
  340. #define dev_proc_get_initial_matrix(proc)\
  341. dev_t_proc_get_initial_matrix(proc, gx_device)
  342. #define dev_t_proc_sync_output(proc, dev_t)\
  343. int proc(P1(dev_t *dev))
  344. #define dev_proc_sync_output(proc)\
  345. dev_t_proc_sync_output(proc, gx_device)
  346. #define dev_t_proc_output_page(proc, dev_t)\
  347. int proc(P3(dev_t *dev, int num_copies, int flush))
  348. #define dev_proc_output_page(proc)\
  349. dev_t_proc_output_page(proc, gx_device)
  350. #define dev_t_proc_close_device(proc, dev_t)\
  351. int proc(P1(dev_t *dev))
  352. #define dev_proc_close_device(proc)\
  353. dev_t_proc_close_device(proc, gx_device)
  354. #define dev_t_proc_map_rgb_color(proc, dev_t)\
  355. gx_color_index proc(P4(dev_t *dev,\
  356. gx_color_value red, gx_color_value green, gx_color_value blue))
  357. #define dev_proc_map_rgb_color(proc)\
  358. dev_t_proc_map_rgb_color(proc, gx_device)
  359. #define dev_t_proc_map_color_rgb(proc, dev_t)\
  360. int proc(P3(dev_t *dev,\
  361. gx_color_index color, gx_color_value rgb[3]))
  362. #define dev_proc_map_color_rgb(proc)\
  363. dev_t_proc_map_color_rgb(proc, gx_device)
  364. #define dev_t_proc_fill_rectangle(proc, dev_t)\
  365. int proc(P6(dev_t *dev,\
  366. int x, int y, int width, int height, gx_color_index color))
  367. #define dev_proc_fill_rectangle(proc)\
  368. dev_t_proc_fill_rectangle(proc, gx_device)
  369. #define dev_t_proc_tile_rectangle(proc, dev_t)\
  370. int proc(P10(dev_t *dev,\
  371. const gx_tile_bitmap *tile, int x, int y, int width, int height,\
  372. gx_color_index color0, gx_color_index color1,\
  373. int phase_x, int phase_y))
  374. #define dev_proc_tile_rectangle(proc)\
  375. dev_t_proc_tile_rectangle(proc, gx_device)
  376. #define dev_t_proc_copy_mono(proc, dev_t)\
  377. int proc(P11(dev_t *dev,\
  378. const byte *data, int data_x, int raster, gx_bitmap_id id,\
  379. int x, int y, int width, int height,\
  380. gx_color_index color0, gx_color_index color1))
  381. #define dev_proc_copy_mono(proc)\
  382. dev_t_proc_copy_mono(proc, gx_device)
  383. #define dev_t_proc_copy_color(proc, dev_t)\
  384. int proc(P9(dev_t *dev,\
  385. const byte *data, int data_x, int raster, gx_bitmap_id id,\
  386. int x, int y, int width, int height))
  387. #define dev_proc_copy_color(proc)\
  388. dev_t_proc_copy_color(proc, gx_device)
  389. /* OBSOLETED in release 3.66 */
  390. #define dev_t_proc_draw_line(proc, dev_t)\
  391. int proc(P6(dev_t *dev,\
  392. int x0, int y0, int x1, int y1, gx_color_index color))
  393. #define dev_proc_draw_line(proc)\
  394. dev_t_proc_draw_line(proc, gx_device)
  395. /* Added in release 2.4 */
  396. #define dev_t_proc_get_bits(proc, dev_t)\
  397. int proc(P4(dev_t *dev,\
  398. int y, byte *data, byte **actual_data))
  399. #define dev_proc_get_bits(proc)\
  400. dev_t_proc_get_bits(proc, gx_device)
  401. /* Added in release 2.4, changed in 2.8, */
  402. /* renamed in 2.9.6 */
  403. #define dev_t_proc_get_params(proc, dev_t)\
  404. int proc(P2(dev_t *dev, gs_param_list *plist))
  405. #define dev_proc_get_params(proc)\
  406. dev_t_proc_get_params(proc, gx_device)
  407. #define dev_t_proc_put_params(proc, dev_t)\
  408. int proc(P2(dev_t *dev, gs_param_list *plist))
  409. #define dev_proc_put_params(proc)\
  410. dev_t_proc_put_params(proc, gx_device)
  411. /* Added in release 2.6 */
  412. #define dev_t_proc_map_cmyk_color(proc, dev_t)\
  413. gx_color_index proc(P5(dev_t *dev,\
  414. gx_color_value cyan, gx_color_value magenta, gx_color_value yellow,\
  415. gx_color_value black))
  416. #define dev_proc_map_cmyk_color(proc)\
  417. dev_t_proc_map_cmyk_color(proc, gx_device)
  418. #define dev_t_proc_get_xfont_procs(proc, dev_t)\
  419. const gx_xfont_procs *proc(P1(dev_t *dev))
  420. #define dev_proc_get_xfont_procs(proc)\
  421. dev_t_proc_get_xfont_procs(proc, gx_device)
  422. /* Added in release 2.6.1 */
  423. #define dev_t_proc_get_xfont_device(proc, dev_t)\
  424. gx_device *proc(P1(dev_t *dev))
  425. #define dev_proc_get_xfont_device(proc)\
  426. dev_t_proc_get_xfont_device(proc, gx_device)
  427. /* Added in release 2.7.1 */
  428. #define dev_t_proc_map_rgb_alpha_color(proc, dev_t)\
  429. gx_color_index proc(P5(dev_t *dev,\
  430. gx_color_value red, gx_color_value green, gx_color_value blue,\
  431. gx_color_value alpha))
  432. #define dev_proc_map_rgb_alpha_color(proc)\
  433. dev_t_proc_map_rgb_alpha_color(proc, gx_device)
  434. /* Added in release 2.8.1 */
  435. #define dev_t_proc_get_page_device(proc, dev_t)\
  436. gx_device *proc(P1(dev_t *dev))
  437. #define dev_proc_get_page_device(proc)\
  438. dev_t_proc_get_page_device(proc, gx_device)
  439. /* Added in release 3.20, OBSOLETED in 5.65 */
  440. #define dev_t_proc_get_alpha_bits(proc, dev_t)\
  441. int proc(P2(dev_t *dev, graphics_object_type type))
  442. #define dev_proc_get_alpha_bits(proc)\
  443. dev_t_proc_get_alpha_bits(proc, gx_device)
  444. /* Added in release 3.20 */
  445. #define dev_t_proc_copy_alpha(proc, dev_t)\
  446. int proc(P11(dev_t *dev, const byte *data, int data_x,\
  447. int raster, gx_bitmap_id id, int x, int y, int width, int height,\
  448. gx_color_index color, int depth))
  449. #define dev_proc_copy_alpha(proc)\
  450. dev_t_proc_copy_alpha(proc, gx_device)
  451. /* Added in release 3.38 */
  452. #define dev_t_proc_get_band(proc, dev_t)\
  453. int proc(P3(dev_t *dev, int y, int *band_start))
  454. #define dev_proc_get_band(proc)\
  455. dev_t_proc_get_band(proc, gx_device)
  456. /* Added in release 3.44 */
  457. #define dev_t_proc_copy_rop(proc, dev_t)\
  458. int proc(P15(dev_t *dev,\
  459. const byte *sdata, int sourcex, uint sraster, gx_bitmap_id id,\
  460. const gx_color_index *scolors,\
  461. const gx_tile_bitmap *texture, const gx_color_index *tcolors,\
  462. int x, int y, int width, int height,\
  463. int phase_x, int phase_y, gs_logical_operation_t lop))
  464. #define dev_proc_copy_rop(proc)\
  465. dev_t_proc_copy_rop(proc, gx_device)
  466. /* Added in release 3.60, changed in 3.68. */
  467. #define dev_t_proc_fill_path(proc, dev_t)\
  468. int proc(P6(dev_t *dev,\
  469. const gs_imager_state *pis, gx_path *ppath,\
  470. const gx_fill_params *params,\
  471. const gx_drawing_color *pdcolor, const gx_clip_path *pcpath))
  472. #define dev_proc_fill_path(proc)\
  473. dev_t_proc_fill_path(proc, gx_device)
  474. #define dev_t_proc_stroke_path(proc, dev_t)\
  475. int proc(P6(dev_t *dev,\
  476. const gs_imager_state *pis, gx_path *ppath,\
  477. const gx_stroke_params *params,\
  478. const gx_drawing_color *pdcolor, const gx_clip_path *pcpath))
  479. #define dev_proc_stroke_path(proc)\
  480. dev_t_proc_stroke_path(proc, gx_device)
  481. /* Added in release 3.60 */
  482. #define dev_t_proc_fill_mask(proc, dev_t)\
  483. int proc(P13(dev_t *dev,\
  484. const byte *data, int data_x, int raster, gx_bitmap_id id,\
  485. int x, int y, int width, int height,\
  486. const gx_drawing_color *pdcolor, int depth,\
  487. gs_logical_operation_t lop, const gx_clip_path *pcpath))
  488. #define dev_proc_fill_mask(proc)\
  489. dev_t_proc_fill_mask(proc, gx_device)
  490. /* Added in release 3.66, changed in 3.69 */
  491. #define dev_t_proc_fill_trapezoid(proc, dev_t)\
  492. int proc(P8(dev_t *dev,\
  493. const gs_fixed_edge *left, const gs_fixed_edge *right,\
  494. fixed ybot, fixed ytop, bool swap_axes,\
  495. const gx_drawing_color *pdcolor, gs_logical_operation_t lop))
  496. #define dev_proc_fill_trapezoid(proc)\
  497. dev_t_proc_fill_trapezoid(proc, gx_device)
  498. #define dev_t_proc_fill_parallelogram(proc, dev_t)\
  499. int proc(P9(dev_t *dev,\
  500. fixed px, fixed py, fixed ax, fixed ay, fixed bx, fixed by,\
  501. const gx_drawing_color *pdcolor, gs_logical_operation_t lop))
  502. #define dev_proc_fill_parallelogram(proc)\
  503. dev_t_proc_fill_parallelogram(proc, gx_device)
  504. #define dev_t_proc_fill_triangle(proc, dev_t)\
  505. int proc(P9(dev_t *dev,\
  506. fixed px, fixed py, fixed ax, fixed ay, fixed bx, fixed by,\
  507. const gx_drawing_color *pdcolor, gs_logical_operation_t lop))
  508. #define dev_proc_fill_triangle(proc)\
  509. dev_t_proc_fill_triangle(proc, gx_device)
  510. #define dev_t_proc_draw_thin_line(proc, dev_t)\
  511. int proc(P7(dev_t *dev,\
  512. fixed fx0, fixed fy0, fixed fx1, fixed fy1,\
  513. const gx_drawing_color *pdcolor, gs_logical_operation_t lop))
  514. #define dev_proc_draw_thin_line(proc)\
  515. dev_t_proc_draw_thin_line(proc, gx_device)
  516. /* Added in release 3.66 (as stubs); */
  517. /* changed in 3.68; */
  518. /* begin_image and image_data changed in 4.30, */
  519. /* begin_image changed in 5.23. */
  520. #define dev_t_proc_begin_image(proc, dev_t)\
  521. int proc(P9(dev_t *dev,\
  522. const gs_imager_state *pis, const gs_image_t *pim,\
  523. gs_image_format_t format, const gs_int_rect *prect,\
  524. const gx_drawing_color *pdcolor, const gx_clip_path *pcpath,\
  525. gs_memory_t *memory, gx_image_enum_common_t **pinfo))
  526. #define dev_proc_begin_image(proc)\
  527. dev_t_proc_begin_image(proc, gx_device)
  528. /* OBSOLETED in release 5.23 */
  529. #define dev_t_proc_image_data(proc, dev_t)\
  530. int proc(P6(dev_t *dev,\
  531. gx_image_enum_common_t *info, const byte **planes, int data_x,\
  532. uint raster, int height))
  533. #define dev_proc_image_data(proc)\
  534. dev_t_proc_image_data(proc, gx_device)
  535. /* OBSOLETED in release 5.23 */
  536. #define dev_t_proc_end_image(proc, dev_t)\
  537. int proc(P3(dev_t *dev,\
  538. gx_image_enum_common_t *info, bool draw_last))
  539. #define dev_proc_end_image(proc)\
  540. dev_t_proc_end_image(proc, gx_device)
  541. /* Added in release 3.68 */
  542. #define dev_t_proc_strip_tile_rectangle(proc, dev_t)\
  543. int proc(P10(dev_t *dev,\
  544. const gx_strip_bitmap *tiles, int x, int y, int width, int height,\
  545. gx_color_index color0, gx_color_index color1,\
  546. int phase_x, int phase_y))
  547. #define dev_proc_strip_tile_rectangle(proc)\
  548. dev_t_proc_strip_tile_rectangle(proc, gx_device)
  549. #define dev_t_proc_strip_copy_rop(proc, dev_t)\
  550. int proc(P15(dev_t *dev,\
  551. const byte *sdata, int sourcex, uint sraster, gx_bitmap_id id,\
  552. const gx_color_index *scolors,\
  553. const gx_strip_bitmap *textures, const gx_color_index *tcolors,\
  554. int x, int y, int width, int height,\
  555. int phase_x, int phase_y, gs_logical_operation_t lop))
  556. #define dev_proc_strip_copy_rop(proc)\
  557. dev_t_proc_strip_copy_rop(proc, gx_device)
  558. /* Added in release 4.20 */
  559. #define dev_t_proc_get_clipping_box(proc, dev_t)\
  560. void proc(P2(dev_t *dev, gs_fixed_rect *pbox))
  561. #define dev_proc_get_clipping_box(proc)\
  562. dev_t_proc_get_clipping_box(proc, gx_device)
  563. /* Added in release 5.20, changed in 5.23 */
  564. #define dev_t_proc_begin_typed_image(proc, dev_t)\
  565. int proc(P9(dev_t *dev,\
  566. const gs_imager_state *pis, const gs_matrix *pmat,\
  567. const gs_image_common_t *pim, const gs_int_rect *prect,\
  568. const gx_drawing_color *pdcolor, const gx_clip_path *pcpath,\
  569. gs_memory_t *memory, gx_image_enum_common_t **pinfo))
  570. #define dev_proc_begin_typed_image(proc)\
  571. dev_t_proc_begin_typed_image(proc, gx_device)
  572. /* Added in release 5.20 */
  573. #define dev_t_proc_get_bits_rectangle(proc, dev_t)\
  574. int proc(P4(dev_t *dev, const gs_int_rect *prect,\
  575. gs_get_bits_params_t *params, gs_int_rect **unread))
  576. #define dev_proc_get_bits_rectangle(proc)\
  577. dev_t_proc_get_bits_rectangle(proc, gx_device)
  578. #define dev_t_proc_map_color_rgb_alpha(proc, dev_t)\
  579. int proc(P3(dev_t *dev,\
  580. gx_color_index color, gx_color_value rgba[4]))
  581. #define dev_proc_map_color_rgb_alpha(proc)\
  582. dev_t_proc_map_color_rgb_alpha(proc, gx_device)
  583. #define dev_t_proc_create_compositor(proc, dev_t)\
  584. int proc(P5(dev_t *dev,\
  585. gx_device **pcdev, const gs_composite_t *pcte,\
  586. const gs_imager_state *pis, gs_memory_t *memory))
  587. #define dev_proc_create_compositor(proc)\
  588. dev_t_proc_create_compositor(proc, gx_device)\
  589. /* Added in release 5.23 */
  590. #define dev_t_proc_get_hardware_params(proc, dev_t)\
  591. int proc(P2(dev_t *dev, gs_param_list *plist))
  592. #define dev_proc_get_hardware_params(proc)\
  593. dev_t_proc_get_hardware_params(proc, gx_device)
  594. /* Added in release 5.24 */
  595. /* ... text_begin ... see gxtext.h for definition */
  596. /* Added in release 6.23 */
  597. #define dev_t_proc_finish_copydevice(proc, dev_t)\
  598. int proc(P2(dev_t *dev, const gx_device *from_dev))
  599. #define dev_proc_finish_copydevice(proc)\
  600. dev_t_proc_finish_copydevice(proc, gx_device)
  601. /* Added in release 6.61 (raph) */
  602. /*
  603. This area of the transparency facilities is in flux. Here is a proposal
  604. for extending the driver interface.
  605. */
  606. /*
  607. Push the current transparency state (*ppts) onto the associated stack,
  608. and set *ppts to a new transparency state of the given dimension. The
  609. transparency state may copy some or all of the imager state, such as the
  610. current alpha and/or transparency mask values, and definitely copies the
  611. parameters.
  612. */
  613. #define dev_t_proc_begin_transparency_group(proc, dev_t)\
  614. int proc(P6(gx_device *dev,\
  615. const gs_transparency_group_params_t *ptgp,\
  616. const gs_rect *pbbox,\
  617. gs_imager_state *pis,\
  618. gs_transparency_state_t **ppts,\
  619. gs_memory_t *mem))
  620. #define dev_proc_begin_transparency_group(proc)\
  621. dev_t_proc_begin_transparency_group(proc, gx_device)
  622. /*
  623. End a transparency group: blend the top element of the transparency
  624. stack, which must be a group, into the next-to-top element, popping the
  625. stack. If the stack only had a single element, blend into the device
  626. output. Set *ppts to 0 iff the stack is now empty. If end_group fails,
  627. the stack is *not* popped.
  628. */
  629. #define dev_t_proc_end_transparency_group(proc, dev_t)\
  630. int proc(P3(gx_device *dev,\
  631. gs_imager_state *pis,\
  632. gs_transparency_state_t **ppts))
  633. #define dev_proc_end_transparency_group(proc)\
  634. dev_t_proc_end_transparency_group(proc, gx_device)
  635. /*
  636. Push the transparency state and prepare to render a transparency mask.
  637. This is similar to begin_transparency_group except that it only
  638. accumulates coverage values, not full pixel values.
  639. */
  640. #define dev_t_proc_begin_transparency_mask(proc, dev_t)\
  641. int proc(P6(gx_device *dev,\
  642. const gs_transparency_mask_params_t *ptmp,\
  643. const gs_rect *pbbox,\
  644. gs_imager_state *pis,\
  645. gs_transparency_state_t **ppts,\
  646. gs_memory_t *mem))
  647. #define dev_proc_begin_transparency_mask(proc)\
  648. dev_t_proc_begin_transparency_mask(proc, gx_device)
  649. /*
  650. Store a pointer to the rendered transparency mask into *pptm, popping the
  651. stack like end_group. Normally, the client will follow this by using
  652. rc_assign to store the rendered mask into pis->{opacity,shape}.mask. If
  653. end_mask fails, the stack is *not* popped.
  654. */
  655. #define dev_t_proc_end_transparency_mask(proc, dev_t)\
  656. int proc(P2(gx_device *dev,\
  657. gs_transparency_mask_t **pptm))
  658. #define dev_proc_end_transparency_mask(proc)\
  659. dev_t_proc_end_transparency_mask(proc, gx_device)
  660. /*
  661. Pop the transparency stack, discarding the top element, which may be
  662. either a group or a mask. Set *ppts to 0 iff the stack is now empty.
  663. */
  664. #define dev_t_proc_discard_transparency_layer(proc, dev_t)\
  665. int proc(P2(gx_device *dev,\
  666. gs_transparency_state_t **ppts))
  667. #define dev_proc_discard_transparency_layer(proc)\
  668. dev_t_proc_discard_transparency_layer(proc, gx_device)
  669. /* (end of transparency driver interface extensions) */
  670. /* Define the device procedure vector template proper. */
  671. #define gx_device_proc_struct(dev_t)\
  672. { dev_t_proc_open_device((*open_device), dev_t);\
  673. dev_t_proc_get_initial_matrix((*get_initial_matrix), dev_t);\
  674. dev_t_proc_sync_output((*sync_output), dev_t);\
  675. dev_t_proc_output_page((*output_page), dev_t);\
  676. dev_t_proc_close_device((*close_device), dev_t);\
  677. dev_t_proc_map_rgb_color((*map_rgb_color), dev_t);\
  678. dev_t_proc_map_color_rgb((*map_color_rgb), dev_t);\
  679. dev_t_proc_fill_rectangle((*fill_rectangle), dev_t);\
  680. dev_t_proc_tile_rectangle((*tile_rectangle), dev_t);\
  681. dev_t_proc_copy_mono((*copy_mono), dev_t);\
  682. dev_t_proc_copy_color((*copy_color), dev_t);\
  683. dev_t_proc_draw_line((*obsolete_draw_line), dev_t);\
  684. dev_t_proc_get_bits((*get_bits), dev_t);\
  685. dev_t_proc_get_params((*get_params), dev_t);\
  686. dev_t_proc_put_params((*put_params), dev_t);\
  687. dev_t_proc_map_cmyk_color((*map_cmyk_color), dev_t);\
  688. dev_t_proc_get_xfont_procs((*get_xfont_procs), dev_t);\
  689. dev_t_proc_get_xfont_device((*get_xfont_device), dev_t);\
  690. dev_t_proc_map_rgb_alpha_color((*map_rgb_alpha_color), dev_t);\
  691. dev_t_proc_get_page_device((*get_page_device), dev_t);\
  692. dev_t_proc_get_alpha_bits((*get_alpha_bits), dev_t);\
  693. dev_t_proc_copy_alpha((*copy_alpha), dev_t);\
  694. dev_t_proc_get_band((*get_band), dev_t);\
  695. dev_t_proc_copy_rop((*copy_rop), dev_t);\
  696. dev_t_proc_fill_path((*fill_path), dev_t);\
  697. dev_t_proc_stroke_path((*stroke_path), dev_t);\
  698. dev_t_proc_fill_mask((*fill_mask), dev_t);\
  699. dev_t_proc_fill_trapezoid((*fill_trapezoid), dev_t);\
  700. dev_t_proc_fill_parallelogram((*fill_parallelogram), dev_t);\
  701. dev_t_proc_fill_triangle((*fill_triangle), dev_t);\
  702. dev_t_proc_draw_thin_line((*draw_thin_line), dev_t);\
  703. dev_t_proc_begin_image((*begin_image), dev_t);\
  704. dev_t_proc_image_data((*image_data), dev_t);\
  705. dev_t_proc_end_image((*end_image), dev_t);\
  706. dev_t_proc_strip_tile_rectangle((*strip_tile_rectangle), dev_t);\
  707. dev_t_proc_strip_copy_rop((*strip_copy_rop), dev_t);\
  708. dev_t_proc_get_clipping_box((*get_clipping_box), dev_t);\
  709. dev_t_proc_begin_typed_image((*begin_typed_image), dev_t);\
  710. dev_t_proc_get_bits_rectangle((*get_bits_rectangle), dev_t);\
  711. dev_t_proc_map_color_rgb_alpha((*map_color_rgb_alpha), dev_t);\
  712. dev_t_proc_create_compositor((*create_compositor), dev_t);\
  713. dev_t_proc_get_hardware_params((*get_hardware_params), dev_t);\
  714. dev_t_proc_text_begin((*text_begin), dev_t);\
  715. dev_t_proc_finish_copydevice((*finish_copydevice), dev_t);\
  716. dev_t_proc_begin_transparency_group((*begin_transparency_group), dev_t);\
  717. dev_t_proc_end_transparency_group((*end_transparency_group), dev_t);\
  718. dev_t_proc_begin_transparency_mask((*begin_transparency_mask), dev_t);\
  719. dev_t_proc_end_transparency_mask((*end_transparency_mask), dev_t);\
  720. dev_t_proc_discard_transparency_layer((*discard_transparency_layer), dev_t);\
  721. }
  722. /*
  723. * Provide procedures for passing image data. image_data and end_image
  724. * are the equivalents of the obsolete driver procedures. image_plane_data
  725. * was originally planned as a driver procedure, but is now associated with
  726. * the image enumerator, like the other two.
  727. */
  728. typedef struct gx_image_plane_s {
  729. const byte *data;
  730. int data_x;
  731. uint raster;
  732. } gx_image_plane_t;
  733. #define gx_device_begin_image(dev, pis, pim, format, prect, pdcolor, pcpath, memory, pinfo)\
  734. ((*dev_proc(dev, begin_image))\
  735. (dev, pis, pim, format, prect, pdcolor, pcpath, memory, pinfo))
  736. #define gx_device_begin_typed_image(dev, pis, pmat, pim, prect, pdcolor, pcpath, memory, pinfo)\
  737. ((*dev_proc(dev, begin_typed_image))\
  738. (dev, pis, pmat, pim, prect, pdcolor, pcpath, memory, pinfo))
  739. /*
  740. * The driver-like procedures gx_device_{image_data, image_plane_data,
  741. * end_image} are now DEPRECATED and will eventually be removed.
  742. * Their replacements no longer take an ignored dev argument.
  743. */
  744. int gx_image_data(P5(gx_image_enum_common_t *info, const byte **planes,
  745. int data_x, uint raster, int height));
  746. /*
  747. * Solely for backward compatibility, gx_image_plane_data doesn't return
  748. * rows_used.
  749. */
  750. int gx_image_plane_data(P3(gx_image_enum_common_t *info,
  751. const gx_image_plane_t *planes, int height));
  752. int gx_image_plane_data_rows(P4(gx_image_enum_common_t *info,
  753. const gx_image_plane_t *planes, int height,
  754. int *rows_used));
  755. int gx_image_flush(P1(gx_image_enum_common_t *info));
  756. bool gx_image_planes_wanted(P2(const gx_image_enum_common_t *info, byte *wanted));
  757. int gx_image_end(P2(gx_image_enum_common_t *info, bool draw_last));
  758. #define gx_device_image_data(dev, info, planes, data_x, raster, height)\
  759. gx_image_data(info, planes, data_x, raster, height)
  760. #define gx_device_image_plane_data(dev, info, planes, height)\
  761. gx_image_plane_data(info, planes, height)
  762. #define gx_device_end_image(dev, info, draw_last)\
  763. gx_image_end(info, draw_last)
  764. /*
  765. * Get the anti-aliasing parameters for a device. This replaces the
  766. * obsolete get_alpha_bits device procedure.
  767. */
  768. #define gx_device_get_alpha_bits(dev, type)\
  769. gx_default_get_alpha_bits(dev, type)
  770. /* A generic device procedure record. */
  771. struct gx_device_procs_s gx_device_proc_struct(gx_device);
  772. /*
  773. * Define unaligned analogues of the copy_xxx procedures.
  774. * These are slower than the standard procedures, which require
  775. * aligned bitmaps, and also are not portable to non-byte-addressed machines.
  776. *
  777. * We allow both unaligned data and unaligned scan line widths;
  778. * however, we do require that both of these be aligned modulo the largest
  779. * power of 2 bytes that divides the data depth, i.e.:
  780. * depth alignment
  781. * <= 8 1
  782. * 16 2
  783. * 24 1
  784. * 32 4
  785. */
  786. dev_proc_copy_mono(gx_copy_mono_unaligned);
  787. dev_proc_copy_color(gx_copy_color_unaligned);
  788. dev_proc_copy_alpha(gx_copy_alpha_unaligned);
  789. /* A generic device */
  790. struct gx_device_s {
  791. gx_device_common;
  792. };
  793. extern_st(st_device);
  794. struct_proc_finalize(gx_device_finalize); /* public for subclasses */
  795. /* We use vacuous enum/reloc procedures, rather than 0, so that */
  796. /* gx_device can have subclasses. */
  797. #define public_st_device() /* in gsdevice.c */\
  798. gs_public_st_complex_only(st_device, gx_device, "gx_device",\
  799. 0, gs_no_struct_enum_ptrs, gs_no_struct_reloc_ptrs, gx_device_finalize)
  800. #define st_device_max_ptrs 0
  801. /* Enumerate or relocate a pointer to a device. */
  802. /* These take the containing space into account properly. */
  803. gx_device *gx_device_enum_ptr(P1(gx_device *));
  804. gx_device *gx_device_reloc_ptr(P2(gx_device *, gc_state_t *));
  805. /* Define typedefs for some of the device procedures, because */
  806. /* ansi2knr can't handle dev_proc_xxx((*xxx)) in a formal argument list. */
  807. typedef dev_proc_map_rgb_color((*dev_proc_map_rgb_color_t));
  808. typedef dev_proc_map_color_rgb((*dev_proc_map_color_rgb_t));
  809. /*
  810. * A forwarding device forwards all non-display operations, and possibly
  811. * some imaging operations (possibly transformed in some way), to another
  812. * device called the "target". This is used for many different purposes
  813. * internally, including clipping, banding, image and pattern accumulation,
  814. * compositing, halftoning, and the null device.
  815. */
  816. #define gx_device_forward_common\
  817. gx_device_common;\
  818. gx_device *target
  819. /* A generic forwarding device. */
  820. typedef struct gx_device_forward_s {
  821. gx_device_forward_common;
  822. } gx_device_forward;
  823. extern_st(st_device_forward);
  824. #define public_st_device_forward() /* in gsdevice.c */\
  825. gs_public_st_complex_only(st_device_forward, gx_device_forward,\
  826. "gx_device_forward", 0, device_forward_enum_ptrs,\
  827. device_forward_reloc_ptrs, gx_device_finalize)
  828. #define st_device_forward_max_ptrs (st_device_max_ptrs + 1)
  829. /* A null device. This is used to temporarily disable output. */
  830. #ifndef gx_device_null_DEFINED
  831. # define gx_device_null_DEFINED
  832. typedef struct gx_device_null_s gx_device_null;
  833. #endif
  834. struct gx_device_null_s {
  835. gx_device_forward_common;
  836. };
  837. extern const gx_device_null gs_null_device;
  838. #define gx_device_is_null(dev)\
  839. ((dev)->dname == gs_null_device.dname)
  840. extern_st(st_device_null);
  841. #define public_st_device_null() /* in gsdevice.c */\
  842. gs_public_st_complex_only(st_device_null, gx_device_null,\
  843. "gx_device_null", 0, device_forward_enum_ptrs,\
  844. device_forward_reloc_ptrs, gx_device_finalize)
  845. #define st_device_null_max_ptrs st_device_forward_max_ptrs
  846. /*
  847. * Initialize a just-allocated device from a prototype. If internal =
  848. * false, the device is marked retained; if internal = true, the device is
  849. * not marked retained. See the beginning of this file for more information
  850. * about what this means. Normally, devices created for temporary use have
  851. * internal = true (retained = false).
  852. */
  853. void gx_device_init(P4(gx_device * dev, const gx_device * proto,
  854. gs_memory_t * mem, bool internal));
  855. /* Make a null device. */
  856. /* The gs_memory_t argument is 0 if the device is temporary and local, */
  857. /* or the allocator that was used to allocate it if it is a real object. */
  858. void gs_make_null_device(P3(gx_device_null *dev_null, gx_device *target,
  859. gs_memory_t *mem));
  860. /* Set the target of a (forwarding) device. */
  861. void gx_device_set_target(P2(gx_device_forward *fdev, gx_device *target));
  862. /* Mark a device as retained or not retained. */
  863. void gx_device_retain(P2(gx_device *dev, bool retained));
  864. /* Calculate the raster (number of bytes in a scan line), */
  865. /* with byte or word padding. */
  866. uint gx_device_raster(P2(const gx_device * dev, bool pad_to_word));
  867. /* Adjust the resolution for devices that only have a fixed set of */
  868. /* geometries, so that the apparent size in inches remains constant. */
  869. /* If fit=1, the resolution is adjusted so that the entire image fits; */
  870. /* if fit=0, one dimension fits, but the other one is clipped. */
  871. int gx_device_adjust_resolution(P4(gx_device * dev, int actual_width, int actual_height, int fit));
  872. /* Set the HWMargins to values defined in inches. */
  873. /* If move_origin is true, also reset the Margins. */
  874. void gx_device_set_margins(P3(gx_device * dev, const float *margins /*[4] */ ,
  875. bool move_origin));
  876. /* Set the width and height (in pixels), updating MediaSize. */
  877. void gx_device_set_width_height(P3(gx_device * dev, int width, int height));
  878. /* Set the resolution (in pixels per inch), updating width and height. */
  879. void gx_device_set_resolution(P3(gx_device * dev, floatp x_dpi, floatp y_dpi));
  880. /* Set the MediaSize (in 1/72" units), updating width and height. */
  881. void gx_device_set_media_size(P3(gx_device * dev, floatp media_width, floatp media_height));
  882. /****** BACKWARD COMPATIBILITY ******/
  883. #define gx_device_set_page_size(dev, w, h)\
  884. gx_device_set_media_size(dev, w, h)
  885. /*
  886. * Temporarily install a null device, or a special device such as
  887. * a clipping or cache device.
  888. */
  889. void gx_set_device_only(P2(gs_state *, gx_device *));
  890. /* Close a device. */
  891. int gs_closedevice(P1(gx_device *));
  892. /* "Free" a device locally allocated on the stack, by finalizing it. */
  893. void gx_device_free_local(P1(gx_device *));
  894. /* ------ Device types (an unused concept right now) ------ */
  895. #define dev_type_proc_initialize(proc)\
  896. int proc(P1(gx_device *))
  897. typedef struct gx_device_type_s {
  898. gs_memory_type_ptr_t stype;
  899. dev_type_proc_initialize((*initialize));
  900. } gx_device_type;
  901. #define device_type(dtname, stype, initproc)\
  902. private dev_type_proc_initialize(initproc);\
  903. const gx_device_type dtname = { &stype, initproc }
  904. /*dev_type_proc_initialize(gdev_initialize); */
  905. #endif /* gxdevcli_INCLUDED */