Coverage Report

Created: 2025-06-10 07:27

/src/ghostpdl/devices/vector/gdevpdft.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2001-2025 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.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
17
/* transparency processing for PDF-writing driver */
18
#include "gx.h"
19
#include "string_.h"
20
#include "gserrors.h"
21
#include "gstrans.h"
22
#include "gscolor2.h"
23
#include "gzstate.h"
24
#include "gdevpdfx.h"
25
#include "gdevpdfg.h"
26
#include "gdevpdfo.h"
27
#include "gsccolor.h"
28
29
static int
30
pdf_make_soft_mask_dict(gx_device_pdf * pdev, const gs_pdf14trans_params_t * pparams)
31
275
{
32
275
    pdf_resource_t *pres_soft_mask_dict = 0;
33
275
    cos_dict_t *soft_mask_dict;
34
275
    int code;
35
36
    /* Fixme : merge redundant objects. */
37
275
    code = pdf_alloc_resource(pdev, resourceSoftMaskDict, gs_no_id, &pres_soft_mask_dict, -1);
38
275
    if (code < 0)
39
0
        return code;
40
275
    cos_become(pres_soft_mask_dict->object, cos_type_dict);
41
275
    pdev->pres_soft_mask_dict = pres_soft_mask_dict;
42
275
    soft_mask_dict = (cos_dict_t *)pres_soft_mask_dict->object;
43
275
    code = cos_dict_put_c_key_string(soft_mask_dict, "/S",
44
275
            pparams->subtype == TRANSPARENCY_MASK_Alpha ? (byte *)"/Alpha" : (byte *)"/Luminosity",
45
275
            pparams->subtype == TRANSPARENCY_MASK_Alpha ? 6 : 11);
46
275
    if (code < 0)
47
0
        return code;
48
275
    if (pparams->Background_components) {
49
199
        cos_array_t *Background;
50
51
199
        Background = cos_array_from_floats(pdev, pparams->Background,
52
199
                    pparams->Background_components, "pdf_write_soft_mask_dict");
53
199
        if (Background == NULL)
54
0
            return_error(gs_error_VMerror);
55
199
        code = cos_dict_put_c_key_object(soft_mask_dict, "/BC", (cos_object_t *)Background);
56
199
        if (code < 0)
57
0
            return code;
58
199
    }
59
275
    if (pdev->CompatibilityLevel <= 1.7 && pparams->transfer_function != NULL && pdev->params.TransferFunctionInfo == tfi_Preserve) {
60
53
        int64_t id;
61
53
        char buf[20];
62
63
53
        code = pdf_write_function(pdev, pparams->transfer_function, &id);
64
53
        if (code < 0)
65
0
            return code;
66
53
        gs_snprintf(buf, sizeof(buf), " %"PRId64" 0 R", id);
67
53
        code = cos_dict_put_c_key_string(soft_mask_dict, "/TR", (const byte *)buf, strlen(buf));
68
53
        if (code < 0)
69
0
            return code;
70
53
    }
71
275
    return 0;
72
73
275
}
74
75
static int
76
pdf_make_group_dict(gx_device_pdf * pdev, const gs_pdf14trans_params_t * pparams,
77
                            const gs_gstate * pgs, cos_dict_t **pdict)
