home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 5
/
FreshFish_July-August1994.bin
/
bbs
/
gnu
/
gs-2.6.1.4-src.lha
/
src
/
amiga
/
gs-2.6.1.4
/
gdevx.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-27
|
31KB
|
1,016 lines
/* Copyright (C) 1989, 1992, 1993 Aladdin Enterprises. All rights reserved.
This file is part of Ghostscript.
Ghostscript is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
to anyone for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing. Refer
to the Ghostscript General Public License for full details.
Everyone is granted permission to copy, modify and redistribute
Ghostscript, but only under the conditions described in the Ghostscript
General Public License. A copy of this license is supposed to have been
given to you along with Ghostscript so you can know your rights and
responsibilities. It should be in a file named COPYING. Among other
things, the copyright notice and this notice must be preserved on all
copies. */
/* gdevx.c */
/* X Windows driver for Ghostscript library */
/* The X include files include <sys/types.h>, which, on some machines */
/* at least, define uint, ushort, and ulong, which std.h also defines. */
/* std.h has taken care of this. */
#include "gx.h" /* for gx_bitmap; includes std.h */
#include "memory_.h"
#include "x_.h"
#include "gserrors.h"
#include "gsprops.h"
#include "gsutil.h" /* for props_extract */
#include "gxdevice.h"
#include "gdevx.h"
/* Define the maximum size of the temporary pixmap for copy_mono */
/* that we are willing to leave lying around in the server */
/* between uses. (Assume 32-bit ints here!) */
private int max_temp_pixmap = 20000;
/* Forward references */
private int set_tile(P2(gx_device *, const gx_bitmap *));
private void free_cp(P1(gx_device *));
/* Screen updating machinery */
#define update_init(dev)\
((gx_device_X *)(dev))->up_area = 0,\
((gx_device_X *)(dev))->up_count = 0
#define update_flush(dev)\
if ( ((gx_device_X *)(dev))->up_area != 0 ) update_do_flush(dev)
private void update_do_flush(P1(gx_device *));
private void x_send_event(P2(gx_device *, Atom));
/* Procedures */
extern int gdev_x_open(P1(gx_device_X *));
private dev_proc_open_device(x_open);
private dev_proc_get_initial_matrix(x_get_initial_matrix);
private dev_proc_sync_output(x_sync);
private dev_proc_output_page(x_output_page);
private dev_proc_close_device(x_close);
private dev_proc_map_rgb_color(x_map_rgb_color);
private dev_proc_map_color_rgb(x_map_color_rgb);
private dev_proc_fill_rectangle(x_fill_rectangle);
private dev_proc_tile_rectangle(x_tile_rectangle);
private dev_proc_copy_mono(x_copy_mono);
private dev_proc_copy_color(x_copy_color);
private dev_proc_draw_line(x_draw_line);
private dev_proc_put_props(x_put_props);
dev_proc_get_xfont_procs(x_get_xfont_procs);
/* The device descriptor */
private gx_device_procs x_procs = {
x_open,
x_get_initial_matrix,
x_sync,
x_output_page,
x_close,
x_map_rgb_color,
x_map_color_rgb,
x_fill_rectangle,
x_tile_rectangle,
x_copy_mono,
x_copy_color,
x_draw_line,
gx_default_get_bits,
gx_default_get_props,
x_put_props,
NULL,
x_get_xfont_procs
};
/* The instance is public. */
gx_device_X gs_x11_device = {
sizeof(gx_device_X),
&x_procs,
"x11",
(int)(8.5*FAKE_RES),
(int)(11*FAKE_RES), /* x and y extent (nominal) */
FAKE_RES, FAKE_RES, /* x and y density (nominal) */
no_margins,
dci_black_and_white,
0, /* connection not initialized */
{ /* image */
0, 0, /* width, height */
0, XYBitmap, NULL, /* xoffset, format, data */
LSBFirst, 8, /* byte-order, bitmap-unit */
MSBFirst, 8, 1, /* bitmap-bit-order, bitmap-pad, depth */
0, 1, /* bytes_per_line, bits_per_pixel */
0, 0, 0, /* red_mask, green_mask, blue_mask */
NULL, /* *obdata */
{ NULL, /* *(*create_image)() */
NULL, /* (*destroy_image)() */
NULL, /* (*get_pixel)() */
NULL, /* (*put_pixel)() */
NULL, /* *(*sub_image)() */
NULL /* (*add_pixel)() */
},
},
NULL, NULL, /* dpy, scr */
/* (connection not initialized) */
NULL, /* vinfo */
(Colormap)None, /* cmap */
(Window)None, /* win */
NULL, /* gc */
(Pixmap)0, /* bpixmap */
0, /* ghostview */
(Window)None, /* mwin */
#if HaveStdCMap
NULL, /* std_cmap */
#endif
identity_matrix_body, /* initial matrix (filled in) */
(Atom)0, (Atom)0, (Atom)0, /* Atoms: NEXT, PAGE, DONE */
{ 0, 0, 0, 0 }, 0, 0, /* update, up_area, up_count */
(Pixmap)0, /* dest */
0L, ~0L, /* colors_or, colors_and */
{ /* cp */
(Pixmap)0, /* pixmap */
NULL, /* gc */
-1, -1 /* raster, height */
},
{ /* ht */
(Pixmap)None, /* pixmap */
(Pixmap)None, /* no_pixmap */
gx_no_bitmap_id, /* id */
0, 0, 0, /* width, height, raster */
0, 0 /* fore_c, back_c */
},
GXcopy, /* function */
FillSolid, /* fill_style */
0, /* font */
0, 0, /* back_color, fore_color */
0, 0, /* background, foreground */
NULL, /* dither_colors */
0, 0, /* color_mask, half_dev_color */
NULL, /* dynamic_colors */
0, 0, /* dynamic_size, dynamic_number */
0, 0, /* borderColor, borderWidth */
NULL, /* geometry */
128, 5, /* maxGrayRamp, maxRGBRamp */
NULL, /* palette */
NULL, NULL, NULL, /* regularFonts, symbolFonts, dingbatFonts */
NULL, NULL, NULL, /* regular_fonts, symbol_fonts, dingbat_fonts */
1, 1, /* useXFonts, useFontExtensions */
1, 0, /* useScalableFonts, logXFonts */
0.0, 0.0, /* xResolution, yResolution */
1, /* useBackingPixmap */
1, 1, /* useXPutImage, useXSetTile */
};
/* If XPutImage doesn't work, do it ourselves. */
private void alt_put_image();
#define put_image(dpy,win,gc,im,sx,sy,x,y,w,h)\
if ( xdev->useXPutImage) XPutImage(dpy,win,gc,im,sx,sy,x,y,w,h);\
else alt_put_image(dev,dpy,win,gc,im,sx,sy,x,y,w,h)
/* Open the device. Most of the code is in gdevxini.c. */
private int
x_open(gx_device *dev)
{
gx_device_X *xdev = (gx_device_X *)dev;
int code = gdev_x_open(xdev);
if (code < 0) return code;
update_init(dev);
return 0;
}
/* Close the device. */
private int
x_close(gx_device *dev)
{
gx_device_X *xdev = (gx_device_X *)dev;
if (xdev->ghostview) x_send_event(dev, xdev->done);
if (xdev->vinfo) {
XFree((char *)xdev->vinfo);
xdev->vinfo = NULL;
}
if (xdev->dither_colors) {
if (gx_device_has_color(xdev))
#define cube(r) (r*r*r)
gs_free((char *)xdev->dither_colors, sizeof(x_pixel),
cube(xdev->color_info.dither_rgb), "gdev_x_rgb_cube");
#undef cube
else
gs_free((char *)xdev->dither_colors, sizeof(x_pixel),
xdev->color_info.dither_gray, "gdev_x_gray_ramp");
xdev->dither_colors = NULL;
}
if (xdev->dynamic_colors) {
gs_free((char *)xdev->dynamic_colors, sizeof(XColor),
xdev->dynamic_size, "gdev_x_dynamic_colors");
xdev->dynamic_colors = NULL;
}
while (xdev->regular_fonts) {
x11fontmap *font = xdev->regular_fonts;
xdev->regular_fonts = font->next;
if (font->std_names) XFreeFontNames(font->std_names);
if (font->iso_names) XFreeFontNames(font->iso_names);
gs_free(font->x11_name, sizeof(char), strlen(font->x11_name)+1,
"gdev_x_font_x11name");
gs_free(font->ps_name, sizeof(char), strlen(font->ps_name)+1,
"gdev_x_font_psname");
gs_free((char *)font, sizeof(x11fontmap), 1, "gdev_x_fontmap");
}
while (xdev->symbol_fonts) {
x11fontmap *font = xdev->symbol_fonts;
xdev->symbol_fonts = font->next;
if (font->std_names) XFreeFontNames(font->std_names);
if (font->iso_names) XFreeFontNames(font->iso_names);
gs_free(font->x11_name, sizeof(char), strlen(font->x11_name)+1,
"gdev_x_font_x11name");
gs_free(font->ps_name, sizeof(char), strlen(font->ps_name)+1,
"gdev_x_font_psname");
gs_free((char *)font, sizeof(x11fontmap), 1, "gdev_x_fontmap");
}
while (xdev->dingbat_fonts) {
x11fontmap *font = xdev->dingbat_fonts;
xdev->dingbat_fonts = font->next;
if (font->std_names) XFreeFontNames(font->std_names);
if (font->iso_names) XFreeFontNames(font->iso_names);
gs_free(font->x11_name, sizeof(char), strlen(font->x11_name)+1,
"gdev_x_font_x11name");
gs_free(font->ps_name, sizeof(char), strlen(font->ps_name)+1,
"gdev_x_font_psname");
gs_free((char *)font, sizeof(x11fontmap), 1, "gdev_x_fontmap");
}
XCloseDisplay(x