11
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
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 */
17
17
#include "memory_.h"
72
74
/* ------ Vector device implementation ------ */
75
77
pdf_setlinewidth(gx_device_vector * vdev, floatp width)
77
79
/* Acrobat Reader doesn't accept negative line widths. */
78
80
return psdf_setlinewidth(vdev, fabs(width));
82
84
pdf_can_handle_hl_color(gx_device_vector * vdev, const gs_imager_state * pis,
83
85
const gx_drawing_color * pdc)
85
87
return pis != NULL;
89
91
pdf_setfillcolor(gx_device_vector * vdev, const gs_imager_state * pis,
90
92
const gx_drawing_color * pdc)
127
129
&psdf_set_stroke_color_commands);
131
133
pdf_dorect(gx_device_vector * vdev, fixed x0, fixed y0, fixed x1, fixed y1,
132
134
gx_path_type_t type)
171
173
return psdf_dorect(vdev, x0, y0, x1, y1, type);
175
177
pdf_endpath(gx_device_vector * vdev, gx_path_type_t type)
177
179
return 0; /* always handled by caller */
292
294
/* Put a single element of a clipping path list. */
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
427
429
make_rect_scaling(const gx_device_pdf *pdev, const gs_fixed_rect *bbox,
428
430
floatp prescale, double *pscale)
449
451
* Return 1 if there is nothing to paint.
450
452
* Changes *box to the clipping box.
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)
502
504
public_st_pdf_lcvd_t();
505
507
lcvd_fill_rectangle_shifted(gx_device *dev, int x, int y, int width, int height, gx_color_index color)
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);
513
515
lcvd_fill_rectangle_shifted2(gx_device *dev, int x, int y, int width, int height, gx_color_index color)
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);
526
528
lcvd_get_clipping_box_shifted_from_mdev(gx_device *dev, gs_fixed_rect *pbox)
575
577
code = pdf_do_image(pdev, writer.pres, NULL, true);
579
581
write_mask(gx_device_pdf *pdev, gx_device_memory *mdev, gs_matrix *m)
581
583
const int sourcex = 0;
599
601
max_subimage_width(int width, byte *base, int x0, long count1, int *x1, long *count)
601
603
long c = 0, c1 = count1 - 1;
631
633
compute_subimage(int width, int height, int raster, byte *base,
632
634
int x0, int y0, long MaxClipPathSize, int *x1, int *y1)
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. */
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)
737
739
return code < 0 ? code : has_segments ? 1 : 0;
741
743
write_subimage(gx_device_pdf *pdev, gx_device_memory *mdev, int x, int y, int x1, int y1)
743
745
gs_image_t image;
870
872
0, 0, cvd->mdev.width, cvd->mdev.height, (gx_color_index)0);
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);
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);
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);
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.
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.
1239
code = pdf_open_page(pdev, PDF_IN_STREAM);
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.
1246
code = pdf_open_page(pdev, PDF_IN_STREAM);
1248
code = pdf_open_page(pdev, PDF_IN_STREAM);
1220
1251
code = pdf_prepare_stroke(pdev, pis);