78
9.57k
{
79
9.57k
    pdf_resource_t *pres_group;
80
9.57k
    cos_dict_t *group_dict;
81
9.57k
    int code;
82
9.57k
    cos_value_t cs_value;
83
84
9.57k
    code = pdf_alloc_resource(pdev, resourceGroup, gs_no_id, &pres_group, -1);
85
9.57k
    if (code < 0)
86
0
        return code;
87
9.57k
    cos_become(pres_group->object, cos_type_dict);
88
9.57k
    group_dict = (cos_dict_t *)pres_group->object;
89
9.57k
    code = cos_dict_put_c_key_string(group_dict, "/Type", (const byte *)"/Group", 6);
90
9.57k
    if (code < 0)
91
0
        return code;
92
9.57k
    code = cos_dict_put_c_key_string(group_dict, "/S", (const byte *)"/Transparency", 13);
93
9.57k
    if (code < 0)
94
0
        return code;
95
9.57k
    if (pparams->Isolated) {
96
7.15k
        code = cos_dict_put_c_key_bool(group_dict, "/I", true);
97
7.15k
        if (code < 0)
98
0
            return code;
99
7.15k
    }
100
9.57k
    if (pparams->Knockout) {
101
2
        code = cos_dict_put_c_key_bool(group_dict, "/K", true);
102
2
        if (code < 0)
103
0
            return code;
104
2
    }
105
    /* Note that we should not add in the graphic state
106
       color space for the group color if there was not
107
       a group color specified.
108
       In this case, the parent group is inherited from
109
       the previous group or the device color space */
110
9.57k
    if (pgs != NULL && pparams->ColorSpace != NULL) {
111
2.51k
        const gs_color_space *cs = pparams->ColorSpace;
112
113
2.51k
        if (pparams->ColorSpace == NULL)
114
0
            code = pdf_color_space_named(pdev, pgs, &cs_value, NULL, cs,
115
0
                    &pdf_color_space_names, false, NULL, 0, false);
116
2.51k
        else
117
2.51k
            code = pdf_color_space_named(pdev, pgs, &cs_value, NULL, pparams->ColorSpace,
118
2.51k
                    &pdf_color_space_names, false, NULL, 0, false);
119
2.51k
        if (code < 0)
120
0
            return code;
121
2.51k
        code = cos_dict_put_c_key(group_dict, "/CS", &cs_value);
122
2.51k
        if (code < 0)
123
0
            return code;
124
2.51k
    }
125
9.57k
    group_dict = NULL; /* The next line invalidates it. */
126
9.57k
    code = pdf_substitute_resource(pdev, &pres_group, resourceGroup, NULL, false);
127
9.57k
    if (code < 0)
128
0
        return code;
129
9.57k
    pres_group->where_used |= pdev->used_mask;
130
9.57k
    *pdict = (cos_dict_t *)pres_group->object;
131
9.57k
    return 0;
132
9.57k
}
133
134
static int
135
pdf_make_form_dict(gx_device_pdf * pdev, const gs_pdf14trans_params_t * pparams,
136
                            const gs_gstate * pgs,
137
                            const cos_dict_t *group_dict, cos_dict_t *form_dict)
138
3.21k
{
139
3.21k
    cos_array_t *bbox_array;
140
3.21k
    float bbox[4];
141
3.21k
    gs_rect bbox_rect;
142
3.21k
    int code;
143
144
3.21k
    code = gs_bbox_transform(&pparams->bbox, &ctm_only(pgs), &bbox_rect);
145
3.21k
    if (code < 0)
146
0
        return code;
147
3.21k
    bbox[0] = bbox_rect.p.x;
148
3.21k
    bbox[1] = bbox_rect.p.y;
149
3.21k
    bbox[2] = bbox_rect.q.x;
150
3.21k
    bbox[3] = bbox_rect.q.y;
151
3.21k
    code = cos_dict_put_c_key_string(form_dict, "/Type", (const byte *)"/XObject", 8);
152
3.21k
    if (code < 0)
153
0
        return code;
154
3.21k
    code = cos_dict_put_c_key_string(form_dict, "/Subtype", (const byte *)"/Form", 5);
155
3.21k
    if (code < 0)
156
0
        return code;
157
3.21k
    code = cos_dict_put_c_key_int(form_dict, "/FormType", 1);
158
3.21k
    if (code < 0)
159
0
        return code;
160
3.21k
    code = cos_dict_put_c_key_string(form_dict, "/Matrix", (const byte *)"[1 0 0 1 0 0]", 13);
161
3.21k
    if (code < 0)
162
0
        return code;
163
3.21k
    bbox_array = cos_array_from_floats(pdev, bbox, 4, "pdf_begin_transparency_group");
164
3.21k
    if (bbox_array == NULL)
165
0
        return_error(gs_error_VMerror);
166
3.21k
    code = cos_dict_put_c_key_object(form_dict, "/BBox", (cos_object_t *)bbox_array);
167
3.21k
    if (code < 0)
168
0
        return code;
169
3.21k
    if (pdev->PendingOC != 0) {
170
26
        if (pdev->CompatibilityLevel < 1.4999) {
171
0
            if (pdev->PDFA) {
172
0
                switch (pdev->PDFACompatibilityPolicy) {
173
0
                    case 0:
174
0
                        emprintf(pdev->memory,
175
0
                                 "Optional Content not valid in this version of PDF, reverting to normal PDF output\n");
176
0
                        pdev->AbortPDFAX = true;
177
0
                        pdev->PDFA = 0;
178
0
                        break;
179
0
                    case 1:
180
0
                        emprintf(pdev->memory,
181
0
                                 "Optional Content not valid in this version of PDF. Dropping feature to preserve PDF/A compatibility\n");
182
0
                        break;
183
0
                    case 2:
184
0
                        emprintf(pdev->memory,
185
0
                                 "Optional Content not valid in this version of PDF,  aborting conversion\n");
186
0
                        return_error (gs_error_typecheck);
187
0
                        break;
188
0
                    default:
189
0
                        emprintf(pdev->memory,
190
0
                                 "Optional Content not valid in this version of PDF, unrecognised PDFACompatibilityLevel,\nreverting to normal PDF output\n");
191
0
                        pdev->AbortPDFAX = true;
192
0
                        pdev->PDFA = 0;
193
0
                        break;
194
0
                }
195
0
            } else {
196
0
                emprintf(pdev->memory,
197
0
                         "Optional Content not valid in this version of PDF. Dropping feature to preserve compatibility\n");
198
0
            }
199
26
        } else {
200
26
            char str[256];
201
26
            gs_param_string param;
202
26
            cos_object_t *pco = NULL;
203
204
26
            param.data = (const byte *)pdev->PendingOC;
205
26
            param.size = strlen(pdev->PendingOC);
206
26
            code = pdf_refer_named(pdev, &param, &pco);
207
26
            gs_free_object(pdev->memory, pdev->PendingOC, "");
208
26
            if(code < 0)
209
0
                return code;
210
211
26
            gs_snprintf(str, sizeof(str), "%"PRId64" 0 R", pco->id);
212
26
            code = cos_dict_put_string_copy(form_dict, "/OC", str);
213
26
            if (code < 0)
214
0
                return code;
215
216
26
            pdev->PendingOC = 0;
217
26
        }
218
26
    }
219
3.21k
    return cos_dict_put_c_key_object(form_dict, "/Group", (cos_object_t *)group_dict);
220
3.21k
}
221
222
static int
223
pdf_begin_transparency_group(gs_gstate * pgs, gx_device_pdf * pdev,
224
                                const gs_pdf14trans_params_t * pparams, bool page_group)
