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

« back to all changes in this revision

Viewing changes to src/gsalphac.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: gsalphac.c 8022 2007-06-05 22:23:38Z giles $ */
 
14
/* $Id: gsalphac.c 8334 2007-10-30 17:47:49Z leonardo $ */
15
15
/* Alpha-compositing implementation */
16
16
#include "memory_.h"
17
17
#include "gx.h"
88
88
/* ------ Object definition and creation ------ */
89
89
 
90
90
/* Define alpha-compositing objects. */
91
 
private composite_create_default_compositor_proc(c_alpha_create_default_compositor);
92
 
private composite_equal_proc(c_alpha_equal);
93
 
private composite_write_proc(c_alpha_write);
94
 
private composite_read_proc(c_alpha_read);
 
91
static composite_create_default_compositor_proc(c_alpha_create_default_compositor);
 
92
static composite_equal_proc(c_alpha_equal);
 
93
static composite_write_proc(c_alpha_write);
 
94
static composite_read_proc(c_alpha_read);
95
95
const gs_composite_type_t gs_composite_alpha_type =
96
96
{
97
97
    GX_COMPOSITOR_ALPHA,
133
133
 
134
134
#define pacte ((const gs_composite_alpha_t *)pcte)
135
135
 
136
 
private bool
 
136
static bool
137
137
c_alpha_equal(const gs_composite_t * pcte, const gs_composite_t * pcte2)
138
138
{
139
139
    return (pcte2->type == pcte->type &&
144
144
#undef pacte2
145
145
}
146
146
 
147
 
private int
 
147
static int
148
148
c_alpha_write(const gs_composite_t * pcte, byte * data, uint * psize)
149
149
{
150
150
    uint size = *psize;
151
151
    uint used;
152
152
 
 
153
    if_debug1('v', "[v]c_alpha_write(%d)\n", pacte->params.op);
153
154
    if (pacte->params.op == composite_Dissolve) {
154
155
        used = 1 + sizeof(pacte->params.delta);
155
156
        if (size < used) {
169
170
    return 0;
170
171
}
171
172
 
172
 
private int
 
173
static int
173
174
c_alpha_read(gs_composite_t ** ppcte, const byte * data, uint size,
174
175
             gs_memory_t * mem)
175
176
{
179
180
    if (size < 1 || *data > composite_op_last)
180
181
        return_error(gs_error_rangecheck);
181
182
    params.op = *data;
 
183
    if_debug1('v', "[v]c_alpha_read(%d)\n", params.op);
182
184
    if (params.op == composite_Dissolve) {
183
185
        if (size < 1 + sizeof(params.delta))
184
186
            return_error(gs_error_rangecheck);
202
204
    device_c_alpha_enum_ptrs, device_c_alpha_reloc_ptrs, gx_device_finalize,
203
205
                                st_device_forward);
204
206
/* The device descriptor. */
205
 
private dev_proc_close_device(dca_close);
206
 
private dev_proc_fill_rectangle(dca_fill_rectangle);
207
 
private dev_proc_map_rgb_color(dca_map_rgb_color);
208
 
private dev_proc_map_color_rgb(dca_map_color_rgb);
209
 
private dev_proc_copy_mono(dca_copy_mono);
210
 
private dev_proc_copy_color(dca_copy_color);
211
 
private dev_proc_map_rgb_alpha_color(dca_map_rgb_alpha_color);
212
 
private dev_proc_map_color_rgb_alpha(dca_map_color_rgb_alpha);
213
 
private dev_proc_copy_alpha(dca_copy_alpha);
214
 
private const gx_device_composite_alpha gs_composite_alpha_device =
 
207
static dev_proc_close_device(dca_close);
 
208
static dev_proc_fill_rectangle(dca_fill_rectangle);
 
209
static dev_proc_map_rgb_color(dca_map_rgb_color);
 
210
static dev_proc_map_color_rgb(dca_map_color_rgb);
 
211
static dev_proc_copy_mono(dca_copy_mono);
 
212
static dev_proc_copy_color(dca_copy_color);
 
213
static dev_proc_map_rgb_alpha_color(dca_map_rgb_alpha_color);
 
214
static dev_proc_map_color_rgb_alpha(dca_map_color_rgb_alpha);
 
215
static dev_proc_copy_alpha(dca_copy_alpha);
 
216
static const gx_device_composite_alpha gs_composite_alpha_device =
215
217
{std_device_std_body_open(gx_device_composite_alpha, 0,
216
218
                          "alpha compositor", 0, 0, 1, 1),
217
219
 {gx_default_open_device,
259
261
};
260
262
 
261
263
/* Create an alpha compositor. */
262
 
private int
 
264
static int
263
265
c_alpha_create_default_compositor(const gs_composite_t * pcte,
264
266
           gx_device ** pcdev, gx_device * dev, gs_imager_state * pis,
265
267
           gs_memory_t * mem)
303
305
}
304
306
 
305
307
/* Close the device and free its storage. */
306
 
private int
 
308
static int
307
309
dca_close(gx_device * dev)
308
310
{                               /*
309
311
                                 * Finalization will call close again: avoid a recursion loop.
315
317
 
316
318
/* ------ (RGB) color mapping ------ */
317
319
 
318
 
private gx_color_index
 
320
static gx_color_index
319
321
dca_map_rgb_color(gx_device * dev, const gx_color_value cv[])
320
322
{
321
323
    return dca_map_rgb_alpha_color(dev, cv[0], cv[1], cv[2], gx_max_color_value);
322
324
}
323
 
private gx_color_index
 
325
static gx_color_index
324
326
dca_map_rgb_alpha_color(gx_device * dev,
325
327
              gx_color_value red, gx_color_value green, gx_color_value blue,
326
328
                        gx_color_value alpha)
364
366
#undef premult
365
367
    return (color << 8) + a;
366
368
}
367
 
private int
 
369
static int
368
370
dca_map_color_rgb(gx_device * dev, gx_color_index color,
369
371
                  gx_color_value prgb[3])
370
372
{
411
413
#undef postdiv
412
414
    return 0;
413
415
}
414
 
private int
 
416
static int
415
417
dca_map_color_rgb_alpha(gx_device * dev, gx_color_index color,
416
418
                        gx_color_value prgba[4])
417
419
{
421
423
 
422
424
/* ------ Imaging ------ */
423
425
 
424
 
private int
 
426
static int
425
427
dca_fill_rectangle(gx_device * dev, int x, int y, int w, int h,
426
428
                   gx_color_index color)
427
429
{                               /* This is where all the real work gets done! */
516
518
    return code;
517
519
}
518
520
 
519
 
private int
 
521
static int
520
522
dca_copy_mono(gx_device * dev, const byte * data,
521
523
            int dx, int raster, gx_bitmap_id id, int x, int y, int w, int h,
522
524
              gx_color_index zero, gx_color_index one)
526
528
                                zero, one);
527
529
}
528
530
 
529
 
private int
 
531
static int
530
532
dca_copy_color(gx_device * dev, const byte * data,
531
533
               int dx, int raster, gx_bitmap_id id,
532
534
               int x, int y, int w, int h)
535
537
    return gx_default_copy_color(dev, data, dx, raster, id, x, y, w, h);
536
538
}
537
539
 
538
 
private int
 
540
static int
539
541
dca_copy_alpha(gx_device * dev, const byte * data, int data_x,
540
542
           int raster, gx_bitmap_id id, int x, int y, int width, int height,
541
543
               gx_color_index color, int depth)