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

« back to all changes in this revision

Viewing changes to src/gdevpdfd.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: gdevpdfd.c 8179 2007-08-07 00:40:18Z alexcher $ */
 
14
/* $Id: gdevpdfd.c 8265 2007-10-02 07:31:58Z ken $ */
15
15
/* Path drawing procedures for pdfwrite driver */
16
16
#include "math_.h"
17
17
#include "memory_.h"
34
34
#include "gdevpdfg.h"
35
35
#include "gdevpdfo.h"
36
36
#include "gsutil.h"
 
37
#include "gdevpdtf.h"
 
38
#include "gdevpdts.h"
37
39
 
38
40
/* ---------------- Drawing ---------------- */
39
41
 
71
73
 
72
74
/* ------ Vector device implementation ------ */
73
75
 
74
 
private int
 
76
static int
75
77
pdf_setlinewidth(gx_device_vector * vdev, floatp width)
76
78
{
77
79
    /* Acrobat Reader doesn't accept negative line widths. */
78
80
    return psdf_setlinewidth(vdev, fabs(width));
79
81
}
80
82
 
81
 
private int
 
83
static int
82
84
pdf_can_handle_hl_color(gx_device_vector * vdev, const gs_imager_state * pis, 
83
85
                 const gx_drawing_color * pdc)
84
86
{
85
87
    return pis != NULL;
86
88
}
87
89
 
88
 
private int
 
90
static int
89
91
pdf_setfillcolor(gx_device_vector * vdev, const gs_imager_state * pis, 
90
92
                 const gx_drawing_color * pdc)
91
93
{
106
108
                                 &psdf_set_fill_color_commands);
107
109
}
108
110
 
109
 
private int
 
111
static int
110
112
pdf_setstrokecolor(gx_device_vector * vdev, const gs_imager_state * pis, 
111
113
                   const gx_drawing_color * pdc)
112
114
{
127
129
                                 &psdf_set_stroke_color_commands);
128
130
}
129
131
 
130
 
private int
 
132
static int
131
133
pdf_dorect(gx_device_vector * vdev, fixed x0, fixed y0, fixed x1, fixed y1,
132
134
           gx_path_type_t type)
133
135
{
171
173
    return psdf_dorect(vdev, x0, y0, x1, y1, type);
172
174
}
173
175
 
174
 
private int
 
176
static int
175
177
pdf_endpath(gx_device_vector * vdev, gx_path_type_t type)
176
178
{
177
179
    return 0;                   /* always handled by caller */
224
226
}
225
227
 
226
228
/* Check if same clipping path. */
227
 
private int
 
229
static int
228
230
pdf_is_same_clip_path(gx_device_pdf * pdev, const gx_clip_path * pcpath)
229
231
{
230
232
    /* Used for skipping redundant clip paths. SF bug #624168. */
290
292
}
291
293
 
292
294
/* Put a single element of a clipping path list. */
293
 
private int
 
295
static int
294
296
pdf_put_clip_path_list_elem(gx_device_pdf * pdev, gx_cpath_path_list *e, 
295
297
        gs_path_enum *cenum, gdev_vector_dopath_state_t *state,
296
298
        gs_fixed_point vs[3])
423
425
 * CTM will be multiplied by *pscale, and all coordinates will be divided by
424
426
 * *pscale.
425
427
 */
426
 
private bool
 
428
static bool
427
429
make_rect_scaling(const gx_device_pdf *pdev, const gs_fixed_rect *bbox,
428
430
                  floatp prescale, double *pscale)
429
431
{
449
451
 * Return 1 if there is nothing to paint.
450
452
 * Changes *box to the clipping box.
451
453
 */
452
 
private int
 
454
static int
453
455
prepare_fill_with_clip(gx_device_pdf *pdev, const gs_imager_state * pis,
454
456
              gs_fixed_rect *box, bool have_path,
455
457
              const gx_drawing_color * pdcolor, const gx_clip_path * pcpath)
501
503
 
502
504
public_st_pdf_lcvd_t();
503
505
 
504
 
private int 
 
506
static int 
505
507
lcvd_fill_rectangle_shifted(gx_device *dev, int x, int y, int width, int height, gx_color_index color)
506
508
{
507
509
    pdf_lcvd_t *cvd = (pdf_lcvd_t *)dev;
509
511
    return cvd->std_fill_rectangle((gx_device *)&cvd->mdev, 
510
512
        x - cvd->mdev.mapped_x, y - cvd->mdev.mapped_y, width, height, color);
511
513
}
512
 
private int 
 
514
static int 
513
515
lcvd_fill_rectangle_shifted2(gx_device *dev, int x, int y, int width, int height, gx_color_index color)
514
516
{
515
517
    pdf_lcvd_t *cvd = (pdf_lcvd_t *)dev;
522
524
    return cvd->std_fill_rectangle((gx_device *)&cvd->mdev, 
523
525
        x - cvd->mdev.mapped_x, y - cvd->mdev.mapped_y, width, height, color);
524
526
}
525
 
private void
 
527
static void
526
528
lcvd_get_clipping_box_shifted_from_mdev(gx_device *dev, gs_fixed_rect *pbox)
527
529
{
528
530
    fixed ofs;
536
538
    pbox->p.y += ofs;
537
539
    pbox->q.y += ofs;
538
540
}
539
 
private int 
 
541
static int 
540
542
lcvd_pattern_manage(gx_device *pdev1, gx_bitmap_id id,
541
543
                gs_pattern1_instance_t *pinst, pattern_manage_t function)
542
544
{
544
546
        return 1; /* Request shading area. */
545
547
    return 0;
546
548
}
547
 
private int 
 
549
static int 
548
550
lcvd_close_device_with_writing(gx_device *pdev)
549
551
{
550
552
    /* Assuming 'mdev' is being closed before 'mask' - see gx_image3_end_image. */
556
558
    return code < 0 ? code : code1;
557
559
}
558
560
 
559
 
private int
 
561
static int
560
562
write_image(gx_device_pdf *pdev, gx_device_memory *mdev, gs_matrix *m)
561
563
{
562
564
    gs_image_t image;
575
577
        code = pdf_do_image(pdev, writer.pres, NULL, true);
576
578
    return code;
577
579
}
578
 
private int
 
580
static int
579
581
write_mask(gx_device_pdf *pdev, gx_device_memory *mdev, gs_matrix *m)
580
582
{
581
583
    const int sourcex = 0;
595
597
    return code;
596
598
}
597
599
 
598
 
private void
 
600
static void
599
601
max_subimage_width(int width, byte *base, int x0, long count1, int *x1, long *count)
600
602
{
601
603
    long c = 0, c1 = count1 - 1;
627
629
    *x1 = x;
628
630
}
629
631
 
630
 
private void
 
632
static void
631
633
compute_subimage(int width, int height, int raster, byte *base, 
632
634
                 int x0, int y0, long MaxClipPathSize, int *x1, int *y1)
633
635
{
668
670
    }
669
671
}
670
672
 
