~ubuntu-branches/ubuntu/oneiric/ghostscript/oneiric

« back to all changes in this revision

Viewing changes to base/gxcldev.h

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2011-07-15 16:49:55 UTC
  • mfrom: (1.1.23 upstream)
  • Revision ID: james.westby@ubuntu.com-20110715164955-uga6qibao6kez05c
Tags: 9.04~dfsg~20110715-0ubuntu1
* New upstream release
   - GIT snapshot from Jult, 12 2011.
* debian/patches/020110406~a54df2d.patch,
  debian/patches/020110408~0791cc8.patch,
  debian/patches/020110408~507cbee.patch,
  debian/patches/020110411~4509a49.patch,
  debian/patches/020110412~78bb9a6.patch,
  debian/patches/020110418~a05ab8a.patch,
  debian/patches/020110420~20b6c78.patch,
  debian/patches/020110420~4ddefa2.patch: Removed upstream patches.
* debian/rules: Generate ABI version number (variable "abi") correctly,
  cutting off repackaging and pre-release parts.
* debian/rules: Added ./lcms2/ directory to DEB_UPSTREAM_REPACKAGE_EXCLUDES.
* debian/copyright: Added lcms2/* to the list of excluded files.
* debian/symbols.common: Updated for new upstream source. Applied patch
  which dpkg-gensymbols generated for debian/libgs9.symbols to this file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
2
2
   All Rights Reserved.
3
 
  
 
3
 
4
4
   This software is provided AS-IS with no warranty, either express or
5
5
   implied.
6
6
 
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/*$Id: gxcldev.h 11926 2010-12-01 05:16:55Z mvrhel $ */
 
14
/*$Id$ */
15
15
/* Internal definitions for Ghostscript command lists. */
16
16
 
17
17
#ifndef gxcldev_INCLUDED
27
27
#include "srlx.h"               /* ditto */
28
28
#include "gsdcolor.h"
29
29
 
 
30
#define CMM_THREAD_SAFE 0        
 
31
 
30
32
/* ---------------- Commands ---------------- */
31
33
 
32
34
/* Define the compression modes for bitmaps. */
40
42
void clist_rld_init(stream_RLD_state *ss);
41
43
void clist_cfe_init(stream_CFE_state *ss, int width, gs_memory_t *mem);
42
44
void clist_cfd_init(stream_CFD_state *ss, int width, int height,
43
 
                    gs_memory_t *mem);
 
45
                    gs_memory_t *mem);
44
46
 
45
47
/*
46
48
 * A command always consists of an operation followed by operands;
59
61
    cmd_op_misc = 0x00,         /* (see below) */
60
62
    cmd_opv_end_run = 0x00,     /* (nothing) */
61
63
    cmd_opv_set_tile_size = 0x01,   /* rs?(1)nry?(1)nrx?(1)depth(5, encoded), */
62
 
                                /* rep_width#, rep_height#, */
63
 
                                /* [, nreps_x#][, nreps_y #] */
64
 
                                /* [, rep_shift#] */
 
64
                                /* rep_width#, rep_height#, */
 
65
                                /* [, nreps_x#][, nreps_y #] */
 
66
                                /* [, rep_shift#] */
65
67
    cmd_opv_set_tile_phase = 0x02,      /* x#, y# */
66
68
    cmd_opv_set_tile_bits = 0x03,       /* index#, offset#, <bits> */
67
69
    cmd_opv_set_bits = 0x04,    /* depth*4+compress, width#, height#, */
68
 
                                /* index#, offset#, <bits> */
 
70
                                /* index#, offset#, <bits> */
69
71
    cmd_opv_set_tile_color = 0x05,      /* (nothing; next set/delta_color */
70
 
                                /* refers to tile) */
 
72
                                /* refers to tile) */
71
73
    cmd_opv_set_misc = 0x06,
72
74
#define cmd_set_misc_lop (0 << 6)       /* 00: lop_lsb(6), lop_msb# */
73
75
#define cmd_set_misc_data_x (1 << 6)    /* 01: more(1)dx_lsb(5)[, dx_msb#] */
76
78
#define cmd_set_misc_halftone (3 << 6)  /* 11: type(6), num_comp# */
77
79
    cmd_opv_enable_lop = 0x07,  /* (nothing) */
78
80
    cmd_opv_disable_lop = 0x08, /* (nothing) */
79
 
    /* obsolete */
80
 
    /* cmd_opv_set_ht_order = 0x09, */  /* component+1#[, cname#], */
