File indexing completed on 2025-12-10 10:23:49
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
0028
0029
0030
0031
0032
0033
0034
0035
0036 #ifndef OUTPUTDEV_H
0037 #define OUTPUTDEV_H
0038
0039 #include "poppler-config.h"
0040 #include "poppler_private_export.h"
0041 #include "CharTypes.h"
0042 #include "Object.h"
0043 #include "PopplerCache.h"
0044 #include "ProfileData.h"
0045 #include "GfxState.h"
0046 #include <memory>
0047 #include <unordered_map>
0048 #include <string>
0049
0050 class Annot;
0051 class Dict;
0052 class GooString;
0053 class Gfx;
0054 class Stream;
0055 class Links;
0056 class AnnotLink;
0057 class Catalog;
0058 class Page;
0059 class Function;
0060
0061
0062
0063
0064
0065 class POPPLER_PRIVATE_EXPORT OutputDev
0066 {
0067 public:
0068
0069 OutputDev();
0070
0071
0072 virtual ~OutputDev();
0073
0074
0075
0076
0077
0078 virtual bool upsideDown() = 0;
0079
0080
0081 virtual bool useDrawChar() = 0;
0082
0083
0084
0085
0086 virtual bool useTilingPatternFill() { return false; }
0087
0088
0089
0090 virtual bool useShadedFills(int type) { return false; }
0091
0092
0093 virtual bool useFillColorStop() { return false; }
0094
0095
0096
0097 virtual bool useDrawForm() { return false; }
0098
0099
0100
0101 virtual bool interpretType3Chars() = 0;
0102
0103
0104 virtual bool needNonText() { return true; }
0105
0106
0107
0108 virtual bool needCharCount() { return false; }
0109
0110
0111
0112 virtual bool needClipToCropBox() { return false; }
0113
0114
0115
0116
0117 virtual void setDefaultCTM(const double *ctm);
0118
0119
0120
0121
0122
0123 virtual bool checkPageSlice(Page *page, double hDPI, double vDPI, int rotate, bool useMediaBox, bool crop, int sliceX, int sliceY, int sliceW, int sliceH, bool printing, bool (*abortCheckCbk)(void *data) = nullptr,
0124 void *abortCheckCbkData = nullptr, bool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = nullptr, void *annotDisplayDecideCbkData = nullptr)
0125 {
0126 return true;
0127 }
0128
0129
0130 virtual void startPage(int pageNum, GfxState *state, XRef *xref) { }
0131
0132
0133 virtual void endPage() { }
0134
0135
0136 virtual void dump() { }
0137
0138 virtual void initGfxState(GfxState *state)
0139 {
0140 #ifdef USE_CMS
0141 state->setDisplayProfile(displayprofile);
0142
0143 auto invalidref = Ref::INVALID();
0144 if (defaultGrayProfile) {
0145 auto cs = new GfxICCBasedColorSpace(1, new GfxDeviceGrayColorSpace(), &invalidref);
0146
0147 cs->setProfile(defaultGrayProfile);
0148 cs->buildTransforms(state);
0149 state->setDefaultGrayColorSpace(cs);
0150 }
0151
0152 if (defaultRGBProfile) {
0153 auto cs = new GfxICCBasedColorSpace(3, new GfxDeviceRGBColorSpace(), &invalidref);
0154
0155 cs->setProfile(defaultRGBProfile);
0156 cs->buildTransforms(state);
0157 state->setDefaultRGBColorSpace(cs);
0158 }
0159
0160 if (defaultCMYKProfile) {
0161 auto cs = new GfxICCBasedColorSpace(4, new GfxDeviceCMYKColorSpace(), &invalidref);
0162
0163 cs->setProfile(defaultCMYKProfile);
0164 cs->buildTransforms(state);
0165 state->setDefaultCMYKColorSpace(cs);
0166 }
0167 #endif
0168 }
0169
0170
0171
0172
0173 virtual void cvtDevToUser(double dx, double dy, double *ux, double *uy);
0174 virtual void cvtUserToDev(double ux, double uy, int *dx, int *dy);
0175
0176 const double *getDefCTM() const { return defCTM; }
0177 const double *getDefICTM() const { return defICTM; }
0178
0179
0180 virtual void saveState(GfxState * ) { }
0181 virtual void restoreState(GfxState * ) { }
0182
0183
0184 virtual void updateAll(GfxState *state);
0185
0186
0187
0188
0189
0190
0191 virtual void updateCTM(GfxState * , double , double , double , double , double , double ) { }
0192 virtual void updateLineDash(GfxState * ) { }
0193 virtual void updateFlatness(GfxState * ) { }
0194 virtual void updateLineJoin(GfxState * ) { }
0195 virtual void updateLineCap(GfxState * ) { }
0196 virtual void updateMiterLimit(GfxState * ) { }
0197 virtual void updateLineWidth(GfxState * ) { }
0198 virtual void updateStrokeAdjust(GfxState * ) { }
0199 virtual void updateAlphaIsShape(GfxState * ) { }
0200 virtual void updateTextKnockout(GfxState * ) { }
0201 virtual void updateFillColorSpace(GfxState * ) { }
0202 virtual void updateStrokeColorSpace(GfxState * ) { }
0203 virtual void updateFillColor(GfxState * ) { }
0204 virtual void updateStrokeColor(GfxState * ) { }
0205 virtual void updateBlendMode(GfxState * ) { }
0206 virtual void updateFillOpacity(GfxState * ) { }
0207 virtual void updateStrokeOpacity(GfxState * ) { }
0208 virtual void updatePatternOpacity(GfxState * ) { }
0209 virtual void clearPatternOpacity(GfxState * ) { }
0210 virtual void updateFillOverprint(GfxState * ) { }
0211 virtual void updateStrokeOverprint(GfxState * ) { }
0212 virtual void updateOverprintMode(GfxState * ) { }
0213 virtual void updateTransfer(GfxState * ) { }
0214 virtual void updateFillColorStop(GfxState * , double ) { }
0215
0216
0217 virtual void updateFont(GfxState * ) { }
0218 virtual void updateTextMat(GfxState * ) { }
0219 virtual void updateCharSpace(GfxState * ) { }
0220 virtual void updateRender(GfxState * ) { }
0221 virtual void updateRise(GfxState * ) { }
0222 virtual void updateWordSpace(GfxState * ) { }
0223 virtual void updateHorizScaling(GfxState * ) { }
0224 virtual void updateTextPos(GfxState * ) { }
0225 virtual void updateTextShift(GfxState * , double ) { }
0226 virtual void saveTextPos(GfxState * ) { }
0227 virtual void restoreTextPos(GfxState * ) { }
0228
0229
0230 virtual void stroke(GfxState * ) { }
0231 virtual void fill(GfxState * ) { }
0232 virtual void eoFill(GfxState * ) { }
0233 virtual bool tilingPatternFill(GfxState * , Gfx * , Catalog * , GfxTilingPattern * , const double * , int , int , int , int , double , double )
0234 {
0235 return false;
0236 }
0237 virtual bool functionShadedFill(GfxState * , GfxFunctionShading * ) { return false; }
0238 virtual bool axialShadedFill(GfxState * , GfxAxialShading * , double , double ) { return false; }
0239 virtual bool axialShadedSupportExtend(GfxState * , GfxAxialShading * ) { return false; }
0240 virtual bool radialShadedFill(GfxState * , GfxRadialShading * , double , double ) { return false; }
0241 virtual bool radialShadedSupportExtend(GfxState * , GfxRadialShading * ) { return false; }
0242 virtual bool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) { return false; }
0243 virtual bool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading) { return false; }
0244
0245
0246
0247
0248
0249
0250
0251
0252 virtual void clip(GfxState * ) { }
0253
0254
0255
0256
0257
0258
0259 virtual void eoClip(GfxState * ) { }
0260
0261
0262
0263
0264 virtual void clipToStrokePath(GfxState * ) { }
0265
0266
0267 virtual void beginStringOp(GfxState * ) { }
0268 virtual void endStringOp(GfxState * ) { }
0269 virtual void beginString(GfxState * , const GooString * ) { }
0270 virtual void endString(GfxState * ) { }
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281 virtual void drawChar(GfxState * , double , double , double , double , double , double , CharCode , int , const Unicode * , int ) { }
0282 virtual void drawString(GfxState * , const GooString * ) { }
0283 virtual bool beginType3Char(GfxState * , double , double , double , double , CharCode , const Unicode * , int );
0284 virtual void endType3Char(GfxState * ) { }
0285 virtual void beginTextObject(GfxState * ) { }
0286 virtual void endTextObject(GfxState * ) { }
0287 virtual void incCharCount(int ) { }
0288 virtual void beginActualText(GfxState * , const GooString * ) { }
0289 virtual void endActualText(GfxState * ) { }
0290
0291
0292
0293
0294
0295
0296
0297 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg);
0298 virtual void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool inlineImg, double *baseMatrix);
0299 virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix);
0300 virtual void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg);
0301 virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert, bool maskInterpolate);
0302 virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap,
0303 bool maskInterpolate);
0304
0305
0306
0307 virtual void endMarkedContent(GfxState *state);
0308 virtual void beginMarkedContent(const char *name, Dict *properties);
0309 virtual void markPoint(const char *name);
0310 virtual void markPoint(const char *name, Dict *properties);
0311
0312 #ifdef OPI_SUPPORT
0313
0314 virtual void opiBegin(GfxState *state, Dict *opiDict);
0315 virtual void opiEnd(GfxState *state, Dict *opiDict);
0316 #endif
0317
0318
0319 virtual void type3D0(GfxState * , double , double ) { }
0320 virtual void type3D1(GfxState * , double , double , double , double , double , double ) { }
0321
0322
0323 virtual void beginForm(Ref ) { }
0324 virtual void drawForm(Ref ) { }
0325 virtual void endForm(Ref ) { }
0326
0327
0328 virtual void psXObject(Stream * , Stream * ) { }
0329
0330
0331 void startProfile();
0332 std::unordered_map<std::string, ProfileData> *getProfileHash() const { return profileHash.get(); }
0333 std::unique_ptr<std::unordered_map<std::string, ProfileData>> endProfile();
0334
0335
0336 virtual bool checkTransparencyGroup(GfxState * , bool ) { return true; }
0337 virtual void beginTransparencyGroup(GfxState * , const double * , GfxColorSpace * , bool , bool , bool ) { }
0338 virtual void endTransparencyGroup(GfxState * ) { }
0339 virtual void paintTransparencyGroup(GfxState * , const double * ) { }
0340 virtual void setSoftMask(GfxState * , const double * , bool , Function * , GfxColor * ) { }
0341 virtual void clearSoftMask(GfxState * ) { }
0342
0343
0344 virtual void processLink(AnnotLink * ) { }
0345
0346 #if 1
0347 virtual bool getVectorAntialias() { return false; }
0348 virtual void setVectorAntialias(bool ) { }
0349 #endif
0350
0351 #ifdef USE_CMS
0352 void setDisplayProfile(const GfxLCMSProfilePtr &profile) { displayprofile = profile; }
0353 GfxLCMSProfilePtr getDisplayProfile() const { return displayprofile; }
0354 void setDefaultGrayProfile(const GfxLCMSProfilePtr &profile) { defaultGrayProfile = profile; }
0355 GfxLCMSProfilePtr getDefaultGrayProfile() const { return defaultGrayProfile; }
0356 void setDefaultRGBProfile(const GfxLCMSProfilePtr &profile) { defaultRGBProfile = profile; }
0357 GfxLCMSProfilePtr getDefaultRGBProfile() const { return defaultRGBProfile; }
0358 void setDefaultCMYKProfile(const GfxLCMSProfilePtr &profile) { defaultCMYKProfile = profile; }
0359 GfxLCMSProfilePtr getDefaultCMYKProfile() const { return defaultCMYKProfile; }
0360
0361 PopplerCache<Ref, GfxICCBasedColorSpace> *getIccColorSpaceCache() { return &iccColorSpaceCache; }
0362 #endif
0363
0364 private:
0365 double defCTM[6];
0366 double defICTM[6];
0367 std::unique_ptr<std::unordered_map<std::string, ProfileData>> profileHash;
0368
0369 #ifdef USE_CMS
0370 GfxLCMSProfilePtr displayprofile;
0371 GfxLCMSProfilePtr defaultGrayProfile;
0372 GfxLCMSProfilePtr defaultRGBProfile;
0373 GfxLCMSProfilePtr defaultCMYKProfile;
0374
0375 PopplerCache<Ref, GfxICCBasedColorSpace> iccColorSpaceCache;
0376 #endif
0377 };
0378
0379 #endif