671
 
private int
 
673
static int
672
674
image_line_to_clip(gx_device_pdf *pdev, byte *base, int x0, int x1, int y0, int y1, bool started)
673
675
{   /* returns the number of segments or error code. */
674
676
    int x = x0, xx;
713
715
    return c;
714
716
}
715
717
 
716
 
private int
 
718
static int
717
719
mask_to_clip(gx_device_pdf *pdev, int width, int height, 
718
720
             int raster, byte *base, int x0, int y0, int x1, int y1)
719
721
{
737
739
    return code < 0 ? code : has_segments ? 1 : 0;
738
740
}
739
741
 
740
 
private int
 
742
static int
741
743
write_subimage(gx_device_pdf *pdev, gx_device_memory *mdev, int x, int y, int x1, int y1)
742
744
{
743
745
    gs_image_t image;
760
762
    return pdf_do_image(pdev, writer.pres, NULL, true);
761
763
}
762
764
 
763
 
private int 
 
765
static int 
764
766
write_image_with_clip(gx_device_pdf *pdev, pdf_lcvd_t *cvd)
765
767
{
766
768
    int x = 0, y = 0;
870
872
                0, 0, cvd->mdev.width, cvd->mdev.height, (gx_color_index)0);
871
873
    return code;
872
874
}
873
 
private int
 
875
static int
874
876
lcvd_handle_fill_path_as_shading_coverage(gx_device *dev,
875
877
    const gs_imager_state *pis, gx_path *ppath,
876
878
    const gx_fill_params *params,
1213
1215
        return 0;               /* won't mark the page */
1214
1216
    if (pdf_must_put_clip_path(pdev, pcpath))
1215
1217
        code = pdf_unclip(pdev);
1216
 
    else 
1217
 
        code = pdf_open_page(pdev, PDF_IN_STREAM);
 
1218
    else if ((pdev->last_charpath_op & TEXT_DO_FALSE_CHARPATH) && ppath->current_subpath && 
 
1219
        (ppath->last_charpath_segment == ppath->current_subpath->last)) {
 
1220
        bool hl_color = pdf_can_handle_hl_color((gx_device_vector *)pdev, pis, pdcolor);
 
1221
        const gs_imager_state *pis_for_hl_color = (hl_color ? pis : NULL);
 
1222
        
 
1223
        if (pdf_modify_text_render_mode(pdev->text->text_state, 1)) {
 
1224
            /* Set the colour for the stroke */
 
1225
            code = pdf_reset_color(pdev, pis_for_hl_color, pdcolor, &pdev->saved_stroke_color, 
 
1226
                        &pdev->stroke_used_process_color, &psdf_set_stroke_color_commands);
 
1227
            if(code == 0) {
 
1228
                s = pdev->strm;
 
1229
                /* Text is emitted scaled so that the CTM is an identity matrix, the line width 
 
1230
                 * needs to be scaled to match otherwise we will get the default, or the current
 
1231
                 * width scaled by the CTM before the text, either of which would be wrong.
 
1232
                 */
 
1233
                pprintg1(s, "%g w\n", (pis->line_params.half_width * 2));
 
1234
                /* Some trickery here. We have altered the colour, text render mode and linewidth,
 
1235
                 * we don't want those to persist. By switching to a stream context we will flush the 
 
1236
                 * pending text. This has the beneficial side effect of executing a grestore. So
 
1237
                 * everything works out neatly.
 
1238
                 */
 
1239
                code = pdf_open_page(pdev, PDF_IN_STREAM);
 
1240
                return(code);
 
1241
            }
 
1242
        }
 
1243
        /* Can only get here if any of the above steps fail, in which case we proceed to
 
1244
         * emit the charpath as a normal path, and stroke it.
 
1245
         */
 
1246
        code = pdf_open_page(pdev, PDF_IN_STREAM);
 
1247
    } else
 
1248
        code = pdf_open_page(pdev, PDF_IN_STREAM);
1218
1249
    if (code < 0)
1219
1250
        return code;
1220
1251
    code = pdf_prepare_stroke(pdev, pis);