81
 
                                /* width#, height#, raster#, */
82
 
                                /* shift#, num_levels#, num_bits#, */
83
 
                                /* order_procs_index */
84
 
    /* obsolete */
85
 
    /* cmd_opv_set_ht_data = 0x0a, */   /* n, n x (uint|gx_ht_bit|ushort) */
86
81
    cmd_opv_end_page = 0x0b,    /* (nothing) */
87
82
    cmd_opv_delta_color0 = 0x0c,        /* See cmd_put_color in gxclutil.c */
88
83
    cmd_opv_delta_color1 = 0x0d,        /* <<same as color0>> */
97
92
    cmd_op_tile_rect = 0x60,    /* +dy2dh2, x#, w# | +0, rect# */
98
93
    cmd_op_tile_rect_short = 0x70,      /* +dh, dx, dw | +0, rect_short */
99
94
    cmd_op_tile_rect_tiny = 0x80,       /* +dw+0, rect_tiny | +dw+8 */
100
 
    cmd_op_copy_mono = 0x90,    /* +compress, x#, y#, (w+data_x)#, */
101
 
                                /* h#, <bits> | */
 
95
    cmd_op_copy_mono_plane = 0x90,      /* +compress, plane, x#, y#, (w+data_x)#, */
 
96
                                        /* h#, <bits> | */
102
97
#define cmd_copy_ht_color 4
103
 
                                /* +4+compress, x#, y#, (w+data_x)#, */
104
 
                                /* h#, <bits> | */
 
98
                                /* +4+compress, x#, y#, (w+data_x)#, */
 
99
                                /* h#, <bits> | */
105
100
#define cmd_copy_use_tile 8
106
 
                                /* +8 (use tile), x#, y# | */
107
 
                                /* +12 (use tile), x#, y# */
 
101
                                /* +8 (use tile), x#, y# | */
 
102
                                /* +12 (use tile), x#, y# */
108
103
    cmd_op_copy_color_alpha = 0xa0,     /* (same as copy_mono, except: */
109
 
                                /* if color, ignore ht_color; */
110
 
                                /* if alpha & !use_tile, depth is */
111
 
                                /*   first operand) */
 
104
                                /* if color, ignore ht_color; */
 
105
                                /* if alpha & !use_tile, depth is */
 
106
                                /*   first operand) */
112
107
    cmd_op_delta_tile_index = 0xb0,     /* +delta+8 */
113
108
    cmd_op_set_tile_index = 0xc0        /* +index[11:8], index[7:0] */
114
109
} gx_cmd_op;
116
111
#define cmd_op_name_strings\
117
112
  "(misc)", "set_color[0]", "set_color[1]", "fill_rect",\
118
113
  "fill_rect_short", "fill_rect_tiny", "tile_rect", "tile_rect_short",\
119
 
  "tile_rect_tiny", "copy_mono", "copy_color_alpha", "delta_tile_index",\
 
114
  "tile_rect_tiny", "copy_mono_plane", "copy_color_alpha", "delta_tile_index",\
120
115
  "set_tile_index", "(misc2)", "(segment)", "(path)"
121
116
 
122
117
#define cmd_misc_op_name_strings\
123
118
  "end_run", "set_tile_size", "set_tile_phase", "set_tile_bits",\
124
119
  "set_bits", "set_tile_color", "set_misc", "enable_lop",\
125
 
  "disable_lop", "set_ht_order", "set_ht_data", "end_page",\
 
120
  "disable_lop", "invalid", "invalid", "end_page",\
126
121
  "delta2_color0", "delta2_color1", "set_copy_color", "set_copy_alpha",
127
122
 
128
123
#ifdef DEBUG
200
195
 * Return the total size of the bitmap.
201
196
 */
202
197
uint clist_bitmap_bytes(uint width_bits, uint height,
203
 
                        int compression_mask,
204
 
                        uint * width_bytes, uint * raster);
 
198
                        int compression_mask,
 
199
                        uint * width_bytes, uint * raster);
205
200
 
206
201
/*
207
202
 * For halftone cells, we always write an unreplicated bitmap, but we
216
211
    int band_min, band_max;
217
212
#define cmd_band_end (-1)       /* end of band file */
218
213
    int64_t pos;                /* starting position in cfile */
219
 
    gx_band_complexity_t band_complexity;  
220
 
    
 
214
    gx_band_complexity_t band_complexity;
 
