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
0024
0025
0026
0027 #ifndef SPLASH_H
0028 #define SPLASH_H
0029
0030 #include <cstddef>
0031 #include "SplashTypes.h"
0032 #include "SplashClip.h"
0033 #include "SplashPattern.h"
0034 #include "poppler_private_export.h"
0035
0036 class SplashBitmap;
0037 struct SplashGlyphBitmap;
0038 class SplashState;
0039 class SplashScreen;
0040 class SplashPath;
0041 class SplashXPath;
0042 class SplashFont;
0043 struct SplashPipe;
0044
0045
0046
0047
0048
0049
0050 typedef bool (*SplashImageMaskSource)(void *data, SplashColorPtr pixel);
0051
0052
0053
0054
0055 typedef bool (*SplashImageSource)(void *data, SplashColorPtr colorLine, unsigned char *alphaLine);
0056
0057
0058 typedef void (*SplashICCTransform)(void *data, SplashBitmap *bitmap);
0059
0060
0061
0062 enum SplashPipeResultColorCtrl
0063 {
0064 splashPipeResultColorNoAlphaBlendCMYK,
0065 splashPipeResultColorNoAlphaBlendDeviceN,
0066 splashPipeResultColorNoAlphaBlendRGB,
0067 splashPipeResultColorNoAlphaBlendMono,
0068 splashPipeResultColorAlphaNoBlendMono,
0069 splashPipeResultColorAlphaNoBlendRGB,
0070 splashPipeResultColorAlphaNoBlendCMYK,
0071 splashPipeResultColorAlphaNoBlendDeviceN,
0072 splashPipeResultColorAlphaBlendMono,
0073 splashPipeResultColorAlphaBlendRGB,
0074 splashPipeResultColorAlphaBlendCMYK,
0075 splashPipeResultColorAlphaBlendDeviceN
0076 };
0077
0078
0079
0080
0081
0082 class POPPLER_PRIVATE_EXPORT Splash
0083 {
0084 public:
0085
0086 Splash(SplashBitmap *bitmapA, bool vectorAntialiasA, SplashScreenParams *screenParams = nullptr);
0087 Splash(SplashBitmap *bitmapA, bool vectorAntialiasA, SplashScreen *screenA);
0088
0089 ~Splash();
0090
0091 Splash(const Splash &) = delete;
0092 Splash &operator=(const Splash &) = delete;
0093
0094
0095
0096 SplashCoord *getMatrix();
0097 SplashPattern *getStrokePattern();
0098 SplashPattern *getFillPattern();
0099 SplashScreen *getScreen();
0100 SplashBlendFunc getBlendFunc();
0101 SplashCoord getStrokeAlpha();
0102 SplashCoord getFillAlpha();
0103 SplashCoord getLineWidth();
0104 int getLineCap();
0105 int getLineJoin();
0106 SplashCoord getMiterLimit();
0107 SplashCoord getFlatness();
0108 SplashCoord getLineDashPhase();
0109 bool getStrokeAdjust();
0110 SplashClip *getClip();
0111 SplashBitmap *getSoftMask();
0112 bool getInNonIsolatedGroup();
0113
0114
0115
0116 void setMatrix(SplashCoord *matrix);
0117 void setStrokePattern(SplashPattern *strokePattern);
0118 void setFillPattern(SplashPattern *fillPattern);
0119 void setScreen(SplashScreen *screen);
0120 void setBlendFunc(SplashBlendFunc func);
0121 void setStrokeAlpha(SplashCoord alpha);
0122 void setFillAlpha(SplashCoord alpha);
0123 void setPatternAlpha(SplashCoord strokeAlpha, SplashCoord fillAlpha);
0124 void clearPatternAlpha();
0125 void setFillOverprint(bool fop);
0126 void setStrokeOverprint(bool sop);
0127 void setOverprintMode(int opm);
0128 void setLineWidth(SplashCoord lineWidth);
0129 void setLineCap(int lineCap);
0130 void setLineJoin(int lineJoin);
0131 void setMiterLimit(SplashCoord miterLimit);
0132 void setFlatness(SplashCoord flatness);
0133
0134 void setLineDash(std::vector<SplashCoord> &&lineDash, SplashCoord lineDashPhase);
0135 void setStrokeAdjust(bool strokeAdjust);
0136
0137 void clipResetToRect(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1);
0138
0139 SplashError clipToRect(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1);
0140
0141 SplashError clipToPath(SplashPath *path, bool eo);
0142 void setSoftMask(SplashBitmap *softMask);
0143 void setInNonIsolatedGroup(SplashBitmap *alpha0BitmapA, int alpha0XA, int alpha0YA);
0144 void setTransfer(unsigned char *red, unsigned char *green, unsigned char *blue, unsigned char *gray);
0145 void setOverprintMask(unsigned int overprintMask, bool additive);
0146
0147
0148
0149 void saveState();
0150 SplashError restoreState();
0151
0152
0153
0154
0155 void clear(SplashColorPtr color, unsigned char alpha = 0x00);
0156
0157
0158 SplashError stroke(SplashPath *path);
0159
0160
0161 SplashError fill(SplashPath *path, bool eo);
0162
0163
0164 SplashError xorFill(SplashPath *path, bool eo);
0165
0166
0167 SplashError fillChar(SplashCoord x, SplashCoord y, int c, SplashFont *font);
0168
0169
0170
0171 void fillGlyph(SplashCoord x, SplashCoord y, SplashGlyphBitmap *glyph);
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186 SplashError fillImageMask(SplashImageMaskSource src, void *srcData, int w, int h, SplashCoord *mat, bool glyphMode);
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203 SplashError drawImage(SplashImageSource src, SplashICCTransform tf, void *srcData, SplashColorMode srcMode, bool srcAlpha, int w, int h, SplashCoord *mat, bool interpolate, bool tilingPattern = false);
0204
0205
0206
0207 SplashError composite(SplashBitmap *src, int xSrc, int ySrc, int xDest, int yDest, int w, int h, bool noClip, bool nonIsolated, bool knockout = false, SplashCoord knockoutOpacity = 1.0);
0208
0209
0210
0211 void compositeBackground(SplashColorConstPtr color);
0212
0213
0214
0215
0216 SplashError blitTransparent(SplashBitmap *src, int xSrc, int ySrc, int xDest, int yDest, int w, int h);
0217 void blitImage(SplashBitmap *src, bool srcAlpha, int xDest, int yDest);
0218
0219
0220
0221
0222
0223
0224
0225 SplashPath *makeStrokePath(SplashPath *path, SplashCoord w, bool flatten = true);
0226
0227
0228 SplashBitmap *getBitmap() { return bitmap; }
0229
0230
0231 void setMinLineWidth(SplashCoord w) { minLineWidth = w; }
0232
0233
0234 void setThinLineMode(SplashThinLineMode thinLineModeA) { thinLineMode = thinLineModeA; }
0235 SplashThinLineMode getThinLineMode() { return thinLineMode; }
0236
0237
0238
0239 SplashClipResult getClipRes() { return opClipRes; }
0240
0241
0242 void setDebugMode(bool debugModeA) { debugMode = debugModeA; }
0243
0244 #if 1
0245 void setInShading(bool sh) { inShading = sh; }
0246 bool getVectorAntialias() { return vectorAntialias; }
0247 void setVectorAntialias(bool vaa) { vectorAntialias = vaa; }
0248 #endif
0249
0250
0251
0252
0253
0254 SplashError shadedFill(SplashPath *path, bool hasBBox, SplashPattern *pattern, bool clipToStrokePath);
0255
0256 bool gouraudTriangleShadedFill(SplashGouraudColor *shading);
0257
0258 private:
0259 void pipeInit(SplashPipe *pipe, int x, int y, SplashPattern *pattern, SplashColorPtr cSrc, unsigned char aInput, bool usesShape, bool nonIsolatedGroup, bool knockout = false, unsigned char knockoutOpacity = 255);
0260 void pipeRun(SplashPipe *pipe);
0261 void pipeRunSimpleMono1(SplashPipe *pipe);
0262 void pipeRunSimpleMono8(SplashPipe *pipe);
0263 void pipeRunSimpleRGB8(SplashPipe *pipe);
0264 void pipeRunSimpleXBGR8(SplashPipe *pipe);
0265 void pipeRunSimpleBGR8(SplashPipe *pipe);
0266 void pipeRunSimpleCMYK8(SplashPipe *pipe);
0267 void pipeRunSimpleDeviceN8(SplashPipe *pipe);
0268 void pipeRunAAMono1(SplashPipe *pipe);
0269 void pipeRunAAMono8(SplashPipe *pipe);
0270 void pipeRunAARGB8(SplashPipe *pipe);
0271 void pipeRunAAXBGR8(SplashPipe *pipe);
0272 void pipeRunAABGR8(SplashPipe *pipe);
0273 void pipeRunAACMYK8(SplashPipe *pipe);
0274 void pipeRunAADeviceN8(SplashPipe *pipe);
0275 void pipeSetXY(SplashPipe *pipe, int x, int y);
0276 void pipeIncX(SplashPipe *pipe);
0277 void drawPixel(SplashPipe *pipe, int x, int y, bool noClip);
0278 void drawAAPixelInit();
0279 void drawAAPixel(SplashPipe *pipe, int x, int y);
0280 void drawSpan(SplashPipe *pipe, int x0, int x1, int y, bool noClip);
0281 void drawAALine(SplashPipe *pipe, int x0, int x1, int y, bool adjustLine = false, unsigned char lineOpacity = 0);
0282 void transform(const SplashCoord *matrix, SplashCoord xi, SplashCoord yi, SplashCoord *xo, SplashCoord *yo);
0283 void strokeNarrow(SplashPath *path);
0284 void strokeWide(SplashPath *path, SplashCoord w);
0285 SplashPath *flattenPath(SplashPath *path, SplashCoord *matrix, SplashCoord flatness);
0286 void flattenCurve(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1, SplashCoord x2, SplashCoord y2, SplashCoord x3, SplashCoord y3, SplashCoord *matrix, SplashCoord flatness2, SplashPath *fPath);
0287 SplashPath *makeDashedPath(SplashPath *xPath);
0288 void getBBoxFP(SplashPath *path, SplashCoord *xMinA, SplashCoord *yMinA, SplashCoord *xMaxA, SplashCoord *yMaxA);
0289 SplashError fillWithPattern(SplashPath *path, bool eo, SplashPattern *pattern, SplashCoord alpha);
0290 bool pathAllOutside(SplashPath *path);
0291 void fillGlyph2(int x0, int y0, SplashGlyphBitmap *glyph, bool noclip);
0292 void arbitraryTransformMask(SplashImageMaskSource src, void *srcData, int srcWidth, int srcHeight, SplashCoord *mat, bool glyphMode);
0293 SplashBitmap *scaleMask(SplashImageMaskSource src, void *srcData, int srcWidth, int srcHeight, int scaledWidth, int scaledHeight);
0294 void scaleMaskYdownXdown(SplashImageMaskSource src, void *srcData, int srcWidth, int srcHeight, int scaledWidth, int scaledHeight, SplashBitmap *dest);
0295 void scaleMaskYdownXup(SplashImageMaskSource src, void *srcData, int srcWidth, int srcHeight, int scaledWidth, int scaledHeight, SplashBitmap *dest);
0296 void scaleMaskYupXdown(SplashImageMaskSource src, void *srcData, int srcWidth, int srcHeight, int scaledWidth, int scaledHeight, SplashBitmap *dest);
0297 void scaleMaskYupXup(SplashImageMaskSource src, void *srcData, int srcWidth, int srcHeight, int scaledWidth, int scaledHeight, SplashBitmap *dest);
0298 void blitMask(SplashBitmap *src, int xDest, int yDest, SplashClipResult clipRes);
0299 SplashError arbitraryTransformImage(SplashImageSource src, SplashICCTransform tf, void *srcData, SplashColorMode srcMode, int nComps, bool srcAlpha, int srcWidth, int srcHeight, SplashCoord *mat, bool interpolate,
0300 bool tilingPattern = false);
0301 SplashBitmap *scaleImage(SplashImageSource src, void *srcData, SplashColorMode srcMode, int nComps, bool srcAlpha, int srcWidth, int srcHeight, int scaledWidth, int scaledHeight, bool interpolate, bool tilingPattern = false);
0302 bool scaleImageYdownXdown(SplashImageSource src, void *srcData, SplashColorMode srcMode, int nComps, bool srcAlpha, int srcWidth, int srcHeight, int scaledWidth, int scaledHeight, SplashBitmap *dest);
0303 bool scaleImageYdownXup(SplashImageSource src, void *srcData, SplashColorMode srcMode, int nComps, bool srcAlpha, int srcWidth, int srcHeight, int scaledWidth, int scaledHeight, SplashBitmap *dest);
0304 bool scaleImageYupXdown(SplashImageSource src, void *srcData, SplashColorMode srcMode, int nComps, bool srcAlpha, int srcWidth, int srcHeight, int scaledWidth, int scaledHeight, SplashBitmap *dest);
0305 bool scaleImageYupXup(SplashImageSource src, void *srcData, SplashColorMode srcMode, int nComps, bool srcAlpha, int srcWidth, int srcHeight, int scaledWidth, int scaledHeight, SplashBitmap *dest);
0306 bool scaleImageYupXupBilinear(SplashImageSource src, void *srcData, SplashColorMode srcMode, int nComps, bool srcAlpha, int srcWidth, int srcHeight, int scaledWidth, int scaledHeight, SplashBitmap *dest);
0307 void vertFlipImage(SplashBitmap *img, int width, int height, int nComps);
0308 void blitImage(SplashBitmap *src, bool srcAlpha, int xDest, int yDest, SplashClipResult clipRes);
0309 void blitImageClipped(SplashBitmap *src, bool srcAlpha, int xSrc, int ySrc, int xDest, int yDest, int w, int h);
0310 void dumpPath(SplashPath *path);
0311 void dumpXPath(SplashXPath *path);
0312
0313 static SplashPipeResultColorCtrl pipeResultColorNoAlphaBlend[];
0314 static SplashPipeResultColorCtrl pipeResultColorAlphaNoBlend[];
0315 static SplashPipeResultColorCtrl pipeResultColorAlphaBlend[];
0316 static int pipeNonIsoGroupCorrection[];
0317
0318 SplashBitmap *bitmap;
0319 SplashState *state;
0320 SplashBitmap *aaBuf;
0321 int aaBufY;
0322 SplashBitmap *alpha0Bitmap;
0323
0324 int alpha0X, alpha0Y;
0325 SplashCoord aaGamma[splashAASize * splashAASize + 1];
0326 SplashCoord minLineWidth;
0327 SplashThinLineMode thinLineMode;
0328 SplashClipResult opClipRes;
0329 bool vectorAntialias;
0330 bool inShading;
0331 bool debugMode;
0332 };
0333
0334 #endif