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>
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
19
//========================================================================
24
#ifdef USE_GCC_PRAGMAS
28
#include "SplashTypes.h"
29
#include "SplashMath.h"
30
#include "SplashXPathScanner.h"
36
//------------------------------------------------------------------------
38
enum SplashClipResult {
44
//------------------------------------------------------------------------
46
//------------------------------------------------------------------------
51
// Create a clip, for the given rectangle.
52
SplashClip(SplashCoord x0, SplashCoord y0,
53
SplashCoord x1, SplashCoord y1,
57
SplashClip *copy() { return new SplashClip(this); }
61
// Reset the clip to a rectangle.
62
void resetToRect(SplashCoord x0, SplashCoord y0,
63
SplashCoord x1, SplashCoord y1);
65
// Intersect the clip with a rectangle.
66
SplashError clipToRect(SplashCoord x0, SplashCoord y0,
67
SplashCoord x1, SplashCoord y1);
69
// Interesect the clip with <path>.
70
SplashError clipToPath(SplashPath *path, SplashCoord *matrix,
71
SplashCoord flatness, GBool eo);
73
// Returns true if (<x>,<y>) is inside the clip.
74
GBool test(int x, int y)
78
// check the rectangle
79
if (x < xMinI || x > xMaxI || y < yMinI || y > yMaxI) {
85
for (i = 0; i < length; ++i) {
86
if (!scanners[i]->test(x * splashAASize, y * splashAASize)) {
91
for (i = 0; i < length; ++i) {
92
if (!scanners[i]->test(x, y)) {
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
105
// - splashClipAllOutside if the entire rectangle is outside the
106
// clipping region, i.e., all the pixels in the rectangle are
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);
113
// Similar to testRect, but tests a horizontal span.
114
SplashClipResult testSpan(int spanXMin, int spanXMax, int spanY);
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);
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; }
127
// Get the number of arbitrary paths used by the clip region.
128
int getNumPaths() { return length; }
132
SplashClip(SplashClip *clip);
133
void grow(int nPaths);
136
SplashCoord xMin, yMin, xMax, yMax;
137
int xMinI, yMinI, xMaxI, yMaxI;
140
SplashXPathScanner **scanners;