225
9.57k
{
226
9.57k
    cos_dict_t *group_dict;
227
9.57k
    int code;
228
229
9.57k
    if (pgs == NULL)
230
0
        return_error(gs_error_unregistered); /* Must not happen. */
231
9.57k
    code = pdf_make_group_dict(pdev, pparams, pgs, &group_dict);
232
9.57k
    if (code < 0)
233
0
        return code;
234
9.57k
    code = pdf_open_page(pdev, PDF_IN_STREAM);
235
9.57k
    if (code < 0)
236
0
        return code;
237
9.57k
    code = pdf_check_soft_mask(pdev, pgs);
238
9.57k
    if (code < 0)
239
0
        return code;
240
9.57k
    if (pdf_must_put_clip_path(pdev, pgs->clip_path)) {
241
1.62k
        code = pdf_put_clip_path(pdev, pgs->clip_path);
242
1.62k
        if (code < 0)
243
0
            return code;
244
1.62k
    }
245
9.57k
    if (page_group)
246
647
        pdev->pages[pdev->next_page].group_id = group_dict->id;
247
8.92k
    else if (pparams->image_with_SMask) {
248
        /* An internal group for the image implementation.
249
           See doimagesmask in gs/lib/pdf_draw.ps .
250
           Just set a flag for skipping pdf_end_transparency_group. */
251
5.70k
        pdev->image_with_SMask |= 1 << ++pdev->FormDepth;
252
5.70k
        pdev->PatternsSinceForm = 0;
253
5.70k
    } else {
254
3.21k
        pdf_resource_t *pres, *pres_gstate = NULL;
255
3.21k
        cos_dict_t *pcd = NULL, *pcd_Resources = NULL;
256
257
3.21k
        code = pdf_prepare_drawing(pdev, pgs, &pres_gstate, false);
258
3.21k
        if (code < 0)
259
0
            return code;
260
3.21k
        code = pdf_end_gstate(pdev, pres_gstate);
261
3.21k
        if (code < 0)
262
0
            return code;
263
3.21k
        code = pdf_enter_substream(pdev, resourceXObject,
264
3.21k
                gs_no_id, &pres, false, pdev->params.CompressPages);
265
3.21k
        if (code < 0)
266
0
            return code;
267
3.21k
        pdev->FormDepth++;
268
3.21k
        pdev->PatternsSinceForm = 0;
269
3.21k
        code = pdf_make_form_dict(pdev, pparams, pgs, group_dict, (cos_dict_t *)pres->object);
270
3.21k
        if (code < 0)
271
0
            return code;
272
273
        /* Create a Resources dictionary and add it to the form dictionary */
274
3.21k
        pcd = cos_stream_dict((cos_stream_t *)pres->object);
275
3.21k
        pcd_Resources = cos_dict_alloc(pdev, "pdf_group(Resources)");
276
3.21k
        if (pcd == NULL || pcd_Resources == NULL)
277
0
            return_error(gs_error_VMerror);
278
3.21k
        code = cos_dict_put_c_key_object(pcd, "/Resources", COS_OBJECT(pcd_Resources));
279
3.21k
        pdev->substream_Resources = pcd_Resources;
280
3.21k
        return code;
281
3.21k
    }
282
6.35k
    return 0;
283
9.57k
}
284
285
static int
286
pdf_end_transparency_group(gs_gstate * pgs, gx_device_pdf * pdev)
287
9.29k
{
288
9.29k
    int bottom = (pdev->ResourcesBeforeUsage ? 1 : 0);
289
290
9.29k
    if (!is_in_page(pdev) && pdev->sbstack_depth == 0)
291
2
        return 0;  /* A Group definition at the page level, handled separately. */
292
9.29k
    if (pdev->image_with_SMask & (1 << pdev->FormDepth)) {
293
        /* An internal group for the image implementation.
294
           See pdf_begin_transparency_group. */
295
5.70k
        pdev->image_with_SMask &= ~(1 << pdev->FormDepth--);
296
5.70k
        pdev->PatternsSinceForm = 0;
297
5.70k
        return 0;
298
5.70k
    } else if (pdev->sbstack_depth == bottom) {
299
        /* We're closing the page group. */
300
645
        if (pdev->pages[pdev->next_page].group_id == 0)
301
0
            return_error(gs_error_unregistered); /* Must not happen. */
302
645
        return 0;
303
2.94k
    } else {
304
2.94k
        pdf_resource_t *pres = pdev->accumulating_substream_resource;
305
2.94k
        int code;
306
2.94k
        uint ignore;
307
308
2.94k
        if (pres == NULL)
309
0
            return_error(gs_error_unregistered);
310
2.94k
        pdev->FormDepth--;
311
2.94k
        pdev->PatternsSinceForm = 0;
312
2.94k
        code = pdf_exit_substream(pdev);
313
2.94k
        if (code < 0)
314
0
            return code;
315
2.94k
        code = pdf_substitute_resource(pdev, &pres, resourceXObject, NULL, false);
316
2.94k
        if (code < 0)
317
0
            return code;
318
        /* We need to update the 'where_used' field, in case we substituted a resource */
319
2.94k
        pres->where_used |= pdev->used_mask;
320
2.94k
        sputc(pdev->strm,'/');
321
2.94k
        sputs(pdev->strm, (const byte *)pres->rname, strlen(pres->rname), &ignore);
322
2.94k
        sputs(pdev->strm, (const byte *)" Do\n", 4, &ignore);
323
2.94k
        code = pdf_add_resource(pdev, pdev->substream_Resources, "/XObject", pres);
324
2.94k
        return code;
325
2.94k
    }
326
9.29k
}
327
328
static int
329
pdf_begin_transparency_mask(gs_gstate * pgs, gx_device_pdf * pdev,
330
                                const gs_pdf14trans_params_t * pparams)
