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

« back to all changes in this revision

Viewing changes to src/gxclip.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: gxclip.c 8022 2007-06-05 22:23:38Z giles $ */
 
14
/* $Id: gxclip.c 8250 2007-09-25 13:31:24Z giles $ */
15
15
/* Implementation of (path-based) clipping */
16
16
#include "gx.h"
17
17
#include "gxdevice.h"
27
27
/* Device for clipping with a region. */
28
28
/* We forward non-drawing operations, but we must be sure to intercept */
29
29
/* all drawing operations. */
30
 
private dev_proc_open_device(clip_open);
31
 
private dev_proc_fill_rectangle(clip_fill_rectangle);
32
 
private dev_proc_copy_mono(clip_copy_mono);
33
 
private dev_proc_copy_color(clip_copy_color);
34
 
private dev_proc_copy_alpha(clip_copy_alpha);
35
 
private dev_proc_fill_mask(clip_fill_mask);
36
 
private dev_proc_strip_tile_rectangle(clip_strip_tile_rectangle);
37
 
private dev_proc_strip_copy_rop(clip_strip_copy_rop);
38
 
private dev_proc_get_clipping_box(clip_get_clipping_box);
39
 
private dev_proc_get_bits_rectangle(clip_get_bits_rectangle);
 
30
static dev_proc_open_device(clip_open);
 
31
static dev_proc_fill_rectangle(clip_fill_rectangle);
 
32
static dev_proc_copy_mono(clip_copy_mono);
 
33
static dev_proc_copy_color(clip_copy_color);
 
34
static dev_proc_copy_alpha(clip_copy_alpha);
 
35
static dev_proc_fill_mask(clip_fill_mask);
 
36
static dev_proc_strip_tile_rectangle(clip_strip_tile_rectangle);
 
37
static dev_proc_strip_copy_rop(clip_strip_copy_rop);
 
38
static dev_proc_get_clipping_box(clip_get_clipping_box);
 
39
static dev_proc_get_bits_rectangle(clip_get_bits_rectangle);
40
40
 
41
41
/* The device descriptor. */
42
 
private const gx_device_clip gs_clip_device =
 
