1 //========================================================================
5 //========================================================================
7 //========================================================================
9 // Modified under the Poppler project - http://poppler.freedesktop.org
11 // All changes made under the Poppler project to this file are licensed
12 // under GPL version 2 or later
14 // Copyright (C) 2010 Albert Astals Cid <aacid@kde.org>
15 // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
17 // To see a description of the changes please see the Changelog file that
18 // came with your tarball or type make ChangeLog if you are building from git
20 //========================================================================
25 #ifdef USE_GCC_PRAGMAS
29 #include "SplashTypes.h"
30 #include "SplashMath.h"
31 #include "SplashXPathScanner.h"
37 //------------------------------------------------------------------------
39 enum SplashClipResult
{
45 //------------------------------------------------------------------------
47 //------------------------------------------------------------------------
52 // Create a clip, for the given rectangle.
53 SplashClip(SplashCoord x0
, SplashCoord y0
,
54 SplashCoord x1
, SplashCoord y1
,
58 SplashClip
*copy() { return new SplashClip(this); }
62 // Reset the clip to a rectangle.
63 void resetToRect(SplashCoord x0
, SplashCoord y0
,
64 SplashCoord x1
, SplashCoord y1
);
66 // Intersect the clip with a rectangle.
67 SplashError
clipToRect(SplashCoord x0
, SplashCoord y0
,
68 SplashCoord x1
, SplashCoord y1
);
70 // Interesect the clip with <path>.
71 SplashError
clipToPath(SplashPath
*path
, SplashCoord
*matrix
,
72 SplashCoord flatness
, GBool eo
);
74 // Returns true if (<x>,<y>) is inside the clip.
75 GBool
test(int x
, int y
)
79 // check the rectangle
80 if (x
< xMinI
|| x
> xMaxI
|| y
< yMinI
|| y
> yMaxI
) {
86 for (i
= 0; i
< length
; ++i
) {
87 if (!scanners
[i
]->test(x
* splashAASize
, y
* splashAASize
)) {
92 for (i
= 0; i
< length
; ++i
) {
93 if (!scanners
[i
]->test(x
, y
)) {
102 // Tests a rectangle against the clipping region. Returns one of:
103 // - splashClipAllInside if the entire rectangle is inside the
104 // clipping region, i.e., all pixels in the rectangle are
106 // - splashClipAllOutside if the entire rectangle is outside the
107 // clipping region, i.e., all the pixels in the rectangle are
109 // - splashClipPartial if the rectangle is part inside and part
110 // outside the clipping region
111 SplashClipResult
testRect(int rectXMin
, int rectYMin
,
112 int rectXMax
, int rectYMax
);
114 // Similar to testRect, but tests a horizontal span.
115 SplashClipResult
testSpan(int spanXMin
, int spanXMax
, int spanY
);
117 // Clips an anti-aliased line by setting pixels to zero. On entry,
118 // all non-zero pixels are between <x0> and <x1>. This function
119 // will update <x0> and <x1>.
120 void clipAALine(SplashBitmap
*aaBuf
, int *x0
, int *x1
, int y
,
121 GBool adjustVertLine
= gFalse
);
123 // Get the rectangle part of the clip region.
124 SplashCoord
getXMin() { return xMin
; }
125 SplashCoord
getXMax() { return xMax
; }
126 SplashCoord
getYMin() { return yMin
; }
127 SplashCoord
getYMax() { return yMax
; }
129 // Get the rectangle part of the clip region, in integer coordinates.
130 int getXMinI() { return xMinI
; }
131 int getXMaxI() { return xMaxI
; }
132 int getYMinI() { return yMinI
; }
133 int getYMaxI() { return yMaxI
; }
135 // Get the number of arbitrary paths used by the clip region.
136 int getNumPaths() { return length
; }
140 SplashClip(SplashClip
*clip
);
141 void grow(int nPaths
);
144 SplashCoord xMin
, yMin
, xMax
, yMax
;
145 int xMinI
, yMinI
, xMaxI
, yMaxI
;
148 SplashXPathScanner
**scanners
;