215
 
221
216
} cmd_block;
222
217
 
223
218
/* ---------------- Band state ---------------- */
241
236
    gx_cmd_rect rect;           /* most recent rectangle */
242
237
    gs_logical_operation_t lop; /* most recent logical op */
243
238
    short lop_enabled;          /* 0 = don't use lop, 1 = use lop, */
244
 
                                /* -1 is used internally */
 
239
                                /* -1 is used internally */
245
240
    short clip_enabled;         /* 0 = don't clip, 1 = do clip, */
246
 
                                /* -1 is used internally */
 
241
                                /* -1 is used internally */
247
242
    bool color_is_alpha;        /* for copy_color_alpha */
248
243
    uint known;                 /* flags for whether this band */
249
 
                                /* knows various misc. parameters */
 
244
                                /* knows various misc. parameters */
250
245
    /* We assign 'known' flags here from the high end; */
251
246
    /* gxclpath.h assigns them from the low end. */
252
247
#define tile_params_known (1<<15)
255
250
    /* Following are only used when writing */
256
251
    cmd_list list;              /* list of commands for band */
257
252
    /* Following are set when writing, read when reading */
258
 
    gx_band_complexity_t band_complexity; 
 
253
    gx_band_complexity_t band_complexity;
259
254
    gx_colors_used_t colors_used;
260
255
};
261
256
 
262
257
/* The initial values for a band state */
263
258
/*static const gx_clist_state cls_initial */
264
259
#define cls_initial_values\
265
 
         { gx_no_color_index, gx_no_color_index },\
266
 
        { gx_dc_type_none },\
267
 
        0, gx_no_bitmap_id, gs_no_id,\
268
 
         { 0, 0 }, { gx_no_color_index, gx_no_color_index },\
269
 
         { 0, 0, 0, 0 }, lop_default, 0, 0, 0, initial_known,\
270
 
        { 0, 0 }, { 0, 0 }, { 0, 0 }
 
260
         { gx_no_color_index, gx_no_color_index },\
 
261
        { gx_dc_type_none },\
 
262
        0, gx_no_bitmap_id, gs_no_id,\
 
263
         { 0, 0 }, { gx_no_color_index, gx_no_color_index },\
 
264
         { 0, 0, 0, 0 }, lop_default, 0, 0, 0, initial_known,\
 
265
        { 0, 0 }, { 0, 0 }, { 0, 0 }
271
266
 
272
267
/* Define the size of the command buffer used for reading. */
273
268
/* This is needed to split up operations with a large amount of data, */
287
282
dev_proc_fill_trapezoid(clist_fill_trapezoid);
288
283
dev_proc_fill_linear_color_trapezoid(clist_fill_linear_color_trapezoid);
289
284
dev_proc_fill_linear_color_triangle(clist_fill_linear_color_triangle);
290
 
dev_proc_pattern_manage(clist_pattern_manage);
 
285
dev_proc_dev_spec_op(clist_dev_spec_op);
 
286
dev_proc_copy_plane(clist_copy_plane);
291
287
 
292
288
/* In gxclimag.c */
293
289
dev_proc_fill_mask(clist_fill_mask);
380
376
/* and allocate space for its data. */
381
377
byte *cmd_put_list_op(gx_device_clist_writer * cldev, cmd_list * pcl, uint size);
382
378
 
383
 
/* Request a space in the buffer. 
 
379
/* Request a space in the buffer.
384
380
   Writes out the buffer if necessary.
385
381
   Returns the size of available space. */
386
382
int cmd_get_buffer_space(gx_device_clist_writer * cldev, gx_clist_state * pcls, uint size);
399
395
 
400
396
/* Add a command for all bands or a range of bands. */
401
397
byte *cmd_put_range_op(gx_device_clist_writer * cldev, int band_min,
402
 
                       int band_max, uint size);
 
398
                       int band_max, uint size);
403
399
 
404
400
#define cmd_put_all_op(cldev, size)\
405
401
  cmd_put_range_op(cldev, 0, (cldev)->nbands - 1, size)
480
476
 
481
477
/* Put out a command to set the tile colors. */
482
478
int cmd_set_tile_colors(gx_device_clist_writer *cldev, gx_clist_state * pcls,
483
 
                        gx_color_index color0, gx_color_index color1);
 
479
                        gx_color_index color0, gx_color_index color1);
484
480
 
