@libgs/linux-arm64 0.0.0-stage → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
- # Temporary Holding Version
1
+ # libgs
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Ghostscript library (libgs) for linux arm64.
4
+
5
+ See the [libgs repository](https://github.com/NickNaso/libgs#readme) for how to use it.
@@ -0,0 +1,417 @@
1
+ /* Copyright (C) 2001-2023 Artifex Software, Inc.
2
+ All Rights Reserved.
3
+
4
+ This software is provided AS-IS with no warranty, either express or
5
+ implied.
6
+
7
+ This software is distributed under license and may not be copied,
8
+ modified or distributed except as expressly authorized under the terms
9
+ of the license contained in the file LICENSE in this distribution.
10
+
11
+ Refer to licensing information at http://www.artifex.com or contact
12
+ Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
13
+ CA 94129, USA, for further information.
14
+ */
15
+
16
+ /* gdevdsp.h - callback structure for DLL based display device */
17
+
18
+ #ifndef gdevdsp_INCLUDED
19
+ # define gdevdsp_INCLUDED
20
+
21
+ /*
22
+ * There are 2 mechanisms to provide the callback structure to
23
+ * Ghostscript. A legacy one, and a modern one. The legacy one is
24
+ * deprecated and should not be used in new code - at some point it may
25
+ * be removed.
26
+ *
27
+ * Modern method: Call the Ghostscript APIs in the following order:
28
+ * gsapi_new_instance(&minst);
29
+ * gsapi_register_callout(minst, callout, callout_handle);
30
+ * gsapi_init_with_args(minst, argc, argv);
31
+ *
32
+ * The callout handler should look for a callout from the 'display'
33
+ * device, with id=DISPLAY_CALLOUT_GET_CALLBACK and respond by filling
34
+ * in the supplied gs_display_get_callback_t structure.
35
+ *
36
+ * Supported parameters and default values are:
37
+ * -dDisplayFormat=0 long
38
+ * Color format specified using bitfields below.
39
+ * Included as argument of display_size() and display_presize()
40
+ * These can only be changed when the device is closed.
41
+ *
42
+ * Legacy method: Call the Ghostscript APIs in the following order:
43
+ * gsapi_new_instance(&minst);
44
+ * gsapi_set_display_callback(minst, callback);
45
+ * gsapi_init_with_args(minst, argc, argv);
46
+ *
47
+ * An additional parameter is supported, with default value NULL:
48
+ * -sDisplayHandle=16#04d2 or 1234 string
49
+ * Caller supplied handle as a decimal or hexadecimal number
50
+ * in a string. On 32-bit platforms, it may be set
51
+ * using -dDisplayHandle=1234 for backward compatibility.
52
+ * Included as first parameter of all callback functions.
53
+ *
54
+ * The second parameter of all callback functions "void *device"
55
+ * is the address of the Ghostscript display device instance.
56
+ * The arguments "void *handle" and "void *device" together
57
+ * uniquely identify an instance of the display device.
58
+ *
59
+ * A typical sequence of callbacks (when running without a
60
+ * display_choose_mode) would be:
61
+ * open, presize, memalloc, size, sync, page
62
+ * presize, memfree, memalloc, size, sync, page
63
+ * preclose, memfree, close
64
+ * The caller should not access the image buffer:
65
+ * - before the first sync
66
+ * - between presize and size
67
+ * - after preclose
68
+ * If opening the device fails, you might see the following:
69
+ * open, presize, memalloc, memfree, close
70
+ *
71
+ * A typical sequence of callbacks (when running with a
72
+ * display_choose_mode) will depend upon whether display_choose_mode
73
+ * selects pagemode or request-rectangle mode:
74
+ *
75
+ * In the pagemode case:
76
+ * open, presize, display_choose_mode, memalloc, size, sync, page
77
+ * presize, display_choose_mode, memfree, memalloc, size, sync, page
78
+ * preclose, memfree, close
79
+ * The caller should not access the image buffer:
80
+ * - before the first sync
81
+ * - between presize and size
82
+ * - after preclose
83
+ * If opening the device fails, you might see the following:
84
+ * open, presize, memalloc, memfree, close
85
+ *
86
+ * In the request-rectangle mode:
87
+ * open, presize, display_choose_mode, {rectangle_request}*
88
+ * presize, display_choose_mode, {rectangle_request}*
89
+ * preclose, close
90
+ *
91
+ * In a run that mixed request-rectangle and pagemode:
92
+ * open, presize, display_choose_mode, memalloc, size, sync, page
93
+ * presize, display_choose_mode, memfree, {rectangle_request}*
94
+ * presize, display_choose_mode, {rectangle_request}*
95
+ * presize, display_choose_mode, memalloc, size, sync, page
96
+ * preclose, memfree, close
97
+ */
98
+
99
+ #define DISPLAY_VERSION_MAJOR 3
100
+ #define DISPLAY_VERSION_MINOR 0
101
+
102
+ #define DISPLAY_VERSION_MAJOR_V1 1 /* before separation format was added */
103
+ #define DISPLAY_VERSION_MINOR_V1 0
104
+
105
+ #define DISPLAY_VERSION_MAJOR_V2 2 /* before planar and banding were added */
106
+ #define DISPLAY_VERSION_MINOR_V2 0
107
+
108
+ /* The display format is set by a combination of the following bitfields */
109
+
110
+ /* Define the color space alternatives */
111
+ typedef enum {
112
+ DISPLAY_COLORS_NATIVE = (1<<0),
113
+ DISPLAY_COLORS_GRAY = (1<<1),
114
+ DISPLAY_COLORS_RGB = (1<<2),
115
+ DISPLAY_COLORS_CMYK = (1<<3),
116
+ DISPLAY_COLORS_SEPARATION = (1<<19)
117
+ } DISPLAY_FORMAT_COLOR;
118
+ #define DISPLAY_COLORS_MASK 0x8000fL
119
+
120
+ /* Define whether alpha information, or an extra unused bytes is included */
121
+ /* DISPLAY_ALPHA_FIRST and DISPLAY_ALPHA_LAST are not implemented */
122
+ typedef enum {
123
+ DISPLAY_ALPHA_NONE = (0<<4),
124
+ DISPLAY_ALPHA_FIRST = (1<<4),
125
+ DISPLAY_ALPHA_LAST = (1<<5),
126
+ DISPLAY_UNUSED_FIRST = (1<<6), /* e.g. Mac xRGB */
127
+ DISPLAY_UNUSED_LAST = (1<<7) /* e.g. Windows BGRx */
128
+ } DISPLAY_FORMAT_ALPHA;
129
+ #define DISPLAY_ALPHA_MASK 0x00f0L
130
+
131
+ /* Define the depth per component for DISPLAY_COLORS_GRAY,
132
+ * DISPLAY_COLORS_RGB and DISPLAY_COLORS_CMYK,
133
+ * or the depth per pixel for DISPLAY_COLORS_NATIVE
134
+ * DISPLAY_DEPTH_2 and DISPLAY_DEPTH_12 have not been tested.
135
+ */
136
+ typedef enum {
137
+ DISPLAY_DEPTH_1 = (1<<8),
138
+ DISPLAY_DEPTH_2 = (1<<9),
139
+ DISPLAY_DEPTH_4 = (1<<10),
140
+ DISPLAY_DEPTH_8 = (1<<11),
141
+ DISPLAY_DEPTH_12 = (1<<12),
142
+ DISPLAY_DEPTH_16 = (1<<13)
143
+ /* unused (1<<14) */
144
+ /* unused (1<<15) */
145
+ } DISPLAY_FORMAT_DEPTH;
146
+ #define DISPLAY_DEPTH_MASK 0xff00L
147
+
148
+ /* Define whether Red/Cyan should come first,
149
+ * or whether Blue/Black should come first
150
+ */
151
+ typedef enum {
152
+ DISPLAY_BIGENDIAN = (0<<16), /* Red/Cyan first */
153
+ DISPLAY_LITTLEENDIAN = (1<<16) /* Blue/Black first */
154
+ } DISPLAY_FORMAT_ENDIAN;
155
+ #define DISPLAY_ENDIAN_MASK 0x00010000L
156
+
157
+ /* Define whether the raster starts at the top or bottom of the bitmap */
158
+ typedef enum {
159
+ DISPLAY_TOPFIRST = (0<<17), /* Unix, Mac */
160
+ DISPLAY_BOTTOMFIRST = (1<<17) /* Windows */
161
+ } DISPLAY_FORMAT_FIRSTROW;
162
+ #define DISPLAY_FIRSTROW_MASK 0x00020000L
163
+
164
+ /* Define whether packing RGB in 16-bits should use 555
165
+ * or 565 (extra bit for green)
166
+ */
167
+ typedef enum {
168
+ DISPLAY_NATIVE_555 = (0<<18),
169
+ DISPLAY_NATIVE_565 = (1<<18)
170
+ } DISPLAY_FORMAT_555;
171
+ #define DISPLAY_555_MASK 0x00040000L
172
+
173
+ /* Define the row alignment, which must be equal to or greater than
174
+ * the size of a pointer.
175
+ * The default (DISPLAY_ROW_ALIGN_DEFAULT) is the size of a pointer,
176
+ * 4 bytes (DISPLAY_ROW_ALIGN_4) on 32-bit systems or 8 bytes
177
+ * (DISPLAY_ROW_ALIGN_8) on 64-bit systems.
178
+ */
179
+ typedef enum {
180
+ DISPLAY_ROW_ALIGN_DEFAULT = (0<<20),
181
+ /* DISPLAY_ROW_ALIGN_1 = (1<<20), */ /* not currently possible */
182
+ /* DISPLAY_ROW_ALIGN_2 = (2<<20), */ /* not currently possible */
183
+ DISPLAY_ROW_ALIGN_4 = (3<<20),
184
+ DISPLAY_ROW_ALIGN_8 = (4<<20),
185
+ DISPLAY_ROW_ALIGN_16 = (5<<20),
186
+ DISPLAY_ROW_ALIGN_32 = (6<<20),
187
+ DISPLAY_ROW_ALIGN_64 = (7<<20)
188
+ } DISPLAY_FORMAT_ROW_ALIGN;
189
+ #define DISPLAY_ROW_ALIGN_MASK 0x00700000L
190
+
191
+ /* Define whether we are using chunky, planar or planar interleaved
192
+ * representation. */
193
+ typedef enum {
194
+ DISPLAY_CHUNKY = (0<<23),
195
+ DISPLAY_PLANAR = (1<<23),
196
+ DISPLAY_PLANAR_INTERLEAVED = (2<<23),
197
+ } DISPLAY_FORMAT_PLANARNESS;
198
+
199
+ #ifndef display_callback_DEFINED
200
+ #define display_callback_DEFINED
201
+ typedef struct display_callback_s display_callback;
202
+ #endif
203
+
204
+ /*
205
+ * Note that for Windows, the display callback functions are
206
+ * cdecl, not stdcall. This differs from those in iapi.h.
207
+ */
208
+
209
+ struct display_callback_s {
210
+ /* Size of this structure */
211
+ /* Used for checking if we have been handed a valid structure */
212
+ int size;
213
+
214
+ /* Major version of this structure */
215
+ /* The major version number will change if this structure changes. */
216
+ int version_major;
217
+
218
+ /* Minor version of this structure */
219
+ /* The minor version number will change if new features are added
220
+ * without changes to this structure. For example, a new color
221
+ * format.
222
+ */
223
+ int version_minor;
224
+
225
+ /* New device has been opened */
226
+ /* This is the first event from this device. */
227
+ int (*display_open)(void *handle, void *device);
228
+
229
+ /* Device is about to be closed. */
230
+ /* Device will not be closed until this function returns. */
231
+ int (*display_preclose)(void *handle, void *device);
232
+
233
+ /* Device has been closed. */
234
+ /* This is the last event from this device. */
235
+ int (*display_close)(void *handle, void *device);
236
+
237
+ /* Device is about to be resized. */
238
+ /* Resize will only occur if this function returns 0. */
239
+ /* raster is byte count of a row. */
240
+ int (*display_presize)(void *handle, void *device,
241
+ int width, int height, int raster, unsigned int format);
242
+
243
+ /* Device has been resized. */
244
+ /* New pointer to raster returned in pimage */
245
+ int (*display_size)(void *handle, void *device, int width, int height,
246
+ int raster, unsigned int format, unsigned char *pimage);
247
+
248
+ /* flushpage */
249
+ int (*display_sync)(void *handle, void *device);
250
+
251
+ /* showpage */
252
+ /* If you want to pause on showpage, then don't return immediately */
253
+ int (*display_page)(void *handle, void *device, int copies, int flush);
254
+
255
+ /* Notify the caller whenever a portion of the raster is updated. */
256
+ /* This can be used for cooperative multitasking or for
257
+ * progressive update of the display.
258
+ * This function pointer may be set to NULL if not required.
259
+ * NOTE: This is actually a really bad thing to work on. It may well
260
+ * end up not being called back at all during the rendering process,
261
+ * in particular if transparency is in use, or if rectangle request
262
+ * mode is used.
263
+ */
264
+ int (*display_update)(void *handle, void *device, int x, int y,
265
+ int w, int h);
266
+
267
+ /* Allocate memory for bitmap */
268
+ /* This is provided in case you need to create memory in a special
269
+ * way, e.g. shared. If this is NULL, the Ghostscript memory device
270
+ * allocates the bitmap. This will only called to allocate the
271
+ * image buffer. The first row will be placed at the address
272
+ * returned by display_memalloc.
273
+ *
274
+ * In the event of this callback returning NULL, Ghostscript will
275
+ * look for a display_rectangle_request callback. If one is not
276
+ * supplied, then this will be reported as memory exhaustion. If
277
+ * one is supplied, then Ghostscript will switch to working in
278
+ * rectangle request mode.
279
+ */
280
+ void *(*display_memalloc)(void *handle, void *device, size_t size);
281
+
282
+ /* Free memory for bitmap */
283
+ /* If this is NULL, the Ghostscript memory device will free the bitmap */
284
+ int (*display_memfree)(void *handle, void *device, void *mem);
285
+
286
+ /* Added in V2 */
287
+ /* When using separation color space (DISPLAY_COLORS_SEPARATION),
288
+ * give a mapping for one separation component.
289
+ * This is called for each new component found.
290
+ * It may be called multiple times for each component.
291
+ * It may be called at any time between display_size
292
+ * and display_close.
293
+ * The client uses this to map from the separations to CMYK
294
+ * and hence to RGB for display.
295
+ * GS must only use this callback if version_major >= 2.
296
+ * The unsigned short c,m,y,k values are 65535 = 1.0.
297
+ * This function pointer may be set to NULL if not required.
298
+ */
299
+ int (*display_separation)(void *handle, void *device,
300
+ int component, const char *component_name,
301
+ unsigned short c, unsigned short m,
302
+ unsigned short y, unsigned short k);
303
+
304
+ /* Added in V3 */
305
+ /* If non NULL, then this gives the callback provider a chance to
306
+ * a) be informed of and b) control the bandheight used by the
307
+ * display device. If a call to allocate the page mode bitmap fails
308
+ * (either an internal allocation or a display_memalloc call), then
309
+ * Ghostscript will look for the presence of a
310
+ * display_rectangle_request callback. If it exists, then it will
311
+ * attempt to use retangle request mode.
312
+ *
313
+ * As part of this, it will pick an appropriate bandheight. If
314
+ * this callback exists, it will be called so the callback provider
315
+ * can know (and, optionally, tweak) the bandheight to be used.
316
+ * This is purely for performance. The callback should only ever
317
+ * *reduce* the bandheight given here.
318
+ *
319
+ * Return the adjusted bandheight (or 0 for no change).
320
+ */
321
+ int (*display_adjust_band_height)(void *handle, void *device,
322
+ int bandheight);
323
+
324
+ /* Ask the callback for a rectangle to render (and a block to render
325
+ * it in). Each subsequent call tells the caller that any previous
326
+ * call has finished. To signal 'no more rectangles' return with
327
+ * *w or *h = 0.
328
+ *
329
+ * On entry: *raster and *plane_raster are set to the standard
330
+ * values. All other values are undefined.
331
+ * On return: *memory should point to a block of memory to use.
332
+ * Pixel (*ox,*oy) is the first pixel represented in that block.
333
+ * *raster = the number of bytes difference between the address of
334
+ * component 0 of Pixel(*ox,*oy) and the address of component 0 of
335
+ * Pixel(*ox,1+*oy).
336
+ * *plane_raster = the number of bytes difference between the
337
+ * address of component 0 of Pixel(*ox,*oy) and the address of
338
+ * component 1 of Pixel(*ox,*oy), if in planar mode, 0 otherwise.
339
+ * *x, *y, *w, *h = rectangle requested within that memory block.
340
+ *
341
+ */
342
+ int (*display_rectangle_request)(void *handle, void *device,
343
+ void **memory, int *ox, int *oy,
344
+ int *raster, int *plane_raster,
345
+ int *x, int *y, int *w, int *h);
346
+ };
347
+
348
+ /* This is the V2 structure, before banding and planar support was added */
349
+ struct display_callback_v2_s {
350
+ int size; /* sizeof(struct display_callback_v2) */
351
+ int version_major; /* DISPLAY_VERSION_MAJOR_V2 */
352
+ int version_minor; /* DISPLAY_VERSION_MINOR_V2 */
353
+ int (*display_open)(void *handle, void *device);
354
+ int (*display_preclose)(void *handle, void *device);
355
+ int (*display_close)(void *handle, void *device);
356
+ int (*display_presize)(void *handle, void *device,
357
+ int width, int height, int raster, unsigned int format);
358
+ int (*display_size)(void *handle, void *device, int width, int height,
359
+ int raster, unsigned int format, unsigned char *pimage);
360
+ int (*display_sync)(void *handle, void *device);
361
+ int (*display_page)(void *handle, void *device, int copies, int flush);
362
+ int (*display_update)(void *handle, void *device, int x, int y,
363
+ int w, int h);
364
+ void *(*display_memalloc)(void *handle, void *device, unsigned long size);
365
+ int (*display_memfree)(void *handle, void *device, void *mem);
366
+ int (*display_separation)(void *handle, void *device,
367
+ int component, const char *component_name,
368
+ unsigned short c, unsigned short m,
369
+ unsigned short y, unsigned short k);
370
+ };
371
+
372
+ /* This is the V1 structure, before separation format was added */
373
+ struct display_callback_v1_s {
374
+ int size; /* sizeof(struct display_callback_v1) */
375
+ int version_major; /* DISPLAY_VERSION_MAJOR_V1 */
376
+ int version_minor; /* DISPLAY_VERSION_MINOR_V1 */
377
+ int (*display_open)(void *handle, void *device);
378
+ int (*display_preclose)(void *handle, void *device);
379
+ int (*display_close)(void *handle, void *device);
380
+ int (*display_presize)(void *handle, void *device,
381
+ int width, int height, int raster, unsigned int format);
382
+ int (*display_size)(void *handle, void *device, int width, int height,
383
+ int raster, unsigned int format, unsigned char *pimage);
384
+ int (*display_sync)(void *handle, void *device);
385
+ int (*display_page)(void *handle, void *device, int copies, int flush);
386
+ int (*display_update)(void *handle, void *device, int x, int y,
387
+ int w, int h);
388
+ void *(*display_memalloc)(void *handle, void *device, unsigned long size);
389
+ int (*display_memfree)(void *handle, void *device, void *mem);
390
+ };
391
+
392
+ #define DISPLAY_CALLBACK_V1_SIZEOF sizeof(struct display_callback_v1_s)
393
+
394
+ #define DISPLAY_CALLOUT_GET_CALLBACK 0
395
+ #define DISPLAY_CALLOUT_GET_CALLBACK_LEGACY 1
396
+
397
+ typedef struct {
398
+ display_callback *callback;
399
+ void *caller_handle;
400
+ } gs_display_get_callback_t;
401
+
402
+ /* The display device calls a callout to find the callback structure
403
+ * and caller_handle from the environment (the DLL caller/user of the
404
+ * API).
405
+ * It passes:
406
+ * id = DISPLAY_CALLOUT_GET_CALLBACK.
407
+ * size = sizeof(gs_display_get_callback_t) (or larger);
408
+ * data = pointer to gs_display_get_callback_t instance for callout
409
+ * handler to fill in.
410
+ *
411
+ * In order to support the old gsapi_set_display_callback we have a
412
+ * related callout, DISPLAY_CALLOUT_GET_CALLBACK_LEGACY. Do not use
413
+ * this!
414
+ */
415
+
416
+
417
+ #endif /* gdevdsp_INCLUDED */