331
2.95k
{
332
2.95k
    if (pparams->subtype == TRANSPARENCY_MASK_None) {
333
2.68k
        int code;
334
2.68k
        pdf_resource_t *pres = 0L;
335
336
        /* reset the soft mask ID. Apparently this is only used by pdfwrite, if we don't
337
         * reset it, then the pdf_prepare_drawing code doesn't know that the SMask has
338
         * changed, and so doesn't write out the GState
339
         */
340
2.68k
        pgs->soft_mask_id = 0;
341
2.68k
        code = pdf_prepare_drawing(pdev, pgs, &pres, false);
342
2.68k
        if (code == gs_error_interrupt) {
343
            /* */
344
            /* Not in an appropriate context.  Do not restore the soft_mask_id.
345
               Otherwise any group push that occurs following this will use that
346
               softmask, which clearly should be NONE here.
347
             */
348
            /* ignore return code, we don't care about this graphics state as we aren't
349
             * emitting it anyway
350
             */
351
433
            pdf_end_gstate(pdev, pres);
352
433
            return 0;
353
433
        }
354
2.25k
        if (code < 0)
355
0
            return code;
356
2.25k
        code = pdf_end_gstate(pdev, pres);
357
2.25k
        if (code < 0)
358
0
            return code;
359
2.25k
        return 0;
360
2.25k
    }
361
275
    if (pparams->mask_is_image) {
362
        /* HACK :
363
            The control comes here when
364
            the PDF interpreter will make the PS interpreter
365
            to interprete the mask for filling the transparency buffer
366
            with an SMask image.
367
            Since we handle Type 3 images as a high level objects,
368
            we don't install the transparency buffer here
369
            and need to skip the image enumeration for the SMask.
370
            However we have no right method for skipping
371
            an image enumeration due to possible side effect
372
            of the image data proc in Postscript language.
373
            Therefore we do enumerate the image mask and accumulate
374
            it as a PDF stream, but don't create a reference to it.
375
            Later it will be enumerated once again as a part of SMask-ed image,
376
            and the pdfwrite image handler will recognize duplicated images
377
            and won't create the second stream for same image.
378
379
            We could make a special workaround for
380
            skipping mask images either in the graphics library or
381
            in the PS code of the PDF interpreter,
382
            but we don't want to complicate things now.
383
            The performance leak for the second enumeration
384
            shouldn't be harmful.
385
386
            So now just set a flag for pdf_end_and_do_image.
387
        */
388
0
        pdev->image_mask_skip = true;
389
0
        return 0;
390
275
    } else {
391
275
        int code;
392
393
275
        pdev->smask_construction = true;
394
275
        code = pdf_make_soft_mask_dict(pdev, pparams);
395
275
        if (code < 0)
396
0
            return code;
397
275
        code = pdf_open_page(pdev, PDF_IN_STREAM);
398
275
        if (code < 0)
399
0
            return code;
400
275
        return pdf_begin_transparency_group(pgs, pdev, pparams, 0);
401
275
    }
402
275
}
403
404
static int
405
pdf_end_transparency_mask(gs_gstate * pgs, gx_device_pdf * pdev,
406
                                const gs_pdf14trans_params_t * pparams)
