summaryrefslogtreecommitdiff
path: root/splash/SplashClip.h
diff options
context:
space:
mode:
Diffstat (limited to 'splash/SplashClip.h')
-rw-r--r--splash/SplashClip.h153
1 files changed, 73 insertions, 80 deletions
diff --git a/splash/SplashClip.h b/splash/SplashClip.h
index f91df1fb..a85f8642 100644
--- a/splash/SplashClip.h
+++ b/splash/SplashClip.h
@@ -32,105 +32,98 @@ class SplashBitmap;
//------------------------------------------------------------------------
-enum SplashClipResult {
- splashClipAllInside,
- splashClipAllOutside,
- splashClipPartial
+enum SplashClipResult
+{
+ splashClipAllInside,
+ splashClipAllOutside,
+ splashClipPartial
};
//------------------------------------------------------------------------
// SplashClip
//------------------------------------------------------------------------
-class SplashClip {
+class SplashClip
+{
public:
+ // Create a clip, for the given rectangle.
+ SplashClip(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1, bool antialiasA);
- // Create a clip, for the given rectangle.
- SplashClip(SplashCoord x0, SplashCoord y0,
- SplashCoord x1, SplashCoord y1,
- bool antialiasA);
+ // Copy a clip.
+ SplashClip *copy() { return new SplashClip(this); }
- // Copy a clip.
- SplashClip *copy() { return new SplashClip(this); }
+ ~SplashClip();
- ~SplashClip();
+ SplashClip(const SplashClip &) = delete;
+ SplashClip &operator=(const SplashClip &) = delete;
- SplashClip(const SplashClip &) = delete;
- SplashClip& operator=(const SplashClip &) = delete;
+ // Reset the clip to a rectangle.
+ void resetToRect(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1);
- // Reset the clip to a rectangle.
- void resetToRect(SplashCoord x0, SplashCoord y0,
- SplashCoord x1, SplashCoord y1);
+ // Intersect the clip with a rectangle.
+ SplashError clipToRect(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1);
- // Intersect the clip with a rectangle.
- SplashError clipToRect(SplashCoord x0, SplashCoord y0,
- SplashCoord x1, SplashCoord y1);
+ // Intersect the clip with <path>.
+ SplashError clipToPath(SplashPath *path, SplashCoord *matrix, SplashCoord flatness, bool eo);
- // Intersect the clip with <path>.
- SplashError clipToPath(SplashPath *path, SplashCoord *matrix,
- SplashCoord flatness, bool eo);
+ // Returns true if (<x>,<y>) is inside the clip.
+ bool test(int x, int y)
+ {
+ // check the rectangle
+ if (x < xMinI || x > xMaxI || y < yMinI || y > yMaxI) {
+ return false;
+ }
- // Returns true if (<x>,<y>) is inside the clip.
- bool test(int x, int y)
- {
- // check the rectangle
- if (x < xMinI || x > xMaxI || y < yMinI || y > yMaxI) {
- return false;
+ // check the paths
+ return testClipPaths(x, y);
}
- // check the paths
- return testClipPaths(x, y);
- }
-
- // Tests a rectangle against the clipping region. Returns one of:
- // - splashClipAllInside if the entire rectangle is inside the
- // clipping region, i.e., all pixels in the rectangle are
- // visible
- // - splashClipAllOutside if the entire rectangle is outside the
- // clipping region, i.e., all the pixels in the rectangle are
- // clipped
- // - splashClipPartial if the rectangle is part inside and part
- // outside the clipping region
- SplashClipResult testRect(int rectXMin, int rectYMin,
- int rectXMax, int rectYMax);
-
- // Similar to testRect, but tests a horizontal span.
- SplashClipResult testSpan(int spanXMin, int spanXMax, int spanY);
-
- // Clips an anti-aliased line by setting pixels to zero. On entry,
- // all non-zero pixels are between <x0> and <x1>. This function
- // will update <x0> and <x1>.
- void clipAALine(SplashBitmap *aaBuf, int *x0, int *x1, int y,
- bool adjustVertLine = false);
-
- // Get the rectangle part of the clip region.
- SplashCoord getXMin() { return xMin; }
- SplashCoord getXMax() { return xMax; }
- SplashCoord getYMin() { return yMin; }
- SplashCoord getYMax() { return yMax; }
-
- // Get the rectangle part of the clip region, in integer coordinates.
- int getXMinI() { return xMinI; }
- int getXMaxI() { return xMaxI; }
- int getYMinI() { return yMinI; }
- int getYMaxI() { return yMaxI; }
-
- // Get the number of arbitrary paths used by the clip region.
- int getNumPaths() { return length; }
+ // Tests a rectangle against the clipping region. Returns one of:
+ // - splashClipAllInside if the entire rectangle is inside the
+ // clipping region, i.e., all pixels in the rectangle are
+ // visible
+ // - splashClipAllOutside if the entire rectangle is outside the
+ // clipping region, i.e., all the pixels in the rectangle are
+ // clipped
+ // - splashClipPartial if the rectangle is part inside and part
+ // outside the clipping region
+ SplashClipResult testRect(int rectXMin, int rectYMin, int rectXMax, int rectYMax);
+
+ // Similar to testRect, but tests a horizontal span.
+ SplashClipResult testSpan(int spanXMin, int spanXMax, int spanY);
+
+ // Clips an anti-aliased line by setting pixels to zero. On entry,
+ // all non-zero pixels are between <x0> and <x1>. This function
+ // will update <x0> and <x1>.
+ void clipAALine(SplashBitmap *aaBuf, int *x0, int *x1, int y, bool adjustVertLine = false);
+
+ // Get the rectangle part of the clip region.
+ SplashCoord getXMin() { return xMin; }
+ SplashCoord getXMax() { return xMax; }
+ SplashCoord getYMin() { return yMin; }
+ SplashCoord getYMax() { return yMax; }
+
+ // Get the rectangle part of the clip region, in integer coordinates.
+ int getXMinI() { return xMinI; }
+ int getXMaxI() { return xMaxI; }
+ int getYMinI() { return yMinI; }
+ int getYMaxI() { return yMaxI; }
+
+ // Get the number of arbitrary paths used by the clip region.
+ int getNumPaths() { return length; }
protected:
-
- SplashClip(SplashClip *clip);
- void grow(int nPaths);
- bool testClipPaths(int x, int y);
-
- bool antialias;
- SplashCoord xMin, yMin, xMax, yMax;
- int xMinI, yMinI, xMaxI, yMaxI;
- SplashXPath **paths;
- unsigned char *flags;
- SplashXPathScanner **scanners;
- int length, size;
+ SplashClip(SplashClip *clip);
+ void grow(int nPaths);
+ bool testClipPaths(int x, int y);
+
+ bool antialias;
+ SplashCoord xMin, yMin, xMax, yMax;
+ int xMinI, yMinI, xMaxI, yMaxI;
+ SplashXPath **paths;
+ unsigned char *flags;
+ SplashXPathScanner **scanners;
+ int length, size;
};
#endif