~ubuntu-branches/ubuntu/hardy/ghostscript/hardy

« back to all changes in this revision

Viewing changes to src/gdevx.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2007-11-22 12:17:43 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071122121743-cd70s3ypq0r243mp
Tags: 8.61.dfsg.1-0ubtuntu1
* New upstream release
  o Final 8.61 release
* debian/patches/09_ijs_krgb_support.dpatch: Adapted to upstream changes.
* debian/rules: Updated CUPS-related variables for "make install" calls.
* debian/rules: Remove /usr/include/ghostscript from the ghostscript
  package, they go into lings-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: gdevx.c 8022 2007-06-05 22:23:38Z giles $ */
 
14
/* $Id: gdevx.c 8346 2007-11-02 19:09:03Z marcos $ */
15
15
/* X Windows driver for Ghostscript library */
16
16
#include "gx.h"                 /* for gx_bitmap; includes std.h */
17
17
#include "math_.h"
38
38
private_st_device_X();
39
39
 
40
40
/* Forward references */
41
 
private int x_copy_image(gx_device_X * xdev, const byte * base, int sourcex,
 
41
static int x_copy_image(gx_device_X * xdev, const byte * base, int sourcex,
42
42
                         int raster, int x, int y, int w, int h);
43
 
private int set_tile(gx_device *, const gx_strip_bitmap *);
44
 
private void free_cp(gx_device *);
 
43
static int set_tile(gx_device *, const gx_strip_bitmap *);
 
44
static void free_cp(gx_device *);
45
45
 
46
46
/* Screen updating machinery */
47
 
private void update_init(gx_device_X *);
48
 
private void update_do_flush(gx_device_X *);
 
47
static void update_init(gx_device_X *);
 
48
static void update_do_flush(gx_device_X *);
49
49
 
50
50
#define flush_text(xdev)\
51
51
  if (IN_TEXT(xdev)) do_flush_text(xdev)
52
 
private void do_flush_text(gx_device_X *);
 
52
static void do_flush_text(gx_device_X *);
53
53
 
54
54
/* Driver procedures */
55
55
/* (External procedures are declared in gdevx.h.) */
56
56
/*extern int gdev_x_open(gx_device_X *);*/
57
 
private dev_proc_open_device(x_open);
58
 
private dev_proc_get_initial_matrix(x_get_initial_matrix);
59
 
private dev_proc_sync_output(x_sync);
60
 
private dev_proc_output_page(x_output_page);
 
57
static dev_proc_open_device(x_open);
 
58
static dev_proc_get_initial_matrix(x_get_initial_matrix);
 
59
static dev_proc_sync_output(x_sync);
 
60
static dev_proc_output_page(x_output_page);
61
61
/*extern int gdev_x_close(gx_device_X *);*/
62
 
private dev_proc_close_device(x_close);
 
62
static dev_proc_close_device(x_close);
63
63
/*extern dev_proc_map_rgb_color(gdev_x_map_rgb_color);*/
64
64
/*extern dev_proc_map_color_rgb(gdev_x_map_color_rgb);*/
65
 
private dev_proc_fill_rectangle(x_fill_rectangle);
66
 
private dev_proc_copy_mono(x_copy_mono);
67
 
private dev_proc_copy_color(x_copy_color);
 
65
static dev_proc_fill_rectangle(x_fill_rectangle);
 
66
static dev_proc_copy_mono(x_copy_mono);
 
67
static dev_proc_copy_color(x_copy_color);
68
68
/*extern dev_proc_get_params(gdev_x_get_params);*/
69
69
/*extern dev_proc_put_params(gdev_x_put_params);*/
70
70
/*extern dev_proc_get_xfont_procs(gdev_x_get_xfont_procs);*/
71
 
private dev_proc_get_page_device(x_get_page_device);
72
 
private dev_proc_strip_tile_rectangle(x_strip_tile_rectangle);
73
 
private dev_proc_begin_typed_image(x_begin_typed_image);
74
 
private dev_proc_get_bits_rectangle(x_get_bits_rectangle);
 
71
static dev_proc_get_page_device(x_get_page_device);
 
72
static dev_proc_strip_tile_rectangle(x_strip_tile_rectangle);
 
73
static dev_proc_begin_typed_image(x_begin_typed_image);
 
74
static dev_proc_get_bits_rectangle(x_get_bits_rectangle);
75
75
/*extern dev_proc_get_xfont_procs(gdev_x_finish_copydevice);*/
76
76
 
77
77
/* The device descriptor */
234
234
         50000000)