407
275
{
408
275
    pdev->smask_construction = false;
409
275
    if (pdev->image_mask_skip)
410
0
        pdev->image_mask_skip = false;
411
275
    else {
412
275
        pdf_resource_t *pres = pdev->accumulating_substream_resource;
413
275
        int code;
414
275
        char buf[20];
415
416
275
        if (pres == NULL)
417
0
            return_error(gs_error_unregistered);
418
275
        code = pdf_exit_substream(pdev);
419
275
        if (code < 0)
420
0
            return code;
421
275
        code = pdf_substitute_resource(pdev, &pres, resourceXObject, NULL, false);
422
275
        if (code < 0)
423
0
            return 0;
424
        /* We need to update the 'where_used' field, in case we substituted a resource */
425
275
        pres->where_used |= pdev->used_mask;
426
275
        gs_snprintf(buf, sizeof(buf), "%"PRId64" 0 R", pdf_resource_id(pres));
427
275
        if (pdev->pres_soft_mask_dict == 0L) {
428
            /* something went horribly wrong, we have an 'end' wihtout a matching 'begin'
429
             * Give up, throw an error.
430
             */
431
0
            return_error(gs_error_undefined);
432
0
        }
433
275
        code = cos_dict_put_c_key_string((cos_dict_t *)pdev->pres_soft_mask_dict->object,
434
275
                "/G", (const byte *)buf, strlen(buf));
435
275
        if (code < 0)
436
0
            return code;
437
275
        code = pdf_substitute_resource(pdev, &pdev->pres_soft_mask_dict,
438
275
                                        resourceSoftMaskDict, NULL, false);
439
275
        if (code < 0)
440
0
            return code;
441
275
        pdev->pres_soft_mask_dict->where_used |= pdev->used_mask;
442
275
        pgs->soft_mask_id = pdev->pres_soft_mask_dict->object->id;
443
275
        pdev->pres_soft_mask_dict = NULL;
444
        /* We called pdf_start_trnasparency_group (see pdf_begin_transparency_mask
445
         * above) but we don't call pdf_end_transparency_group, so we must reduce
446
         * the FormDepth ourselves.
447
         */
448
275
        pdev->FormDepth--;
449
275
        pdev->PatternsSinceForm = 0;
450
275
    }
451
275
    return 0;
452
275
}
453
454
static int
455
pdf_set_blend_params(gs_gstate * pgs, gx_device_pdf * dev,
456
                                const gs_pdf14trans_params_t * pparams)