42
static const gx_device_clip gs_clip_device =
43
43
{std_device_std_body(gx_device_clip, 0, "clipper",
44
44
                     0, 0, 1, 1),
45
45
 {clip_open,
108
108
 
109
109
/* Make a clipping device. */
110
110
void
111
 
gx_make_clip_translate_device(gx_device_clip * dev, const gx_clip_list * list,
112
 
                              int tx, int ty, gs_memory_t *mem)
 
111
gx_make_clip_device_on_stack(gx_device_clip * dev, const gx_clip_path *pcpath, gx_device *target)
113
112
{
114
 
    gx_device_init((gx_device *)dev, (const gx_device *)&gs_clip_device,
115
 
                   mem, true);
116
 
    dev->list = *list;
117
 
    dev->translation.x = tx;
118
 
    dev->translation.y = ty;
 
113
    gx_device_init((gx_device *)dev, (const gx_device *)&gs_clip_device, NULL, true);
 
114
    dev->list = *gx_cpath_list(pcpath);
 
115
    dev->translation.x = 0;
 
116
    dev->translation.y = 0;
 
117
    dev->HWResolution[0] = target->HWResolution[0];
 
118
    dev->HWResolution[1] = target->HWResolution[1];
 
119
    dev->target = target;
 
120
    (*dev_proc(dev, open_device)) ((gx_device *)dev);
119
121
}
120
122
void
121
 
gx_make_clip_path_device(gx_device_clip * dev, const gx_clip_path * pcpath)
 
123
gx_make_clip_device_in_heap(gx_device_clip * dev, const gx_clip_path *pcpath, gx_device *target,
 
124
                              gs_memory_t *mem)
122
125
{
123
 
    gx_make_clip_device(dev, gx_cpath_list(pcpath));
 
126
    gx_device_init((gx_device *)dev, (const gx_device *)&gs_clip_device, mem, true);
 
127
    dev->list = *gx_cpath_list(pcpath);
 
128
    dev->translation.x = 0;
 
129
    dev->translation.y = 0;
 
130
    dev->HWResolution[0] = target->HWResolution[0];
 
131
    dev->HWResolution[1] = target->HWResolution[1];
 
132
    gx_device_set_target((gx_device_forward *)dev, target);
 
133
    gx_device_retain((gx_device *)dev, true); /* will free explicitly */
 
134
    (*dev_proc(dev, open_device)) ((gx_device *)dev);
124
135
}
125
 
 
126
136
/* Define debugging statistics for the clipping loops. */
127
137
#ifdef DEBUG
128
138
struct stats_clip_s {
130
140
         loops, out, in_y, in, in1, down, up, x, no_x;
131
141
} stats_clip;
132
142
 
133
 
private const uint clip_interval = 10000;
 
143
static const uint clip_interval = 10000;
134
144
 
135
145
# define INCR(v) (++(stats_clip.v))
136
146
# define INCR_THEN(v, e) (INCR(v), (e))
143
153
 * Enumerate the rectangles of the x,w,y,h argument that fall within
144
154
 * the clipping region.
145
155
 */
146
 
private int
 
156
static int
147
157
clip_enumerate_rest(gx_device_clip * rdev,
148
158
                    int x, int y, int xe, int ye,
149
159
                    int (*process)(clip_callback_data_t * pccd,
251
261
    return 0;
252
262
}
253
263
 
254
 
private int
 
264
static int
255
265
clip_enumerate(gx_device_clip * rdev, int x, int y, int w, int h,
256
266
               int (*process)(clip_callback_data_t * pccd,
257
267
                              int xc, int yc, int xec, int yec),
278
288
}
279
289
 
280
290
/* Open a clipping device */
281
 
private int
 
291
static int
282
292
clip_open(gx_device * dev)
283
293
{
284
294
    gx_device_clip *const rdev = (gx_device_clip *) dev;
304
314
    return (*dev_proc(pccd->tdev, fill_rectangle))
305
315
        (pccd->tdev, xc, yc, xec - xc, yec - yc, pccd->color[0]);
306
316
}
307
 
private int
 
317
static int
308
318
clip_fill_rectangle(gx_device * dev, int x, int y, int w, int h,
309
319
                    gx_color_index color)
310
320
{
360
370
         pccd->sourcex + xc - pccd->x, pccd->raster, gx_no_bitmap_id,
361
371
         xc, yc, xec - xc, yec - yc, pccd->color[0], pccd->color[1]);
362
372
}
363
 
private int
 
373
static int
364
374
clip_copy_mono(gx_device * dev,
365
375
               const byte * data, int sourcex, int raster, gx_bitmap_id id,
366
376
               int x, int y, int w, int h,
403
413
         pccd->sourcex + xc - pccd->x, pccd->raster, gx_no_bitmap_id,
404
414
         xc, yc, xec - xc, yec - yc);
405
415
}
406
 
private int
 
416
static int
407
417
clip_copy_color(gx_device * dev,
408
418
                const byte * data, int sourcex, int raster, gx_bitmap_id id,
409
419
                int x, int y, int w, int h)
424
434
         pccd->sourcex + xc - pccd->x, pccd->raster, gx_no_bitmap_id,
425
435
         xc, yc, xec - xc, yec - yc, pccd->color[0], pccd->depth);
426
436
}
427
 
private int
 
437
static int
428
438
clip_copy_alpha(gx_device * dev,
429
439
                const byte * data, int sourcex, int raster, gx_bitmap_id id,
430
440
                int x, int y, int w, int h,
448
458
         xc, yc, xec - xc, yec - yc, pccd->pdcolor, pccd->depth,
449
459
         pccd->lop, NULL);
450
460
}
451
 
private int
 
461
static int
452
462
clip_fill_mask(gx_device * dev,
453
463
               const byte * data, int sourcex, int raster, gx_bitmap_id id,
454
464
               int x, int y, int w, int h,
475
485
        (pccd->tdev, pccd->tiles, xc, yc, xec - xc, yec - yc,
476
486
         pccd->color[0], pccd->color[1], pccd->phase.x, pccd->phase.y);
477
487
}
478
 
private int
 
488
static int
479
489
clip_strip_tile_rectangle(gx_device * dev, const gx_strip_bitmap * tiles,
480
490
                          int x, int y, int w, int h,
481
491
     gx_color_index color0, gx_color_index color1, int phase_x, int phase_y)
500
510
         xc, yc, xec - xc, yec - yc, pccd->phase.x, pccd->phase.y,
501
511
         pccd->lop);
502
512
}
503
 
private int
 
513
static int
504
514
clip_strip_copy_rop(gx_device * dev,
505
515
              const byte * sdata, int sourcex, uint raster, gx_bitmap_id id,
506
516
                    const gx_color_index * scolors,
519
529
}
520
530
 
521
531
/* Get the (outer) clipping box, in client coordinates. */
522
 
private void
 
532
static void
523
533
clip_get_clipping_box(gx_device * dev, gs_fixed_rect * pbox)
524
534
{
525
535
    gx_device_clip *const rdev = (gx_device_clip *) dev;
566
576
}
567
577
 
568
578
/* Get bits back from the device. */
569
 
private int
 
579
static int
570
580
clip_get_bits_rectangle(gx_device * dev, const gs_int_rect * prect,
571
581
                        gs_get_bits_params_t * params, gs_int_rect ** unread)
572
582
{