235
235
 
236
236
/* If XPutImage doesn't work, do it ourselves. */
237
 
private int alt_put_image(gx_device * dev, Display * dpy, Drawable win,
 
237
static int alt_put_image(gx_device * dev, Display * dpy, Drawable win,
238
238
GC gc, XImage * pi, int sx, int sy, int dx, int dy, unsigned w, unsigned h);
239
239
 
240
240
#define put_image(dpy,win,gc,im,sx,sy,x,y,w,h)\
241
241
  BEGIN\
242
 
    if ( xdev->useXPutImage ) {\
243
 
      if (XInitImage(im) == 0)\
244
 
        return_error(gs_error_unknownerror);\
 
242
    if ( xdev->useXPutImage && !(XInitImage(im) == 0) ) {\
245
243
      XPutImage(dpy,win,gc,im,sx,sy,x,y,w,h);\
246
244
    } else {\
247
245
      int code_ = alt_put_image(dev,dpy,win,gc,im,sx,sy,x,y,w,h);\
250
248
  END
251
249
 
252
250
/* Open the device.  Most of the code is in gdevxini.c. */
253
 
private int
 
251
static int
254
252
x_open(gx_device * dev)
255
253
{
256
254
    gx_device_X *xdev = (gx_device_X *) dev;
263
261
}
264
262
 
265
263
/* Close the device. */
266
 
private int
 
264
static int
267
265
x_close(gx_device * dev)
268
266
{
269
267
    gx_device_X *xdev = (gx_device_X *) dev;
274
272
/* Get initial matrix for X device. */
275
273
/* This conflicts seriously with the code for page devices; */
276
274
/* we only do it if Ghostview is active. */
277
 
private void
 
275
static void
278
276
x_get_initial_matrix(gx_device * dev, gs_matrix * pmat)
279
277
{
280
278
    gx_device_X *xdev = (gx_device_X *) dev;
292
290
}
293
291
 
294
292
/* Synchronize the display with the commands already given. */
295
 
private int
 
293
static int
296
294
x_sync(gx_device * dev)
297
295
{
298
296
    gx_device_X *xdev = (gx_device_X *) dev;
319
317
}
320
318
 
321
319
/* Output "page" */
322
 
private int
 
320
static int
323
321
x_output_page(gx_device * dev, int num_copies, int flush)
324
322
{
325
323
    gx_device_X *xdev = (gx_device_X *) dev;
342
340
}
343
341
 
344
342
/* Fill a rectangle with a color. */
345
 
private int
 
343
static int
346
344
x_fill_rectangle(gx_device * dev,
347
345
                 int x, int y, int w, int h, gx_color_index gscolor)
348
346
{
373
371
}
374
372
 
375
373
/* Copy a monochrome bitmap. */
376
 
private int
 
374
static int
377
375
x_copy_mono(gx_device * dev,
378
376
            const byte * base, int sourcex, int raster, gx_bitmap_id id,
379
377
            int x, int y, int w, int h,
523
521
}
524
522
 
525
523
/* Internal routine to free the GC and pixmap used for copying. */
526
 
private void
 
524
static void
527
525
free_cp(gx_device * dev)
528
526
{
529
527
    gx_device_X *xdev = (gx_device_X *) dev;
540
538
}
541
539
 
542
540
/* Copy a color bitmap. */
543
 
private int
 
541
static int
544
542
x_copy_image(gx_device_X * xdev, const byte * base, int sourcex, int raster,
545
543
             int x, int y, int w, int h)
546
544
{
586
584
    }
587
585
    return 0;
588
586
}
589
 
private int
 
587
static int
590
588
x_copy_color(gx_device * dev,
591
589
             const byte * base, int sourcex, int raster, gx_bitmap_id id,
592
590
             int x, int y, int w, int h)
606
604
 
607
605
/* Get the page device.  We reimplement this so that we can make this */
608
606
/* device be a page device conditionally. */
609
 
private gx_device *
 
607
static gx_device *
610
608
x_get_page_device(gx_device * dev)
611
609
{
612
610
    return (((gx_device_X *) dev)->IsPageDevice ? dev : (gx_device *) 0);
613
611
}
614
612
 
615
613
/* Tile a rectangle. */
616
 
private int
 
614
static int
617
615
x_strip_tile_rectangle(gx_device * dev, const gx_strip_bitmap * tiles,
618
616
                       int x, int y, int w, int h,
619
617
                       gx_color_index zero, gx_color_index one,
698
696
/* Implement ImageType 2 using CopyArea if possible. */
699
697
/* Note that since ImageType 2 images don't have any source data, */
700
698
/* this procedure does all the work. */
701
 
private int
 
699
static int
702
700
x_begin_typed_image(gx_device * dev,
703
701
                    const gs_imager_state * pis, const gs_matrix * pmat,
704
702
                    const gs_image_common_t * pic, const gs_int_rect * prect,
775
773
}
776
774
 
777
775
/* Read bits back from the screen. */
778
 
private int
 
776
static int
779
777
x_get_bits_rectangle(gx_device * dev, const gs_int_rect * prect,
780
778
                     gs_get_bits_params_t * params, gs_int_rect ** unread)
781
779
{
968
966
 
969
967
/* Set up with a specified tile. */
970
968
/* Return false if we can't do it for some reason. */
971
 
private int
 
969
static int
972
970
set_tile(gx_device * dev, const gx_strip_bitmap * tile)
973
971
{
974
972
    gx_device_X *xdev = (gx_device_X *) dev;
1026
1024
/* ------ Screen update procedures ------ */
1027
1025
 
1028
1026
/* Initialize the update machinery. */
1029
 
private void
 
1027
static void
1030
1028
update_init(gx_device_X *xdev)
1031
1029
{
1032
1030
    xdev->update.box.p.x = xdev->update.box.p.y = max_int_in_fixed;
1035
1033
}
1036
1034
 
1037
1035
/* Flush updates to the screen if needed. */
1038
 
private void
 
1036
static void
1039
1037
update_do_flush(gx_device_X * xdev)
1040
1038
{
1041
1039
    flush_text(xdev);
1125
1123
}
1126
1124
 
1127
1125
/* Flush buffered text to the screen. */
1128
 
private void
 
1126
static void
1129
1127
do_flush_text(gx_device_X * xdev)
1130
1128
{
1131
1129
    if (!IN_TEXT(xdev))
1135
1133
}
1136
1134
 
1137
1135
/* Bounding box device procedures (only used when buffering) */
1138
 
private bool
 
1136
static bool
1139
1137
x_bbox_init_box(void *pdata)
1140
1138
{
1141
1139
    gx_device_X *const xdev = pdata;
1143
1141
    update_init(xdev);
1144
1142
    return true;
1145
1143
}
1146
 
private void
 
1144
static void
1147
1145
x_bbox_get_box(const void *pdata, gs_fixed_rect *pbox)
1148
1146
{
1149
1147
    const gx_device_X *const xdev = pdata;
1153
1151
    pbox->q.x = int2fixed(xdev->update.box.q.x);
1154
1152
    pbox->q.y = int2fixed(xdev->update.box.q.y);
1155
1153
}
1156
 
private void
 
1154
static void
1157
1155
x_bbox_add_rect(void *pdata, fixed x0, fixed y0, fixed x1, fixed y1)
1158
1156
{
1159
1157
    gx_device_X *const xdev = pdata;
1162
1160
    x_update_add(xdev, x, y, fixed2int_ceiling(x1) - x,
1163
1161
                 fixed2int_ceiling(y1) - y);
1164
1162
}
1165
 
private bool
 
1163
static bool
1166
1164
x_bbox_in_rect(const void *pdata, const gs_fixed_rect *pbox)
1167
1165
{
1168
1166
    gs_fixed_rect box;
1181
1179
 * around an apparent bug in some X servers.  It only works with the
1182
1180
 * specific parameters (bit/byte order, padding) used above.
1183
1181
 */
1184
 
private int
 
1182
static int
1185
1183
alt_put_image(gx_device *dev, Display *dpy, Drawable win, GC gc, XImage *pi,
1186
1184
              int sx, int sy, int dx, int dy, unsigned w, unsigned h)
1187
1185
{