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

Last change on this file since 461 was 461, checked in by Silvan Scherrer, 11 years ago

poppler update to 0.14.2

File size: 3.9 KB
RevLine 
[2]1//========================================================================
2//
3// SplashClip.h
4//
5//========================================================================
6
[461]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
[2]21#ifndef SPLASHCLIP_H
22#define SPLASHCLIP_H
23
24#ifdef USE_GCC_PRAGMAS
25#pragma interface
26#endif
27
28#include "SplashTypes.h"
[250]29#include "SplashMath.h"
[461]30#include "SplashXPathScanner.h"
[2]31
32class SplashPath;
33class SplashXPath;
[250]34class SplashBitmap;
[2]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,
[250]53             SplashCoord x1, SplashCoord y1,
54             GBool antialiasA);
[2]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>.
[250]70  SplashError clipToPath(SplashPath *path, SplashCoord *matrix,
71                         SplashCoord flatness, GBool eo);
[2]72
73  // Returns true if (<x>,<y>) is inside the clip.
[461]74  GBool test(int x, int y)
75  {
76    int i;
[2]77
[461]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
[2]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
[250]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);
[2]120
[250]121  // Get the rectangle part of the clip region, in integer coordinates.
122  int getXMinI() { return xMinI; }
123  int getXMaxI() { return xMaxI; }
124  int getYMinI() { return yMinI; }
125  int getYMaxI() { return yMaxI; }
126
[2]127  // Get the number of arbitrary paths used by the clip region.
128  int getNumPaths() { return length; }
129
[277]130protected:
[2]131
132  SplashClip(SplashClip *clip);
133  void grow(int nPaths);
134
[250]135  GBool antialias;
136  SplashCoord xMin, yMin, xMax, yMax;
137  int xMinI, yMinI, xMaxI, yMaxI;
[2]138  SplashXPath **paths;
139  Guchar *flags;
140  SplashXPathScanner **scanners;
141  int length, size;
142};
143
144#endif
Note: See TracBrowser for help on using the repository browser.