Coverage Report

Created: 2025-06-24 07:01

/src/ghostpdl/base/gdevmr1.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2001-2023 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
/* RasterOp implementation for monobit memory devices */
17
#include "memory_.h"
18
#include "gx.h"
19
#include "gsbittab.h"
20
#include "gserrors.h"
21
#include "gsropt.h"
22
#include "gxcindex.h"
23
#include "gxdcolor.h"
24
#include "gxdevice.h"
25
#include "gxdevmem.h"
26
#include "gdevmem.h"
27
#include "gdevmrop.h"
28
29
/* ---------------- Monobit RasterOp ---------------- */
30
31
/* The guts of this function have been moved to gdevm1.c as
32
 * mem_mono_strip_copy_rop_dev. This function takes care of the color
33
 * mapping and then passes control over to the subsidiary function that
34
 * does everything in device space.
35
 */
36
int
37
mem_mono_strip_copy_rop2(gx_device * dev, const byte * sdata,
38
                         int sourcex,uint sraster, gx_bitmap_id id,
39
                         const gx_color_index * scolors,
40
                         const gx_strip_bitmap * textures,
41
                         const gx_color_index * tcolors,
42
                         int x, int y, int width, int height,
43
                         int phase_x, int phase_y,
44
                         gs_logical_operation_t lop,
45
                         uint planar_height)
46
0
{
47
0
    gx_device_memory *mdev = (gx_device_memory *) dev;
48
0
    gs_rop3_t rop = lop_sanitize(lop);  /* handle transparency */
49
0
    bool invert;
50
51
    /* assert(planar_height == 0); */
52
53
    /* If map_rgb_color isn't the default one for monobit memory */
54
    /* devices, palette might not be set; set it now if needed. */
55
0
    if (mdev->palette.data == 0) {
56
0
        gx_color_value cv[3];
57
0
        cv[0] = cv[1] = cv[2] = 0;
58
0
        gdev_mem_mono_set_inverted(mdev,
59
0
                                   (*dev_proc(dev, encode_color)) (dev, cv) != 0);
60
0
    }
61
0
    invert = mdev->palette.data[0] != 0;
62
63
#ifdef DEBUG
64
    if (gs_debug_c('b'))
65
        trace_copy_rop("mem_mono_strip_copy_rop",
66
                       dev, sdata, sourcex, sraster,
67
                       id, scolors, textures, tcolors,
68
                       x, y, width, height, phase_x, phase_y, lop);
69
    if (gs_debug_c('B'))
70
        debug_dump_bitmap(mdev->memory, scan_line_base(mdev, y), mdev->raster,
71
                          height, "initial dest bits");
72
#endif
73
74
    /*
75
     * RasterOp is defined as operating in RGB space; in the monobit
76
     * case, this means black = 0, white = 1.  However, most monobit
77
     * devices use the opposite convention.  To make this work,
78
     * we must precondition the Boolean operation by swapping the
79
     * order of bits end-for-end and then inverting.
80
     */
81
82
0
    if (invert)
83
0
        rop = byte_reverse_bits[rop & 0xff] ^ 0xff;
84
85
0
    return mem_mono_strip_copy_rop2_dev(dev, sdata, sourcex, sraster, id,
86
0
                                        scolors, textures, tcolors, x, y,
87
0
                                        width, height, phase_x, phase_y,
88
0
                                        (gs_logical_operation_t)rop, 0);
89
0
}