/src/ghostpdl/base/claptrap-impl.h
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 | | #ifndef CLAPTRAP_IMPL_H |
17 | | #define CLAPTRAP_IMPL_H |
18 | | |
19 | | #include "claptrap.h" |
20 | | |
21 | | /* The API for this is that the caller requests trapped scanlines. |
22 | | * We rely on being able to request untrapped scanlines from a source. |
23 | | * Because we need to look ahead (and behind) of the current position |
24 | | * to calculate whether trapping is needed at a given point, we use a |
25 | | * rolling buffer to hold several scanlines. |
26 | | * |
27 | | * First we examine the buffered data to calculate a 'process map'. |
28 | | * The process map says whether we need to consider 'smearing' |
29 | | * component i at position(x, y). If we ever consider trapping |
30 | | * component i, we will also consider trapping component i+1. |
31 | | * |
32 | | * We need to have processed line y+max_y_offset in order to be |
33 | | * sure that the process map for line y is complete. |
34 | | */ |
35 | | |
36 | | struct ClapTrap |
37 | | { |
38 | | ClapTrap_LineFn *get_line; |
39 | | void *get_line_arg; |
40 | | int width; |
41 | | int height; |
42 | | int num_comps; |
43 | | const int *comp_order; |
44 | | int max_x_offset; |
45 | | int max_y_offset; |
46 | | int lines_in_buf; /* How many lines we can store in linebuf (2*max_y_offset+1) */ |
47 | | unsigned char *linebuf; |
48 | | int lines_read; /* How many lines we have read into linebuf so far */ |
49 | | int y; /* Which output line we are on */ |
50 | | int span; |
51 | | unsigned char *process; |
52 | | }; |
53 | | |
54 | | /* Evaluate whether a given component should 'shadow' components |
55 | | * under it (i.e. if the component plane 'comp' was printed |
56 | | * offset, would it noticably change the amount of the colours |
57 | | * under it that could be seen) */ |
58 | | inline static int shadow_here(int v, int min_v, int comp) |
59 | 0 | { |
60 | 0 | return (min_v < 0.8 * v && min_v < v - 16); |
61 | 0 | } Unexecuted instantiation: claptrap.c:shadow_here Unexecuted instantiation: claptrap-init.c:shadow_here Unexecuted instantiation: claptrap-planar.c:shadow_here |
62 | | |
63 | | /* Given that component comp might be exposed by a higher |
64 | | * plane being offset, would the value exposed here be |
65 | | * noticably different from the values around it? */ |
66 | | inline static int trap_here(int v, int max_v, int comp) |
67 | 0 | { |
68 | 0 | return (v < 0.8 * max_v); |
69 | 0 | } Unexecuted instantiation: claptrap.c:trap_here Unexecuted instantiation: claptrap-init.c:trap_here Unexecuted instantiation: claptrap-planar.c:trap_here |
70 | | |
71 | | #endif /* CLAPTRAP_IMPL_H */ |