~ubuntu-branches/ubuntu/vivid/ghostscript/vivid-security

« back to all changes in this revision

Viewing changes to devices/gdevp2up.c

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2013-08-09 20:01:36 UTC
  • mfrom: (1.1.37)
  • Revision ID: package-import@ubuntu.com-20130809200136-amb6zrr7hnjb5jq9
Tags: 9.08~rc1~dfsg-0ubuntu1
* New upstream release
   - Ghostscript 9.08rc1.
   - We are using the system's liblcms2 and libopenjpeg now.
* debian/patches/020130401-852e545-pxl-xl-driver-produced-drawing-commands-without-setting-color-space.patch:
  Removed patch backported from upstream.
* debian/patches/ojdk-8007925+8007926.patch,
  debian/patches/ojdk-8007927.patch,
  debian/patches/ojdk-8007929.patch,
  debian/patches/ojdk-8009654.patch: Removed patches on build in liblcms2, we
  use the system's liblcms2 now.
* debian/patches/2001_docdir_fix_for_debian.patch: Manually updated to new
  upstream source code.
* debian/patches/2003_support_multiarch.patch: Refreshed with quilt.
* debian/control: Added build dependencies on liblcms2-dev and
  libopenjpeg-dev.
* debian/rules: Check for removed lcms2/ and openjpeg/ subdirectories in
  the repackaging check again, also set build options for shared liblcms2
  and libopenjpeg libraries.
* debian/rules: Makefile.in and configure.ac are in the root directory of
  the source now and do not need to get linked from base/. Also there is no
  gstoraster and gstopxl CUPS filter in the package any more and no
  "install-cups" make target any more.
* debian/control, debian/rules, debian/ghostscript-cups.install,
  debian/ghostscript-cups.ppd-updater: Removed the ghostscript-cups binary
  package. The files are now provided by cups-filters.
* 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
/* Copyright (C) 2001-2012 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.,  7 Mt. Lassen Drive - Suite A-134, San Rafael,
 
13
   CA  94903, U.S.A., +1(415)492-9861, for further information.
 
14
*/
 
15
 
 
16
/* A "2-up" PCX device for testing page objects. */
 
17
#include "gdevprn.h"
 
18
#include "gdevpccm.h"
 
19
#include "gxclpage.h"
 
20
 
 
21
extern gx_device_printer gs_pcx256_device;
 
22
 
 
23
/* ------ The device descriptors ------ */
 
24
 
 
25
/*
 
26
 * Default X and Y resolution.
 
27
 */
 
28
#define X_DPI 72
 
29
#define Y_DPI 72
 
30
 
 
31
/*
 
32
 * Define the size of the rendering buffer.
 
33
 */
 
34
#define RENDER_BUFFER_SPACE 500000
 
35
 
 
36
/* This device only supports SVGA 8-bit color. */
 
37
 
 
38
static dev_proc_open_device(pcx2up_open);
 
39
static dev_proc_print_page(pcx2up_print_page);
 
40
 
 
41
typedef struct gx_device_2up_s {
 
42
    gx_device_common;
 
43
    gx_prn_device_common;
 
44
    bool have_odd_page;
 
45
    gx_saved_page odd_page;
 
46
} gx_device_2up;
 
47
 
 
48
static const gx_device_procs pcx2up_procs =
 
49
prn_color_procs(pcx2up_open, gdev_prn_output_page, gdev_prn_close,
 
50
                pc_8bit_map_rgb_color, pc_8bit_map_color_rgb);
 
51
gx_device_2up gs_pcx2up_device =
 
52
{prn_device_body(gx_device_2up, pcx2up_procs, "pcx2up",
 
53
                 DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
 
54
                 X_DPI, Y_DPI,
 
55
                 0, 0, 0, 0,    /* margins */
 
56
                 3, 8, 5, 5, 6, 6, pcx2up_print_page)
 
57
};
 
58
 
 
59
/* Open the device.  We reimplement this to force banding with */
 
60
/* delayed rasterizing. */
 
61
static int
 
62
pcx2up_open(gx_device * dev)
 
