| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 | |
| 7 #ifndef CORE_FPDFAPI_FPDF_PAGE_PAGEINT_H_ | |
| 8 #define CORE_FPDFAPI_FPDF_PAGE_PAGEINT_H_ | |
| 9 | |
| 10 #include <map> | |
| 11 #include <memory> | |
| 12 #include <set> | |
| 13 #include <unordered_map> | |
| 14 #include <vector> | |
| 15 | |
| 16 #include "core/fpdfapi/fpdf_page/cpdf_contentmark.h" | |
| 17 #include "core/fpdfapi/fpdf_page/cpdf_countedobject.h" | |
| 18 #include "core/fpdfapi/fpdf_page/cpdf_pageobjectholder.h" | |
| 19 #include "core/fxcrt/cfx_string_pool_template.h" | |
| 20 #include "core/fxcrt/cfx_weak_ptr.h" | |
| 21 #include "core/fxge/cfx_pathdata.h" | |
| 22 #include "core/fxge/cfx_renderdevice.h" | |
| 23 | |
| 24 class CPDF_AllStates; | |
| 25 class CPDF_ColorSpace; | |
| 26 class CPDF_ExpIntFunc; | |
| 27 class CPDF_Font; | |
| 28 class CPDF_FontEncoding; | |
| 29 class CPDF_Form; | |
| 30 class CPDF_IccProfile; | |
| 31 class CPDF_Image; | |
| 32 class CPDF_ImageObject; | |
| 33 class CPDF_Page; | |
| 34 class CPDF_Pattern; | |
| 35 class CPDF_SampledFunc; | |
| 36 class CPDF_StitchFunc; | |
| 37 class CPDF_StreamAcc; | |
| 38 class CPDF_TextObject; | |
| 39 class CPDF_Type3Char; | |
| 40 | |
| 41 #define PARSE_STEP_LIMIT 100 | |
| 42 | |
| 43 class CPDF_StreamParser { | |
| 44 public: | |
| 45 enum SyntaxType { EndOfData, Number, Keyword, Name, Others }; | |
| 46 | |
| 47 CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize); | |
| 48 CPDF_StreamParser(const uint8_t* pData, | |
| 49 uint32_t dwSize, | |
| 50 const CFX_WeakPtr<CFX_ByteStringPool>& pPool); | |
| 51 ~CPDF_StreamParser(); | |
| 52 | |
| 53 CPDF_Stream* ReadInlineStream(CPDF_Document* pDoc, | |
| 54 CPDF_Dictionary* pDict, | |
| 55 CPDF_Object* pCSObj); | |
| 56 SyntaxType ParseNextElement(); | |
| 57 uint8_t* GetWordBuf() { return m_WordBuffer; } | |
| 58 uint32_t GetWordSize() const { return m_WordSize; } | |
| 59 CPDF_Object* GetObject() { | |
| 60 CPDF_Object* pObj = m_pLastObj; | |
| 61 m_pLastObj = nullptr; | |
| 62 return pObj; | |
| 63 } | |
| 64 uint32_t GetPos() const { return m_Pos; } | |
| 65 void SetPos(uint32_t pos) { m_Pos = pos; } | |
| 66 CPDF_Object* ReadNextObject(bool bAllowNestedArray, uint32_t dwInArrayLevel); | |
| 67 | |
| 68 protected: | |
| 69 friend class fpdf_page_parser_old_ReadHexString_Test; | |
| 70 | |
| 71 void GetNextWord(FX_BOOL& bIsNumber); | |
| 72 CFX_ByteString ReadString(); | |
| 73 CFX_ByteString ReadHexString(); | |
| 74 | |
| 75 const uint8_t* m_pBuf; | |
| 76 uint32_t m_Size; // Length in bytes of m_pBuf. | |
| 77 uint32_t m_Pos; // Current byte position within m_pBuf. | |
| 78 uint8_t m_WordBuffer[256]; | |
| 79 uint32_t m_WordSize; | |
| 80 CPDF_Object* m_pLastObj; | |
| 81 CFX_WeakPtr<CFX_ByteStringPool> m_pPool; | |
| 82 | |
| 83 private: | |
| 84 bool PositionIsInBounds() const; | |
| 85 }; | |
| 86 | |
| 87 #define PARAM_BUF_SIZE 16 | |
| 88 struct ContentParam { | |
| 89 enum Type { OBJECT = 0, NUMBER, NAME }; | |
| 90 Type m_Type; | |
| 91 union { | |
| 92 struct { | |
| 93 bool m_bInteger; | |
| 94 union { | |
| 95 int m_Integer; | |
| 96 FX_FLOAT m_Float; | |
| 97 }; | |
| 98 } m_Number; | |
| 99 CPDF_Object* m_pObject; | |
| 100 struct { | |
| 101 int m_Len; | |
| 102 char m_Buffer[32]; | |
| 103 } m_Name; | |
| 104 }; | |
| 105 }; | |
| 106 #define _FPDF_MAX_FORM_LEVEL_ 30 | |
| 107 #define _FPDF_MAX_TYPE3_FORM_LEVEL_ 4 | |
| 108 class CPDF_StreamContentParser { | |
| 109 public: | |
| 110 CPDF_StreamContentParser(CPDF_Document* pDoc, | |
| 111 CPDF_Dictionary* pPageResources, | |
| 112 CPDF_Dictionary* pParentResources, | |
| 113 const CFX_Matrix* pmtContentToUser, | |
| 114 CPDF_PageObjectHolder* pObjectHolder, | |
| 115 CPDF_Dictionary* pResources, | |
| 116 CFX_FloatRect* pBBox, | |
| 117 CPDF_AllStates* pAllStates, | |
| 118 int level); | |
| 119 ~CPDF_StreamContentParser(); | |
| 120 | |
| 121 CPDF_PageObjectHolder* GetPageObjectHolder() const { return m_pObjectHolder; } | |
| 122 CPDF_AllStates* GetCurStates() const { return m_pCurStates.get(); } | |
| 123 FX_BOOL IsColored() const { return m_bColored; } | |
| 124 const FX_FLOAT* GetType3Data() const { return m_Type3Data; } | |
| 125 | |
| 126 void AddNumberParam(const FX_CHAR* str, int len); | |
| 127 void AddObjectParam(CPDF_Object* pObj); | |
| 128 void AddNameParam(const FX_CHAR* name, int size); | |
| 129 int GetNextParamPos(); | |
| 130 void ClearAllParams(); | |
| 131 CPDF_Object* GetObject(uint32_t index); | |
| 132 CFX_ByteString GetString(uint32_t index); | |
| 133 FX_FLOAT GetNumber(uint32_t index); | |
| 134 int GetInteger(uint32_t index) { return (int32_t)(GetNumber(index)); } | |
| 135 void OnOperator(const FX_CHAR* op); | |
| 136 void BigCaseCaller(int index); | |
| 137 uint32_t GetParsePos() { return m_pSyntax->GetPos(); } | |
| 138 void AddTextObject(CFX_ByteString* pText, | |
| 139 FX_FLOAT fInitKerning, | |
| 140 FX_FLOAT* pKerning, | |
| 141 int count); | |
| 142 | |
| 143 void ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y); | |
| 144 void ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y); | |
| 145 void OnChangeTextMatrix(); | |
| 146 uint32_t Parse(const uint8_t* pData, uint32_t dwSize, uint32_t max_cost); | |
| 147 void ParsePathObject(); | |
| 148 void AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag); | |
| 149 void AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_FLOAT w, FX_FLOAT h); | |
| 150 void AddPathObject(int FillType, FX_BOOL bStroke); | |
| 151 CPDF_ImageObject* AddImage(CPDF_Stream* pStream, | |
| 152 CPDF_Image* pImage, | |
| 153 bool bInline); | |
| 154 void AddDuplicateImage(); | |
| 155 void AddForm(CPDF_Stream* pStream); | |
| 156 void SetGraphicStates(CPDF_PageObject* pObj, | |
| 157 FX_BOOL bColor, | |
| 158 FX_BOOL bText, | |
| 159 FX_BOOL bGraph); | |
| 160 void SaveStates(CPDF_AllStates* pState); | |
| 161 void RestoreStates(CPDF_AllStates* pState); | |
| 162 CPDF_Font* FindFont(const CFX_ByteString& name); | |
| 163 CPDF_ColorSpace* FindColorSpace(const CFX_ByteString& name); | |
| 164 CPDF_Pattern* FindPattern(const CFX_ByteString& name, bool bShading); | |
| 165 CPDF_Object* FindResourceObj(const CFX_ByteString& type, | |
| 166 const CFX_ByteString& name); | |
| 167 | |
| 168 protected: | |
| 169 using OpCodes = | |
| 170 std::unordered_map<uint32_t, void (CPDF_StreamContentParser::*)()>; | |
| 171 static OpCodes InitializeOpCodes(); | |
| 172 | |
| 173 void Handle_CloseFillStrokePath(); | |
| 174 void Handle_FillStrokePath(); | |
| 175 void Handle_CloseEOFillStrokePath(); | |
| 176 void Handle_EOFillStrokePath(); | |
| 177 void Handle_BeginMarkedContent_Dictionary(); | |
| 178 void Handle_BeginImage(); | |
| 179 void Handle_BeginMarkedContent(); | |
| 180 void Handle_BeginText(); | |
| 181 void Handle_CurveTo_123(); | |
| 182 void Handle_ConcatMatrix(); | |
| 183 void Handle_SetColorSpace_Fill(); | |
| 184 void Handle_SetColorSpace_Stroke(); | |
| 185 void Handle_SetDash(); | |
| 186 void Handle_SetCharWidth(); | |
| 187 void Handle_SetCachedDevice(); | |
| 188 void Handle_ExecuteXObject(); | |
| 189 void Handle_MarkPlace_Dictionary(); | |
| 190 void Handle_EndImage(); | |
| 191 void Handle_EndMarkedContent(); | |
| 192 void Handle_EndText(); | |
| 193 void Handle_FillPath(); | |
| 194 void Handle_FillPathOld(); | |
| 195 void Handle_EOFillPath(); | |
| 196 void Handle_SetGray_Fill(); | |
| 197 void Handle_SetGray_Stroke(); | |
| 198 void Handle_SetExtendGraphState(); | |
| 199 void Handle_ClosePath(); | |
| 200 void Handle_SetFlat(); | |
| 201 void Handle_BeginImageData(); | |
| 202 void Handle_SetLineJoin(); | |
| 203 void Handle_SetLineCap(); | |
| 204 void Handle_SetCMYKColor_Fill(); | |
| 205 void Handle_SetCMYKColor_Stroke(); | |
| 206 void Handle_LineTo(); | |
| 207 void Handle_MoveTo(); | |
| 208 void Handle_SetMiterLimit(); | |
| 209 void Handle_MarkPlace(); | |
| 210 void Handle_EndPath(); | |
| 211 void Handle_SaveGraphState(); | |
| 212 void Handle_RestoreGraphState(); | |
| 213 void Handle_Rectangle(); | |
| 214 void Handle_SetRGBColor_Fill(); | |
| 215 void Handle_SetRGBColor_Stroke(); | |
| 216 void Handle_SetRenderIntent(); | |
| 217 void Handle_CloseStrokePath(); | |
| 218 void Handle_StrokePath(); | |
| 219 void Handle_SetColor_Fill(); | |
| 220 void Handle_SetColor_Stroke(); | |
| 221 void Handle_SetColorPS_Fill(); | |
| 222 void Handle_SetColorPS_Stroke(); | |
| 223 void Handle_ShadeFill(); | |
| 224 void Handle_SetCharSpace(); | |
| 225 void Handle_MoveTextPoint(); | |
| 226 void Handle_MoveTextPoint_SetLeading(); | |
| 227 void Handle_SetFont(); | |
| 228 void Handle_ShowText(); | |
| 229 void Handle_ShowText_Positioning(); | |
| 230 void Handle_SetTextLeading(); | |
| 231 void Handle_SetTextMatrix(); | |
| 232 void Handle_SetTextRenderMode(); | |
| 233 void Handle_SetTextRise(); | |
| 234 void Handle_SetWordSpace(); | |
| 235 void Handle_SetHorzScale(); | |
| 236 void Handle_MoveToNextLine(); | |
| 237 void Handle_CurveTo_23(); | |
| 238 void Handle_SetLineWidth(); | |
| 239 void Handle_Clip(); | |
| 240 void Handle_EOClip(); | |
| 241 void Handle_CurveTo_13(); | |
| 242 void Handle_NextLineShowText(); | |
| 243 void Handle_NextLineShowText_Space(); | |
| 244 void Handle_Invalid(); | |
| 245 | |
| 246 CPDF_Document* const m_pDocument; | |
| 247 CPDF_Dictionary* m_pPageResources; | |
| 248 CPDF_Dictionary* m_pParentResources; | |
| 249 CPDF_Dictionary* m_pResources; | |
| 250 CPDF_PageObjectHolder* m_pObjectHolder; | |
| 251 int m_Level; | |
| 252 CFX_Matrix m_mtContentToUser; | |
| 253 CFX_FloatRect m_BBox; | |
| 254 ContentParam m_ParamBuf[PARAM_BUF_SIZE]; | |
| 255 uint32_t m_ParamStartPos; | |
| 256 uint32_t m_ParamCount; | |
| 257 CPDF_StreamParser* m_pSyntax; | |
| 258 std::unique_ptr<CPDF_AllStates> m_pCurStates; | |
| 259 CPDF_ContentMark m_CurContentMark; | |
| 260 std::vector<std::unique_ptr<CPDF_TextObject>> m_ClipTextList; | |
| 261 CPDF_TextObject* m_pLastTextObject; | |
| 262 FX_FLOAT m_DefFontSize; | |
| 263 FX_PATHPOINT* m_pPathPoints; | |
| 264 int m_PathPointCount; | |
| 265 int m_PathAllocSize; | |
| 266 FX_FLOAT m_PathStartX; | |
| 267 FX_FLOAT m_PathStartY; | |
| 268 FX_FLOAT m_PathCurrentX; | |
| 269 FX_FLOAT m_PathCurrentY; | |
| 270 uint8_t m_PathClipType; | |
| 271 CFX_ByteString m_LastImageName; | |
| 272 CPDF_Image* m_pLastImage; | |
| 273 CFX_BinaryBuf m_LastImageDict; | |
| 274 CFX_BinaryBuf m_LastImageData; | |
| 275 CPDF_Dictionary* m_pLastImageDict; | |
| 276 CPDF_Dictionary* m_pLastCloneImageDict; | |
| 277 FX_BOOL m_bReleaseLastDict; | |
| 278 FX_BOOL m_bSameLastDict; | |
| 279 FX_BOOL m_bColored; | |
| 280 FX_FLOAT m_Type3Data[6]; | |
| 281 FX_BOOL m_bResourceMissing; | |
| 282 std::vector<std::unique_ptr<CPDF_AllStates>> m_StateStack; | |
| 283 }; | |
| 284 class CPDF_ContentParser { | |
| 285 public: | |
| 286 enum ParseStatus { Ready, ToBeContinued, Done }; | |
| 287 | |
| 288 CPDF_ContentParser(); | |
| 289 ~CPDF_ContentParser(); | |
| 290 | |
| 291 ParseStatus GetStatus() const { return m_Status; } | |
| 292 void Start(CPDF_Page* pPage); | |
| 293 void Start(CPDF_Form* pForm, | |
| 294 CPDF_AllStates* pGraphicStates, | |
| 295 const CFX_Matrix* pParentMatrix, | |
| 296 CPDF_Type3Char* pType3Char, | |
| 297 int level); | |
| 298 void Continue(IFX_Pause* pPause); | |
| 299 | |
| 300 private: | |
| 301 enum InternalStage { | |
| 302 STAGE_GETCONTENT = 1, | |
| 303 STAGE_PARSE, | |
| 304 STAGE_CHECKCLIP, | |
| 305 }; | |
| 306 | |
| 307 ParseStatus m_Status; | |
| 308 InternalStage m_InternalStage; | |
| 309 CPDF_PageObjectHolder* m_pObjectHolder; | |
| 310 FX_BOOL m_bForm; | |
| 311 CPDF_Type3Char* m_pType3Char; | |
| 312 uint32_t m_nStreams; | |
| 313 std::unique_ptr<CPDF_StreamAcc> m_pSingleStream; | |
| 314 std::vector<std::unique_ptr<CPDF_StreamAcc>> m_StreamArray; | |
| 315 uint8_t* m_pData; | |
| 316 uint32_t m_Size; | |
| 317 uint32_t m_CurrentOffset; | |
| 318 std::unique_ptr<CPDF_StreamContentParser> m_pParser; | |
| 319 }; | |
| 320 | |
| 321 class CPDF_DocPageData { | |
| 322 public: | |
| 323 explicit CPDF_DocPageData(CPDF_Document* pPDFDoc); | |
| 324 ~CPDF_DocPageData(); | |
| 325 | |
| 326 void Clear(FX_BOOL bRelease = FALSE); | |
| 327 CPDF_Font* GetFont(CPDF_Dictionary* pFontDict, FX_BOOL findOnly); | |
| 328 CPDF_Font* GetStandardFont(const CFX_ByteString& fontName, | |
| 329 CPDF_FontEncoding* pEncoding); | |
| 330 void ReleaseFont(const CPDF_Dictionary* pFontDict); | |
| 331 CPDF_ColorSpace* GetColorSpace(CPDF_Object* pCSObj, | |
| 332 const CPDF_Dictionary* pResources); | |
| 333 CPDF_ColorSpace* GetCopiedColorSpace(CPDF_Object* pCSObj); | |
| 334 void ReleaseColorSpace(const CPDF_Object* pColorSpace); | |
| 335 CPDF_Pattern* GetPattern(CPDF_Object* pPatternObj, | |
| 336 FX_BOOL bShading, | |
| 337 const CFX_Matrix& matrix); | |
| 338 void ReleasePattern(const CPDF_Object* pPatternObj); | |
| 339 CPDF_Image* GetImage(CPDF_Object* pImageStream); | |
| 340 void ReleaseImage(const CPDF_Object* pImageStream); | |
| 341 CPDF_IccProfile* GetIccProfile(CPDF_Stream* pIccProfileStream); | |
| 342 void ReleaseIccProfile(const CPDF_IccProfile* pIccProfile); | |
| 343 CPDF_StreamAcc* GetFontFileStreamAcc(CPDF_Stream* pFontStream); | |
| 344 void ReleaseFontFileStreamAcc(const CPDF_Stream* pFontStream); | |
| 345 FX_BOOL IsForceClear() const { return m_bForceClear; } | |
| 346 CPDF_CountedColorSpace* FindColorSpacePtr(CPDF_Object* pCSObj) const; | |
| 347 CPDF_CountedPattern* FindPatternPtr(CPDF_Object* pPatternObj) const; | |
| 348 | |
| 349 private: | |
| 350 using CPDF_CountedFont = CPDF_CountedObject<CPDF_Font>; | |
| 351 using CPDF_CountedIccProfile = CPDF_CountedObject<CPDF_IccProfile>; | |
| 352 using CPDF_CountedImage = CPDF_CountedObject<CPDF_Image>; | |
| 353 using CPDF_CountedStreamAcc = CPDF_CountedObject<CPDF_StreamAcc>; | |
| 354 | |
| 355 using CPDF_ColorSpaceMap = | |
| 356 std::map<const CPDF_Object*, CPDF_CountedColorSpace*>; | |
| 357 using CPDF_FontFileMap = std::map<const CPDF_Stream*, CPDF_CountedStreamAcc*>; | |
| 358 using CPDF_FontMap = std::map<const CPDF_Dictionary*, CPDF_CountedFont*>; | |
| 359 using CPDF_IccProfileMap = | |
| 360 std::map<const CPDF_Stream*, CPDF_CountedIccProfile*>; | |
| 361 using CPDF_ImageMap = std::map<uint32_t, CPDF_CountedImage*>; | |
| 362 using CPDF_PatternMap = std::map<const CPDF_Object*, CPDF_CountedPattern*>; | |
| 363 | |
| 364 CPDF_ColorSpace* GetColorSpaceImpl(CPDF_Object* pCSObj, | |
| 365 const CPDF_Dictionary* pResources, | |
| 366 std::set<CPDF_Object*>* pVisited); | |
| 367 | |
| 368 CPDF_Document* const m_pPDFDoc; | |
| 369 FX_BOOL m_bForceClear; | |
| 370 std::map<CFX_ByteString, CPDF_Stream*> m_HashProfileMap; | |
| 371 CPDF_ColorSpaceMap m_ColorSpaceMap; | |
| 372 CPDF_FontFileMap m_FontFileMap; | |
| 373 CPDF_FontMap m_FontMap; | |
| 374 CPDF_IccProfileMap m_IccProfileMap; | |
| 375 CPDF_ImageMap m_ImageMap; | |
| 376 CPDF_PatternMap m_PatternMap; | |
| 377 }; | |
| 378 | |
| 379 class CPDF_Function { | |
| 380 public: | |
| 381 enum class Type { | |
| 382 kTypeInvalid = -1, | |
| 383 kType0Sampled = 0, | |
| 384 kType2ExpotentialInterpolation = 2, | |
| 385 kType3Stitching = 3, | |
| 386 kType4PostScript = 4, | |
| 387 }; | |
| 388 | |
| 389 static std::unique_ptr<CPDF_Function> Load(CPDF_Object* pFuncObj); | |
| 390 static Type IntegerToFunctionType(int iType); | |
| 391 | |
| 392 virtual ~CPDF_Function(); | |
| 393 FX_BOOL Call(FX_FLOAT* inputs, | |
| 394 uint32_t ninputs, | |
| 395 FX_FLOAT* results, | |
| 396 int& nresults) const; | |
| 397 uint32_t CountInputs() const { return m_nInputs; } | |
| 398 uint32_t CountOutputs() const { return m_nOutputs; } | |
| 399 FX_FLOAT GetDomain(int i) const { return m_pDomains[i]; } | |
| 400 FX_FLOAT GetRange(int i) const { return m_pRanges[i]; } | |
| 401 | |
| 402 const CPDF_SampledFunc* ToSampledFunc() const; | |
| 403 const CPDF_ExpIntFunc* ToExpIntFunc() const; | |
| 404 const CPDF_StitchFunc* ToStitchFunc() const; | |
| 405 | |
| 406 protected: | |
| 407 explicit CPDF_Function(Type type); | |
| 408 | |
| 409 FX_BOOL Init(CPDF_Object* pObj); | |
| 410 virtual FX_BOOL v_Init(CPDF_Object* pObj) = 0; | |
| 411 virtual FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const = 0; | |
| 412 | |
| 413 uint32_t m_nInputs; | |
| 414 uint32_t m_nOutputs; | |
| 415 FX_FLOAT* m_pDomains; | |
| 416 FX_FLOAT* m_pRanges; | |
| 417 const Type m_Type; | |
| 418 }; | |
| 419 | |
| 420 class CPDF_ExpIntFunc : public CPDF_Function { | |
| 421 public: | |
| 422 CPDF_ExpIntFunc(); | |
| 423 ~CPDF_ExpIntFunc() override; | |
| 424 | |
| 425 // CPDF_Function | |
| 426 FX_BOOL v_Init(CPDF_Object* pObj) override; | |
| 427 FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; | |
| 428 | |
| 429 uint32_t m_nOrigOutputs; | |
| 430 FX_FLOAT m_Exponent; | |
| 431 FX_FLOAT* m_pBeginValues; | |
| 432 FX_FLOAT* m_pEndValues; | |
| 433 }; | |
| 434 | |
| 435 class CPDF_SampledFunc : public CPDF_Function { | |
| 436 public: | |
| 437 struct SampleEncodeInfo { | |
| 438 FX_FLOAT encode_max; | |
| 439 FX_FLOAT encode_min; | |
| 440 uint32_t sizes; | |
| 441 }; | |
| 442 | |
| 443 struct SampleDecodeInfo { | |
| 444 FX_FLOAT decode_max; | |
| 445 FX_FLOAT decode_min; | |
| 446 }; | |
| 447 | |
| 448 CPDF_SampledFunc(); | |
| 449 ~CPDF_SampledFunc() override; | |
| 450 | |
| 451 // CPDF_Function | |
| 452 FX_BOOL v_Init(CPDF_Object* pObj) override; | |
| 453 FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; | |
| 454 | |
| 455 const std::vector<SampleEncodeInfo>& GetEncodeInfo() const { | |
| 456 return m_EncodeInfo; | |
| 457 } | |
| 458 uint32_t GetBitsPerSample() const { return m_nBitsPerSample; } | |
| 459 const CPDF_StreamAcc* GetSampleStream() const { | |
| 460 return m_pSampleStream.get(); | |
| 461 } | |
| 462 | |
| 463 private: | |
| 464 std::vector<SampleEncodeInfo> m_EncodeInfo; | |
| 465 std::vector<SampleDecodeInfo> m_DecodeInfo; | |
| 466 uint32_t m_nBitsPerSample; | |
| 467 uint32_t m_SampleMax; | |
| 468 std::unique_ptr<CPDF_StreamAcc> m_pSampleStream; | |
| 469 }; | |
| 470 | |
| 471 class CPDF_StitchFunc : public CPDF_Function { | |
| 472 public: | |
| 473 CPDF_StitchFunc(); | |
| 474 ~CPDF_StitchFunc() override; | |
| 475 | |
| 476 // CPDF_Function | |
| 477 FX_BOOL v_Init(CPDF_Object* pObj) override; | |
| 478 FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; | |
| 479 | |
| 480 const std::vector<std::unique_ptr<CPDF_Function>>& GetSubFunctions() const { | |
| 481 return m_pSubFunctions; | |
| 482 } | |
| 483 FX_FLOAT GetBound(size_t i) const { return m_pBounds[i]; } | |
| 484 | |
| 485 private: | |
| 486 std::vector<std::unique_ptr<CPDF_Function>> m_pSubFunctions; | |
| 487 FX_FLOAT* m_pBounds; | |
| 488 FX_FLOAT* m_pEncode; | |
| 489 | |
| 490 static const uint32_t kRequiredNumInputs = 1; | |
| 491 }; | |
| 492 | |
| 493 class CPDF_IccProfile { | |
| 494 public: | |
| 495 CPDF_IccProfile(const uint8_t* pData, uint32_t dwSize); | |
| 496 ~CPDF_IccProfile(); | |
| 497 uint32_t GetComponents() const { return m_nSrcComponents; } | |
| 498 FX_BOOL m_bsRGB; | |
| 499 void* m_pTransform; | |
| 500 | |
| 501 private: | |
| 502 uint32_t m_nSrcComponents; | |
| 503 }; | |
| 504 | |
| 505 class CPDF_DeviceCS : public CPDF_ColorSpace { | |
| 506 public: | |
| 507 CPDF_DeviceCS(CPDF_Document* pDoc, int family); | |
| 508 | |
| 509 FX_BOOL GetRGB(FX_FLOAT* pBuf, | |
| 510 FX_FLOAT& R, | |
| 511 FX_FLOAT& G, | |
| 512 FX_FLOAT& B) const override; | |
| 513 FX_BOOL SetRGB(FX_FLOAT* pBuf, | |
| 514 FX_FLOAT R, | |
| 515 FX_FLOAT G, | |
| 516 FX_FLOAT B) const override; | |
| 517 FX_BOOL v_GetCMYK(FX_FLOAT* pBuf, | |
| 518 FX_FLOAT& c, | |
| 519 FX_FLOAT& m, | |
| 520 FX_FLOAT& y, | |
| 521 FX_FLOAT& k) const override; | |
| 522 FX_BOOL v_SetCMYK(FX_FLOAT* pBuf, | |
| 523 FX_FLOAT c, | |
| 524 FX_FLOAT m, | |
| 525 FX_FLOAT y, | |
| 526 FX_FLOAT k) const override; | |
| 527 void TranslateImageLine(uint8_t* pDestBuf, | |
| 528 const uint8_t* pSrcBuf, | |
| 529 int pixels, | |
| 530 int image_width, | |
| 531 int image_height, | |
| 532 FX_BOOL bTransMask = FALSE) const override; | |
| 533 }; | |
| 534 | |
| 535 class CPDF_PatternCS : public CPDF_ColorSpace { | |
| 536 public: | |
| 537 explicit CPDF_PatternCS(CPDF_Document* pDoc); | |
| 538 ~CPDF_PatternCS() override; | |
| 539 FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; | |
| 540 FX_BOOL GetRGB(FX_FLOAT* pBuf, | |
| 541 FX_FLOAT& R, | |
| 542 FX_FLOAT& G, | |
| 543 FX_FLOAT& B) const override; | |
| 544 CPDF_ColorSpace* GetBaseCS() const override; | |
| 545 | |
| 546 private: | |
| 547 CPDF_ColorSpace* m_pBaseCS; | |
| 548 CPDF_CountedColorSpace* m_pCountedBaseCS; | |
| 549 }; | |
| 550 | |
| 551 #define MAX_PATTERN_COLORCOMPS 16 | |
| 552 struct PatternValue { | |
| 553 CPDF_Pattern* m_pPattern; | |
| 554 CPDF_CountedPattern* m_pCountedPattern; | |
| 555 int m_nComps; | |
| 556 FX_FLOAT m_Comps[MAX_PATTERN_COLORCOMPS]; | |
| 557 }; | |
| 558 | |
| 559 CFX_ByteStringC PDF_FindKeyAbbreviationForTesting(const CFX_ByteStringC& abbr); | |
| 560 CFX_ByteStringC PDF_FindValueAbbreviationForTesting( | |
| 561 const CFX_ByteStringC& abbr); | |
| 562 | |
| 563 void PDF_ReplaceAbbr(CPDF_Object* pObj); | |
| 564 bool IsPathOperator(const uint8_t* buf, size_t len); | |
| 565 | |
| 566 #endif // CORE_FPDFAPI_FPDF_PAGE_PAGEINT_H_ | |
| OLD | NEW |