]> www.fi.muni.cz Git - evince.git/blob - pdf/splash/SplashClip.h
guard against unloaded docs when the title is accessed.
[evince.git] / pdf / splash / SplashClip.h
1 //========================================================================
2 //
3 // SplashClip.h
4 //
5 //========================================================================
6
7 #ifndef SPLASHCLIP_H
8 #define SPLASHCLIP_H
9
10 #include <aconf.h>
11
12 #ifdef USE_GCC_PRAGMAS
13 #pragma interface
14 #endif
15
16 #include "SplashTypes.h"
17
18 class SplashPath;
19 class SplashXPath;
20 class SplashXPathScanner;
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(SplashCoord x0, SplashCoord y0,
39              SplashCoord x1, SplashCoord y1);
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 flatness,
56                          GBool eo);
57
58   // Returns true if (<x>,<y>) is inside the clip.
59   GBool test(int x, int y);
60
61   // Tests a rectangle against the clipping region.  Returns one of:
62   //   - splashClipAllInside if the entire rectangle is inside the
63   //     clipping region, i.e., all pixels in the rectangle are
64   //     visible
65   //   - splashClipAllOutside if the entire rectangle is outside the
66   //     clipping region, i.e., all the pixels in the rectangle are
67   //     clipped
68   //   - splashClipPartial if the rectangle is part inside and part
69   //     outside the clipping region
70   SplashClipResult testRect(int rectXMin, int rectYMin,
71                             int rectXMax, int rectYMax);
72
73   // Similar to testRect, but tests a horizontal span.
74   SplashClipResult testSpan(int spanXMin, int spanXMax, int spanY);
75
76 private:
77
78   SplashClip(SplashClip *clip);
79   void grow(int nPaths);
80
81   int xMin, yMin, xMax, yMax;
82   SplashXPath **paths;
83   Guchar *flags;
84   SplashXPathScanner **scanners;
85   int length, size;
86 };
87
88 #endif