Coverage Report

Created: 2023-09-25 06:35

/src/xpdf-4.04/splash/SplashClip.h
Line
Count
Source (jump to first uncovered line)
1
//========================================================================
2
//
3
// SplashClip.h
4
//
5
// Copyright 2003-2013 Glyph & Cog, LLC
6
//
7
//========================================================================
8
9
#ifndef SPLASHCLIP_H
10
#define SPLASHCLIP_H
11
12
#include <aconf.h>
13
14
#ifdef USE_GCC_PRAGMAS
15
#pragma interface
16
#endif
17
18
#include "SplashTypes.h"
19
#include "SplashMath.h"
20
21
class SplashPath;
22
class SplashXPath;
23
class SplashXPathScanner;
24
class SplashBitmap;
25
26
//------------------------------------------------------------------------
27
28
enum SplashClipResult {
29
  splashClipAllInside,
30
  splashClipAllOutside,
31
  splashClipPartial
32
};
33
34
//------------------------------------------------------------------------
35
// SplashClip
36
//------------------------------------------------------------------------
37
38
class SplashClip {
39
public:
40
41
  // Create a clip, for the given rectangle.
42
  SplashClip(int hardXMinA, int hardYMinA,
43
       int hardXMaxA, int hardYMaxA);
44
45
  // Copy a clip.
46
0
  SplashClip *copy() { return new SplashClip(this); }
47
48
  ~SplashClip();
49
50
  // Reset the clip to a rectangle.
51
  void resetToRect(SplashCoord x0, SplashCoord y0,
52
       SplashCoord x1, SplashCoord y1);
53
54
  // Intersect the clip with a rectangle.
55
  SplashError clipToRect(SplashCoord x0, SplashCoord y0,
56
       SplashCoord x1, SplashCoord y1);
57
58
  // Interesect the clip with <path>.
59
  SplashError clipToPath(SplashPath *path, SplashCoord *matrix,
60
       SplashCoord flatness, GBool eoA,
61
       GBool enablePathSimplification,
62
       SplashStrokeAdjustMode strokeAdjust);
63
64
  // Tests a rectangle against the clipping region.  Returns one of:
65
  //   - splashClipAllInside if the entire rectangle is inside the
66
  //     clipping region, i.e., all pixels in the rectangle are
67
  //     visible
68
  //   - splashClipAllOutside if the entire rectangle is outside the
69
  //     clipping region, i.e., all the pixels in the rectangle are
70
  //     clipped
71
  //   - splashClipPartial if the rectangle is part inside and part
72
  //     outside the clipping region
73
  SplashClipResult testRect(int rectXMin, int rectYMin,
74
          int rectXMax, int rectYMax,
75
          SplashStrokeAdjustMode strokeAdjust);
76
77
  // Clip a scan line.  Modifies line[] by multiplying with clipping
78
  // shape values for one scan line: ([x0, x1], y).
79
  void clipSpan(Guchar *line, int y, int x0, int x1,
80
    SplashStrokeAdjustMode strokeAdjust);
81
82
  // Like clipSpan(), but uses the values 0 and 255 only.
83
  // Returns true if there are any non-zero values in the result
84
  // (i.e., returns false if the entire line is clipped out).
85
  GBool clipSpanBinary(Guchar *line, int y, int x0, int x1,
86
           SplashStrokeAdjustMode strokeAdjust);
87
88
  // Get the rectangle part of the clip region.
89
0
  SplashCoord getXMin() { return xMin; }
90
0
  SplashCoord getXMax() { return xMax; }
91
0
  SplashCoord getYMin() { return yMin; }
92
0
  SplashCoord getYMax() { return yMax; }
93
94
  // Get the rectangle part of the clip region, in integer coordinates.
95
  int getXMinI(SplashStrokeAdjustMode strokeAdjust);
96
  int getXMaxI(SplashStrokeAdjustMode strokeAdjust);
97
  int getYMinI(SplashStrokeAdjustMode strokeAdjust);
98
  int getYMaxI(SplashStrokeAdjustMode strokeAdjust);
99
100
  // Get the number of arbitrary paths used by the clip region.
101
  int getNumPaths();
102
103
private:
104
105
  SplashClip(SplashClip *clip);
106
  void grow(int nPaths);
107
  void updateIntBounds(SplashStrokeAdjustMode strokeAdjust);
108
109
  int hardXMin, hardYMin, // coordinates cannot fall outside of
110
      hardXMax, hardYMax; //   [hardXMin, hardXMax), [hardYMin, hardYMax)
111
112
  SplashCoord xMin, yMin, // current clip bounding rectangle
113
              xMax, yMax; //   (these coordinates may be adjusted if
114
        //   stroke adjustment is enabled)
115
116
  int xMinI, yMinI, xMaxI, yMaxI;
117
  GBool intBoundsValid;   // true if xMinI, etc. are valid
118
  GBool intBoundsStrokeAdjust;  // value of strokeAdjust used to compute
119
        //   xMinI, etc.
120
121
  SplashXPath **paths;
122
  Guchar *eo;
123
  SplashXPathScanner **scanners;
124
  int length, size;
125
  GBool isSimple;
126
  SplashClip *prev;
127
  Guchar *buf;
128
};
129
130
#endif