63
{
 
64
    gx_device_printer *pdev = (gx_device_printer *) dev;
 
65
    int code;
 
66
    gdev_prn_space_params save_params;
 
67
 
 
68
    save_params = pdev->space_params;
 
69
    pdev->space_params.MaxBitmap = 0;   /* force banding */
 
70
    pdev->space_params.band.BandWidth =
 
71
        dev->width * 2 + (int)(dev->HWResolution[0] * 2.0);
 
72
    pdev->space_params.band.BandBufferSpace = RENDER_BUFFER_SPACE;
 
73
    code = gdev_prn_open(dev);
 
74
    pdev->space_params = save_params;
 
75
    ((gx_device_2up *) dev)->have_odd_page = false;
 
76
    return code;
 
77
}
 
78
 
 
79
/* Write the page. */
 
80
static int
 
81
pcx2up_print_page(gx_device_printer * pdev, FILE * file)
 
82
{
 
83
    gx_device_2up *pdev2 = (gx_device_2up *) pdev;
 
84
    const gx_device_printer *prdev_template =
 
85
    (const gx_device_printer *)&gs_pcx2up_device;
 
86
 
 
87
    if (!pdev2->have_odd_page) {        /* This is the odd page, just save it. */
 
88
        pdev2->have_odd_page = true;
 
89
        return gdev_prn_save_page(pdev, &pdev2->odd_page, 1);
 
90
    } else {                    /* This is the even page, do 2-up output. */
 
91
        gx_saved_page even_page;
 
92
        gx_placed_page pages[2];
 
93
        int x_offset = (int)(pdev->HWResolution[0] * 0.5);
 
94
        int code = gdev_prn_save_page(pdev, &even_page, 1);
 
95
        int prdev_size = prdev_template->params_size;
 
96
        gx_device_printer *prdev;
 
97
 
 
98
#define rdev ((gx_device *)prdev)
 
99
 
 
100
        if (code < 0)
 
101
            return code;
 
102
        /* Create the placed page list. */
 
103
        pages[0].page = &pdev2->odd_page;
 
104
        pages[0].offset.x = x_offset;
 
105
        pages[0].offset.y = 0 /*y_offset */ ;
 
106
        pages[1].page = &even_page;
 
107
        pages[1].offset.x = pdev->width + x_offset * 3;
 
108
        pages[1].offset.y = 0 /*y_offset */ ;
 
109
        /* Create and open a device for rendering. */
 
110
        prdev = (gx_device_printer *)
 
111
            gs_alloc_bytes(pdev->memory, prdev_size,
 
112
                           "pcx2up_print_page(device)");
 
113
        if (prdev == 0)
 
114
            return_error(gs_error_VMerror);
 
115
        memcpy(prdev, prdev_template, prdev_size);
 
116
        check_device_separable((gx_device *)rdev);
 
117
        gx_device_fill_in_procs(rdev);
 
118
        set_dev_proc(prdev, open_device,
 
119
                     dev_proc(&gs_pcx256_device, open_device));
 
120
        prdev->printer_procs.print_page =
 
121
            gs_pcx256_device.printer_procs.print_page;
 
122
        prdev->space_params.band =
 
123
            pages[0].page->info.band_params;    /* either one will do */
 
124
        prdev->space_params.MaxBitmap = 0;
 
125
        prdev->space_params.BufferSpace =
 
126
            prdev->space_params.band.BandBufferSpace;
 
127
        prdev->width = prdev->space_params.band.BandWidth;
 
128
        prdev->OpenOutputFile = false;
 
129
        code = (*dev_proc(rdev, open_device)) (rdev);
 
130
        if (code < 0)
 
131
            return code;
 
132
        rdev->is_open = true;
 
133
        prdev->file = pdev->file;
 
134
        /* Render the pages. */
 
135
        code = gdev_prn_render_pages(prdev, pages, 2);
 
136
        /* Clean up. */
 
137
        if (pdev->file != 0)
 
138
            prdev->file = 0;    /* don't close it */
 
139
        gs_closedevice(rdev);
 
140
        pdev2->have_odd_page = false;
 
141
        return code;
 
142
#undef rdev
 
143
    }
 
144
}