485
481
/* Put out a command to set the tile phase. */
486
482
int
487
483
cmd_set_tile_phase_generic(gx_device_clist_writer * cldev, gx_clist_state * pcls,
488
 
                   int px, int py, bool all_bands);
 
484
                   int px, int py, bool all_bands);
489
485
int cmd_set_tile_phase(gx_device_clist_writer *cldev, gx_clist_state * pcls,
490
 
                       int px, int py);
 
486
                       int px, int py);
491
487
 
492
488
/* Enable or disable the logical operation. */
493
489
int cmd_put_enable_lop(gx_device_clist_writer *, gx_clist_state *, int);
514
510
 
515
511
/* Write a command to set the logical operation. */
516
512
int cmd_set_lop(gx_device_clist_writer *, gx_clist_state *,
517
 
                gs_logical_operation_t);
 
513
                gs_logical_operation_t);
518
514
 
519
515
/* Disable (if default) or enable the logical operation, setting it if */
520
516
/* needed. */
521
517
int cmd_update_lop(gx_device_clist_writer *, gx_clist_state *,
522
 
                   gs_logical_operation_t);
 
518
                   gs_logical_operation_t);
523
519
 
524
520
/*
525
521
 * For dividing up an operation into bands, use the control pattern :
526
 
 * 
 
522
 *
527
523
 *   cmd_rects_enum_t re;
528
524
 *   RECT_ENUM_INIT(re, ry, rheight);
529
525
 *   do {
551
547
 * and then restart emitting the entire band.
552
548
 * Note that re.y must not change when restarting the band.
553
549
 *
554
 
 * The band processing code may wrap a writing operation with a pattern like this : 
 
550
 * The band processing code may wrap a writing operation with a pattern like this :
555
551
 *
556
552
 *      do {
557
553
 *          code = operation(...);
560
556
 *          goto error_in_rect;
561
557
 *
562
558
 *
563
 
 * This will 
 
559
 * This will
564
560
 * perform local first-stage VMerror recovery, by waiting for some memory to
565
561
 * become free and then retrying the failed operation starting at the
566
562
 * TRY_RECT. If local recovery is unsuccessful, the local recovery code
572
568
 * VMerror recovery.  In such cases, the recursive call must not attempt
573
569
 * second-stage VMerror recovery, since the caller would have no way of
574
570
 * knowing that the writer state had been reset.  Such recursive calls
575
 
 * should be wrapped in 
 
571
 * should be wrapped in
576
572
 *
577
573
 *  ++cdev->driver_call_nesting;  { ... } --cdev->driver_call_nesting;
578
574
 *
589
585
 */
590
586
 
591
587
typedef struct cmd_rects_enum_s {
592
 
        int y;
593
 
        int height;
594
 
        int yend;
595
 
        int band_height;
596
 
        int band_code;
597
 
        int band;
598
 
        gx_clist_state *pcls;
599
 
        int band_end;
600
 
        int nbands;
 
588
        int y;
 
589
        int height;
 
590
        int yend;
 
591
        int band_height;
 
592
        int band_code;
 
593
        int band;
 
594
        gx_clist_state *pcls;
 
595
        int band_end;
 
596
        int nbands;
601
597
} cmd_rects_enum_t;
602
598
 
603
599
#define RECT_ENUM_INIT(re, yvar, heightvar)\
604
 
        re.y = yvar;\
605
 
        re.height = heightvar;\
606
 
        re.yend = re.y + re.height;\
607
 
        re.band_height = cdev->page_band_height;\
608
 
        re.nbands = (re.yend - re.y + re.band_height - 1) / re.band_height;
 
600
        re.y = yvar;\
 
601
        re.height = heightvar;\
 
602
        re.yend = re.y + re.height;\
 
603
        re.band_height = cdev->page_band_height;\
 
604
        re.nbands = (re.yend - re.y + re.band_height - 1) / re.band_height;
609
605
 
610
606
#define RECT_STEP_INIT(re)\
611
 
            re.band = re.y / re.band_height;\
612
 
            re.pcls = cdev->states + re.band;\
613
 
            re.band_end = (re.band + 1) * re.band_height;\
614
 
            re.height = min(re.band_end, re.yend) - re.y;
615
 
 
 
607
            re.band = re.y / re.band_height;\
 
608
            re.pcls = cdev->states + re.band;\
 
609
            re.band_end = (re.band + 1) * re.band_height;\
 
610
            re.height = min(re.band_end, re.yend) - re.y;
616
611
 
