File indexing completed on 2025-12-11 10:26:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #ifndef SPLASHCLIP_H
0024 #define SPLASHCLIP_H
0025
0026 #include "SplashTypes.h"
0027
0028 #include <memory>
0029 #include <vector>
0030
0031 class SplashPath;
0032 class SplashXPath;
0033 class SplashXPathScanner;
0034 class SplashBitmap;
0035
0036
0037
0038 enum SplashClipResult
0039 {
0040 splashClipAllInside,
0041 splashClipAllOutside,
0042 splashClipPartial
0043 };
0044
0045
0046
0047
0048
0049 class SplashClip
0050 {
0051 public:
0052
0053 SplashClip(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1, bool antialiasA);
0054
0055
0056 SplashClip *copy() const { return new SplashClip(this); }
0057
0058 ~SplashClip();
0059
0060 SplashClip(const SplashClip &) = delete;
0061 SplashClip &operator=(const SplashClip &) = delete;
0062
0063
0064 void resetToRect(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1);
0065
0066
0067 SplashError clipToRect(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1);
0068
0069
0070 SplashError clipToPath(SplashPath *path, SplashCoord *matrix, SplashCoord flatness, bool eo);
0071
0072
0073 bool test(int x, int y)
0074 {
0075
0076 if (x < xMinI || x > xMaxI || y < yMinI || y > yMaxI) {
0077 return false;
0078 }
0079
0080
0081 return testClipPaths(x, y);
0082 }
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 SplashClipResult testRect(int rectXMin, int rectYMin, int rectXMax, int rectYMax);
0094
0095
0096 SplashClipResult testSpan(int spanXMin, int spanXMax, int spanY);
0097
0098
0099
0100
0101 void clipAALine(SplashBitmap *aaBuf, int *x0, int *x1, int y, bool adjustVertLine = false);
0102
0103
0104 SplashCoord getXMin() { return xMin; }
0105 SplashCoord getXMax() { return xMax; }
0106 SplashCoord getYMin() { return yMin; }
0107 SplashCoord getYMax() { return yMax; }
0108
0109
0110 int getXMinI() { return xMinI; }
0111 int getXMaxI() { return xMaxI; }
0112 int getYMinI() { return yMinI; }
0113 int getYMaxI() { return yMaxI; }
0114
0115
0116 int getNumPaths() { return length; }
0117
0118 protected:
0119 explicit SplashClip(const SplashClip *clip);
0120 void grow(int nPaths);
0121 bool testClipPaths(int x, int y);
0122
0123 bool antialias;
0124 SplashCoord xMin, yMin, xMax, yMax;
0125 int xMinI, yMinI, xMaxI, yMaxI;
0126 unsigned char *flags;
0127 std::vector<std::shared_ptr<SplashXPathScanner>> scanners;
0128 int length, size;
0129 };
0130
0131 #endif