Debian Codegraph @

libs/xpdf/xpdf-src/splash/SplashClip.h

raw
1 //========================================================================
2 //
3 // SplashClip.h
4 //
5 // Copyright 2003-2013 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 #ifndef SPLASHCLIP_H
10 #define SPLASHCLIP_H
11
12 #include <aconf.h>
13
14 #include "SplashTypes.h"
15 #include "SplashMath.h"
16
17 class SplashPath;
18 class SplashXPath;
19 class SplashXPathScanner;
20 class SplashBitmap;
21
22 //------------------------------------------------------------------------
23
24 enum SplashClipResult {
25 splashClipAllInside,
26 splashClipAllOutside,
27 splashClipPartial
28 };
29
30 //------------------------------------------------------------------------
31 // SplashClip
32 //------------------------------------------------------------------------
33
34 class SplashClip {
35 public:
36
37 // Create a clip, for the given rectangle.
38 SplashClip(int hardXMinA, int hardYMinA,
39 int hardXMaxA, int hardYMaxA);
40
41 // Copy a clip.
42 SplashClip *copy() { return new SplashClip(this); }
43
44 ~SplashClip();
45
46 // Reset the clip to a rectangle.
47 void resetToRect(SplashCoord x0, SplashCoord y0,
48 SplashCoord x1, SplashCoord y1);
49
50 // Intersect the clip with a rectangle.
51 SplashError clipToRect(SplashCoord x0, SplashCoord y0,
52 SplashCoord x1, SplashCoord y1);
53
54 // Interesect the clip with <path>.
55 SplashError clipToPath(SplashPath *path, SplashCoord *matrix,
56 SplashCoord flatness, GBool eoA,
57 GBool enablePathSimplification,
58 SplashStrokeAdjustMode strokeAdjust);
59
60 // Tests a rectangle against the clipping region. Returns one of:
61 // - splashClipAllInside if the entire rectangle is inside the
62 // clipping region, i.e., all pixels in the rectangle are
63 // visible
64 // - splashClipAllOutside if the entire rectangle is outside the
65 // clipping region, i.e., all the pixels in the rectangle are
66 // clipped
67 // - splashClipPartial if the rectangle is part inside and part
68 // outside the clipping region
69 SplashClipResult testRect(int rectXMin, int rectYMin,
70 int rectXMax, int rectYMax,
71 SplashStrokeAdjustMode strokeAdjust);
72
73 // Clip a scan line. Modifies line[] by multiplying with clipping
74 // shape values for one scan line: ([x0, x1], y).
75 void clipSpan(Guchar *line, int y, int x0, int x1,
76 SplashStrokeAdjustMode strokeAdjust);
77
78 // Like clipSpan(), but uses the values 0 and 255 only.
79 // Returns true if there are any non-zero values in the result
80 // (i.e., returns false if the entire line is clipped out).
81 GBool clipSpanBinary(Guchar *line, int y, int x0, int x1,
82 SplashStrokeAdjustMode strokeAdjust);
83
84 // Get the rectangle part of the clip region.
85 SplashCoord getXMin() { return xMin; }
86 SplashCoord getXMax() { return xMax; }
87 SplashCoord getYMin() { return yMin; }
88 SplashCoord getYMax() { return yMax; }
89
90 // Get the rectangle part of the clip region, in integer coordinates.
91 int getXMinI(SplashStrokeAdjustMode strokeAdjust);
92 int getXMaxI(SplashStrokeAdjustMode strokeAdjust);
93 int getYMinI(SplashStrokeAdjustMode strokeAdjust);
94 int getYMaxI(SplashStrokeAdjustMode strokeAdjust);
95
96 // Get the number of arbitrary paths used by the clip region.
97 int getNumPaths();
98
99 // Return true if the clip path is a simple rectangle.
100 GBool getIsSimple() { return isSimple; }
101
102 private:
103
104 SplashClip(SplashClip *clip);
105 void grow(int nPaths);
106 void updateIntBounds(SplashStrokeAdjustMode strokeAdjust);
107
108 int hardXMin, hardYMin, // coordinates cannot fall outside of
109 hardXMax, hardYMax; // [hardXMin, hardXMax), [hardYMin, hardYMax)
110
111 SplashCoord xMin, yMin, // current clip bounding rectangle
112 xMax, yMax;
113
114 int xMinI, yMinI, // integer clip bounding rectangle
115 xMaxI, yMaxI; // (these coordinates are adjusted if
116 // stroke adjustment is enabled)
117 GBool intBoundsValid; // true if xMinI, etc. are valid
118 GBool intBoundsStrokeAdjust; // value of strokeAdjust used to compute
119 // xMinI, etc.
120
121 SplashXPath **paths;
122 Guchar *eo;
123 SplashXPathScanner **scanners;
124 int length, size;
125 GBool isSimple;
126 SplashClip *prev;
127 Guchar *buf;
128 };
129
130 #endif