617
612
#define RECT_RECOVER(codevar) (codevar < 0 && (codevar = clist_VMerror_recover(cdev, codevar)) >= 0)
618
613
#define SET_BAND_CODE(codevar) (re.band_code = codevar)
620
615
/* Read a transformation matrix. */
621
616
const byte *cmd_read_matrix(gs_matrix * pmat, const byte * cbp);
622
617
 
623
 
 
624
618
/* ------ Exported by gxclrect.c ------ */
625
619
 
626
620
/* Put out a fill or tile rectangle command. */
627
621
int cmd_write_rect_cmd(gx_device_clist_writer * cldev, gx_clist_state * pcls,
628
 
                       int op, int x, int y, int width, int height);
 
622
                       int op, int x, int y, int width, int height);
629
623
 
630
624
/* Put out a fill or tile rectangle command for fillpage. */
631
625
int cmd_write_page_rect_cmd(gx_device_clist_writer * cldev, int op);
655
649
#define decompress_spread 0x200
656
650
 
657
651
int cmd_put_bits(gx_device_clist_writer * cldev, gx_clist_state * pcls,
658
 
                 const byte * data, uint width_bits, uint height,
659
 
                 uint raster, int op_size, int compression_mask,
660
 
                 byte ** pdp, uint * psize);
 
652
                 const byte * data, uint width_bits, uint height,
 
653
                 uint raster, int op_size, int compression_mask,
 
654
                 byte ** pdp, uint * psize);
661
655
 
662
656
/*
663
657
 * Put out commands for a color map (transfer function, black generation, or
687
681
 * procedure primarily for readability.)
688
682
 */
689
683
int clist_change_tile(gx_device_clist_writer * cldev, gx_clist_state * pcls,
690
 
                      const gx_strip_bitmap * tiles, int depth);
 
684
                      const gx_strip_bitmap * tiles, int depth);
691
685
 
692
686
/*
693
687
 * Change "tile" for clist_copy_*.  Only uses tiles->{data, id, raster,
694
688
 * rep_width, rep_height}.  tiles->[rep_]shift must be zero.
695
689
 */
696
690
int clist_change_bits(gx_device_clist_writer * cldev, gx_clist_state * pcls,
697
 
                      const gx_strip_bitmap * tiles, int depth);
 
691
                      const gx_strip_bitmap * tiles, int depth);
698
692
 
699
693
/* ------ Exported by gxclimag.c ------ */
700
694
 
702
696
 * Write out any necessary color mapping data.
703
697
 */
704
698
int cmd_put_color_mapping(gx_device_clist_writer * cldev,
705
 
                                  const gs_imager_state * pis);
 
699
                                  const gs_imager_state * pis);
706
700
/*
707
701
 * Add commands to represent a full (device) halftone.
708
702
 * (This routine should probably be in some other module.)
709
703
 */
710
704
int cmd_put_halftone(gx_device_clist_writer * cldev,
711
 
                     const gx_device_halftone * pdht);
 
705
                     const gx_device_halftone * pdht);
712
706
 
713
707
/* ------ Exported by gxclrast.c for gxclread.c ------ */
714
708
 
723
717
 
724
718
/* Play back and rasterize one band. */
725
719
int clist_playback_band(clist_playback_action action,
726
 
                        gx_device_clist_reader *cdev,
727
 
                        stream *s, gx_device *target,
728
 
                        int x0, int y0, gs_memory_t *mem);
 
720
                        gx_device_clist_reader *cdev,
 
721
                        stream *s, gx_device *target,
 
722
                        int x0, int y0, gs_memory_t *mem);
729
723
 
730
724
/* Playback the band file, taking the indicated action w/ its contents. */
731
 
int clist_playback_file_bands(clist_playback_action action, 
732
 
                          gx_device_clist_reader *crdev,
733
 
                          gx_band_page_info_t *page_info, gx_device *target,
734
 
                          int band_first, int band_last, int x0, int y0);
735
 
#ifdef DEBUG 
 
725
int clist_playback_file_bands(clist_playback_action action,
 
726
                          gx_device_clist_reader *crdev,
 
727
                          gx_band_page_info_t *page_info, gx_device *target,
 
728
                          int band_first, int band_last, int x0, int y0);
 
729
#ifdef DEBUG
736
730
int64_t clist_file_offset(const stream_state *st, uint buffer_offset);
737
731
int top_up_offset_map(stream_state * st, const byte *buf, const byte *ptr, const byte *end);
738
732
#endif