457
0
{
458
0
    return 0;
459
0
}
460
461
int
462
gdev_pdf_composite(gx_device *dev,
463
    gx_device **pcdev, const gs_composite_t *pct,
464
    gs_gstate *pgs, gs_memory_t *memory, gx_device *cdev)
465
364k
{
466
364k
    gx_device_pdf *pdev = (gx_device_pdf *)dev;
467
468
364k
    if (pdev->HaveTransparency && pdev->CompatibilityLevel >= 1.4 &&
469
364k
            pct->type->comp_id == GX_COMPOSITOR_PDF14_TRANS &&
470
364k
            pdev->PDFA != 1) {
471
159k
        gs_pdf14trans_t *pcte = (gs_pdf14trans_t *)pct;
472
159k
        gs_pdf14trans_params_t *params = &pcte->params;
473
474
159k
        *pcdev = dev;
475
159k
        switch(params->pdf14_op) {
476
1.44k
            case PDF14_PUSH_DEVICE:
477
1.44k
                return 0;
478
1.44k
            case PDF14_POP_DEVICE:
479
1.44k
                return 0;
480
0
            case PDF14_ABORT_DEVICE:
481
0
                return 0;
482
647
            case PDF14_BEGIN_TRANS_PAGE_GROUP:
483
647
                return pdf_begin_transparency_group(pgs, pdev, params, 1);
484
8.65k
            case PDF14_BEGIN_TRANS_GROUP:
485
8.65k
                return pdf_begin_transparency_group(pgs, pdev, params, 0);
486
9.29k
            case PDF14_END_TRANS_GROUP:
487
9.29k
                return pdf_end_transparency_group(pgs, pdev);
488
65.5k
            case PDF14_BEGIN_TRANS_TEXT_GROUP:
489
65.5k
                return 0;
490
68.0k
            case PDF14_END_TRANS_TEXT_GROUP:
491
68.0k
                return 0;
492
2.95k
            case PDF14_BEGIN_TRANS_MASK:
493
2.95k
                return pdf_begin_transparency_mask(pgs, pdev, params);
494
275
            case PDF14_END_TRANS_MASK:
495
275
                return pdf_end_transparency_mask(pgs, pdev, params);
496
0
            case PDF14_SET_BLEND_PARAMS:
497
0
                return pdf_set_blend_params(pgs, pdev, params);
498
0
            case PDF14_PUSH_TRANS_STATE:
499
0
                return 0;
500
177
            case PDF14_POP_TRANS_STATE:
501
177
                return 0;
502
275
            case PDF14_PUSH_SMASK_COLOR:
503
275
                return 0;
504
275
            case PDF14_POP_SMASK_COLOR:
505
275
                return 0;
506
507
0
            default :
508
0
                return_error(gs_error_unregistered); /* Must not happen. */
509
159k
        }
510
0
        return 0;
511
159k
    }
512
205k
    return psdf_composite(dev, pcdev, pct, pgs, memory, cdev);
513
364k
}
514
515
/* We're not sure why the folllowing device methods are never called.
516
   Stub them for a while. */
517
518
int
519
gdev_pdf_begin_transparency_group(gx_device *dev,
520
    const gs_transparency_group_params_t *ptgp,
521
    const gs_rect *pbbox,
522
    gs_gstate *pgs, gs_memory_t *mem)
523
0
{
524
0
    return 0;
525
0
}
526
527
int
528
gdev_pdf_end_transparency_group(gx_device *dev,
529
    gs_gstate *pgs)
530
0
{
531
0
    return 0;
532
0
}
533
534
int
535
gdev_pdf_begin_transparency_mask(gx_device *dev,
536
    const gx_transparency_mask_params_t *ptmp,
537
    const gs_rect *pbbox,
538
    gs_gstate *pgs, gs_memory_t *mem)
539
0
{
540
0
    return 0;
541
0
}
542
543
int
544
gdev_pdf_end_transparency_mask(gx_device *dev,
545
    gs_gstate *pgs)
546
0
{
547
0
    return 0;
548
0
}