source: trunk/poppler/mypoppler/splash/SplashClip.h @ 515

Last change on this file since 515 was 515, checked in by Silvan Scherrer, 9 years ago

updated poppler to 0.20.3

File size: 4.1 KB
Line 
1//========================================================================
2//
3// SplashClip.h
4//
5//========================================================================
6
7//========================================================================
8//
9// Modified under the Poppler project - http://poppler.freedesktop.org
10//
11// All changes made under the Poppler project to this file are licensed
12// under GPL version 2 or later
13//
14// Copyright (C) 2010 Albert Astals Cid <aacid@kde.org>
15//
16// To see a description of the changes please see the Changelog file that
17// came with your tarball or type make ChangeLog if you are building from git
18//
19//========================================================================
20
21#ifndef SPLASHCLIP_H
22#define SPLASHCLIP_H
23
24#ifdef USE_GCC_PRAGMAS
25#pragma interface
26#endif
27
28#include "SplashTypes.h"
29#include "SplashMath.h"
30#include "SplashXPathScanner.h"
31
32class SplashPath;
33class SplashXPath;
34class SplashBitmap;
35
36//------------------------------------------------------------------------
37
38enum SplashClipResult {
39  splashClipAllInside,
40  splashClipAllOutside,
41  splashClipPartial
42};
43
44//------------------------------------------------------------------------
45// SplashClip
46//------------------------------------------------------------------------
47
48class SplashClip {
49public:
50
51  // Create a clip, for the given rectangle.
52  SplashClip(SplashCoord x0, SplashCoord y0,
53             SplashCoord x1, SplashCoord y1,
54             GBool antialiasA);
55
56  // Copy a clip.
57  SplashClip *copy() { return new SplashClip(this); }
58
59  ~SplashClip();
60
61  // Reset the clip to a rectangle.
62  void resetToRect(SplashCoord x0, SplashCoord y0,
63                   SplashCoord x1, SplashCoord y1);
64
65  // Intersect the clip with a rectangle.
66  SplashError clipToRect(SplashCoord x0, SplashCoord y0,
67                         SplashCoord x1, SplashCoord y1);
68
69  // Interesect the clip with <path>.
70  SplashError clipToPath(SplashPath *path, SplashCoord *matrix,
71                         SplashCoord flatness, GBool eo);
72
73  // Returns true if (<x>,<y>) is inside the clip.
74  GBool test(int x, int y)
75  {
76    int i;
77
78    // check the rectangle
79    if (x < xMinI || x > xMaxI || y < yMinI || y > yMaxI) {
80      return gFalse;
81    }
82
83    // check the paths
84    if (antialias) {
85      for (i = 0; i < length; ++i) {
86        if (!scanners[i]->test(x * splashAASize, y * splashAASize)) {
87          return gFalse;
88        }
89      }
90    } else {
91      for (i = 0; i < length; ++i) {
92        if (!scanners[i]->test(x, y)) {
93          return gFalse;
94        }
95      }
96    }
97
98    return gTrue;
99  }
100
101  // Tests a rectangle against the clipping region.  Returns one of:
102  //   - splashClipAllInside if the entire rectangle is inside the
103  //     clipping region, i.e., all pixels in the rectangle are
104  //     visible
105  //   - splashClipAllOutside if the entire rectangle is outside the
106  //     clipping region, i.e., all the pixels in the rectangle are
107  //     clipped
108  //   - splashClipPartial if the rectangle is part inside and part
109  //     outside the clipping region
110  SplashClipResult testRect(int rectXMin, int rectYMin,
111                            int rectXMax, int rectYMax);
112
113  // Similar to testRect, but tests a horizontal span.
114  SplashClipResult testSpan(int spanXMin, int spanXMax, int spanY);
115
116  // Clips an anti-aliased line by setting pixels to zero.  On entry,
117  // all non-zero pixels are between <x0> and <x1>.  This function
118  // will update <x0> and <x1>.
119  void clipAALine(SplashBitmap *aaBuf, int *x0, int *x1, int y);
120
121  // Get the rectangle part of the clip region.
122  SplashCoord getXMin() { return xMin; }
123  SplashCoord getXMax() { return xMax; }
124  SplashCoord getYMin() { return yMin; }
125  SplashCoord getYMax() { return yMax; }
126
127  // Get the rectangle part of the clip region, in integer coordinates.
128  int getXMinI() { return xMinI; }
129  int getXMaxI() { return xMaxI; }
130  int getYMinI() { return yMinI; }
131  int getYMaxI() { return yMaxI; }
132
133  // Get the number of arbitrary paths used by the clip region.
134  int getNumPaths() { return length; }
135
136protected:
137
138  SplashClip(SplashClip *clip);
139  void grow(int nPaths);
140
141  GBool antialias;
142  SplashCoord xMin, yMin, xMax, yMax;
143  int xMinI, yMinI, xMaxI, yMaxI;
144  SplashXPath **paths;
145  Guchar *flags;
146  SplashXPathScanner **scanners;
147  int length, size;
148};
149
150#endif
Note: See TracBrowser for help on using the repository browser.