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_SRC_FPDFAPI_FPDF_RENDER_RENDER_INT_H_ 8 #define CORE_SRC_FPDFAPI_FPDF_RENDER_RENDER_INT_H_ 9 10 #include <map> 11 #include <memory> 12 13 #include "core/include/fpdfapi/fpdf_pageobj.h" 14 #include "core/include/fpdfapi/fpdf_render.h" 15 16 class CFX_GlyphBitmap; 17 class CFX_ImageTransformer; 18 class CPDF_ImageCacheEntry; 19 class CPDF_ImageLoaderHandle; 20 class ICodec_ScanlineDecoder; 21 22 #define TYPE3_MAX_BLUES 16 23 24 class CPDF_Type3Glyphs { 25 public: CPDF_Type3Glyphs()26 CPDF_Type3Glyphs() : m_TopBlueCount(0), m_BottomBlueCount(0) {} 27 ~CPDF_Type3Glyphs(); 28 void AdjustBlue(FX_FLOAT top, 29 FX_FLOAT bottom, 30 int& top_line, 31 int& bottom_line); 32 33 std::map<FX_DWORD, CFX_GlyphBitmap*> m_GlyphMap; 34 int m_TopBlue[TYPE3_MAX_BLUES]; 35 int m_BottomBlue[TYPE3_MAX_BLUES]; 36 int m_TopBlueCount; 37 int m_BottomBlueCount; 38 }; 39 class CPDF_Type3Cache { 40 public: CPDF_Type3Cache(CPDF_Type3Font * pFont)41 explicit CPDF_Type3Cache(CPDF_Type3Font* pFont) : m_pFont(pFont) {} 42 ~CPDF_Type3Cache(); 43 44 CFX_GlyphBitmap* LoadGlyph(FX_DWORD charcode, 45 const CFX_Matrix* pMatrix, 46 FX_FLOAT retinaScaleX = 1.0f, 47 FX_FLOAT retinaScaleY = 1.0f); 48 49 protected: 50 CFX_GlyphBitmap* RenderGlyph(CPDF_Type3Glyphs* pSize, 51 FX_DWORD charcode, 52 const CFX_Matrix* pMatrix, 53 FX_FLOAT retinaScaleX = 1.0f, 54 FX_FLOAT retinaScaleY = 1.0f); 55 CPDF_Type3Font* const m_pFont; 56 std::map<CFX_ByteString, CPDF_Type3Glyphs*> m_SizeMap; 57 }; 58 59 class CPDF_TransferFunc { 60 public: 61 explicit CPDF_TransferFunc(CPDF_Document* pDoc); 62 63 FX_COLORREF TranslateColor(FX_COLORREF src) const; 64 CFX_DIBSource* TranslateImage(const CFX_DIBSource* pSrc, 65 FX_BOOL bAutoDropSrc); 66 67 CPDF_Document* const m_pPDFDoc; 68 FX_BOOL m_bIdentity; 69 uint8_t m_Samples[256 * 3]; 70 }; 71 72 class CPDF_DocRenderData { 73 public: 74 CPDF_DocRenderData(CPDF_Document* pPDFDoc = NULL); 75 ~CPDF_DocRenderData(); 76 CPDF_Type3Cache* GetCachedType3(CPDF_Type3Font* pFont); 77 CPDF_TransferFunc* GetTransferFunc(CPDF_Object* pObj); GetFontCache()78 CFX_FontCache* GetFontCache() { return m_pFontCache; } 79 void Clear(FX_BOOL bRelease = FALSE); 80 void ReleaseCachedType3(CPDF_Type3Font* pFont); 81 void ReleaseTransferFunc(CPDF_Object* pObj); 82 83 private: 84 using CPDF_Type3CacheMap = 85 std::map<CPDF_Font*, CPDF_CountedObject<CPDF_Type3Cache>*>; 86 using CPDF_TransferFuncMap = 87 std::map<CPDF_Object*, CPDF_CountedObject<CPDF_TransferFunc>*>; 88 89 CPDF_Document* m_pPDFDoc; 90 CFX_FontCache* m_pFontCache; 91 CPDF_Type3CacheMap m_Type3FaceMap; 92 CPDF_TransferFuncMap m_TransferFuncMap; 93 }; 94 struct _PDF_RenderItem { 95 public: 96 CPDF_PageObjects* m_pObjectList; 97 CFX_Matrix m_Matrix; 98 }; 99 100 typedef CFX_ArrayTemplate<_PDF_RenderItem> CPDF_RenderLayer; 101 102 class IPDF_ObjectRenderer { 103 public: 104 static IPDF_ObjectRenderer* Create(int type); ~IPDF_ObjectRenderer()105 virtual ~IPDF_ObjectRenderer() {} 106 virtual FX_BOOL Start(CPDF_RenderStatus* pRenderStatus, 107 const CPDF_PageObject* pObj, 108 const CFX_Matrix* pObj2Device, 109 FX_BOOL bStdCS, 110 int blendType = FXDIB_BLEND_NORMAL) = 0; 111 virtual FX_BOOL Continue(IFX_Pause* pPause) = 0; 112 FX_BOOL m_Result; 113 }; 114 115 class CPDF_RenderStatus { 116 public: 117 CPDF_RenderStatus(); 118 ~CPDF_RenderStatus(); 119 FX_BOOL Initialize(class CPDF_RenderContext* pContext, 120 CFX_RenderDevice* pDevice, 121 const CFX_Matrix* pDeviceMatrix, 122 const CPDF_PageObject* pStopObj, 123 const CPDF_RenderStatus* pParentStatus, 124 const CPDF_GraphicStates* pInitialStates, 125 const CPDF_RenderOptions* pOptions, 126 int transparency, 127 FX_BOOL bDropObjects, 128 CPDF_Dictionary* pFormResource = NULL, 129 FX_BOOL bStdCS = FALSE, 130 CPDF_Type3Char* pType3Char = NULL, 131 FX_ARGB fill_color = 0, 132 FX_DWORD GroupFamily = 0, 133 FX_BOOL bLoadMask = FALSE); 134 void RenderObjectList(const CPDF_PageObjects* pObjs, 135 const CFX_Matrix* pObj2Device); 136 void RenderSingleObject(const CPDF_PageObject* pObj, 137 const CFX_Matrix* pObj2Device); 138 FX_BOOL ContinueSingleObject(const CPDF_PageObject* pObj, 139 const CFX_Matrix* pObj2Device, 140 IFX_Pause* pPause); GetContext()141 CPDF_RenderContext* GetContext() { return m_pContext; } 142 143 CPDF_RenderOptions m_Options; 144 CPDF_Dictionary* m_pFormResource; 145 CPDF_Dictionary* m_pPageResource; 146 CFX_ArrayTemplate<CPDF_Type3Font*> m_Type3FontCache; 147 148 protected: 149 friend class CPDF_ImageRenderer; 150 friend class CPDF_RenderContext; 151 void ProcessClipPath(CPDF_ClipPath ClipPath, const CFX_Matrix* pObj2Device); 152 void DrawClipPath(CPDF_ClipPath ClipPath, const CFX_Matrix* pObj2Device); 153 FX_BOOL ProcessTransparency(const CPDF_PageObject* PageObj, 154 const CFX_Matrix* pObj2Device); 155 void ProcessObjectNoClip(const CPDF_PageObject* PageObj, 156 const CFX_Matrix* pObj2Device); 157 void DrawObjWithBackground(const CPDF_PageObject* pObj, 158 const CFX_Matrix* pObj2Device); 159 FX_BOOL DrawObjWithBlend(const CPDF_PageObject* pObj, 160 const CFX_Matrix* pObj2Device); 161 FX_BOOL ProcessPath(CPDF_PathObject* pPathObj, const CFX_Matrix* pObj2Device); 162 void ProcessPathPattern(CPDF_PathObject* pPathObj, 163 const CFX_Matrix* pObj2Device, 164 int& filltype, 165 FX_BOOL& bStroke); 166 void DrawPathWithPattern(CPDF_PathObject* pPathObj, 167 const CFX_Matrix* pObj2Device, 168 CPDF_Color* pColor, 169 FX_BOOL bStroke); 170 void DrawTilingPattern(CPDF_TilingPattern* pPattern, 171 CPDF_PageObject* pPageObj, 172 const CFX_Matrix* pObj2Device, 173 FX_BOOL bStroke); 174 void DrawShadingPattern(CPDF_ShadingPattern* pPattern, 175 CPDF_PageObject* pPageObj, 176 const CFX_Matrix* pObj2Device, 177 FX_BOOL bStroke); 178 FX_BOOL SelectClipPath(CPDF_PathObject* pPathObj, 179 const CFX_Matrix* pObj2Device, 180 FX_BOOL bStroke); 181 FX_BOOL ProcessImage(CPDF_ImageObject* pImageObj, 182 const CFX_Matrix* pObj2Device); 183 FX_BOOL OutputBitmapAlpha(CPDF_ImageObject* pImageObj, 184 const CFX_Matrix* pImage2Device); 185 FX_BOOL OutputImage(CPDF_ImageObject* pImageObj, 186 const CFX_Matrix* pImage2Device); 187 FX_BOOL OutputDIBSource(const CFX_DIBSource* pOutputBitmap, 188 FX_ARGB fill_argb, 189 int bitmap_alpha, 190 const CFX_Matrix* pImage2Device, 191 CPDF_ImageCacheEntry* pImageCache, 192 FX_DWORD flags); 193 void CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, 194 int left, 195 int top, 196 FX_ARGB mask_argb, 197 int bitmap_alpha, 198 int blend_mode, 199 int bIsolated); 200 FX_BOOL ProcessShading(CPDF_ShadingObject* pShadingObj, 201 const CFX_Matrix* pObj2Device); 202 void DrawShading(CPDF_ShadingPattern* pPattern, 203 CFX_Matrix* pMatrix, 204 FX_RECT& clip_rect, 205 int alpha, 206 FX_BOOL bAlphaMode); 207 FX_BOOL ProcessType3Text(const CPDF_TextObject* textobj, 208 const CFX_Matrix* pObj2Device); 209 FX_BOOL ProcessText(const CPDF_TextObject* textobj, 210 const CFX_Matrix* pObj2Device, 211 CFX_PathData* pClippingPath); 212 void DrawTextPathWithPattern(const CPDF_TextObject* textobj, 213 const CFX_Matrix* pObj2Device, 214 CPDF_Font* pFont, 215 FX_FLOAT font_size, 216 const CFX_Matrix* pTextMatrix, 217 FX_BOOL bFill, 218 FX_BOOL bStroke); 219 FX_BOOL ProcessForm(CPDF_FormObject* pFormObj, const CFX_Matrix* pObj2Device); 220 CFX_DIBitmap* GetBackdrop(const CPDF_PageObject* pObj, 221 const FX_RECT& rect, 222 int& left, 223 int& top, 224 FX_BOOL bBackAlphaRequired); 225 CFX_DIBitmap* LoadSMask(CPDF_Dictionary* pSMaskDict, 226 FX_RECT* pClipRect, 227 const CFX_Matrix* pMatrix); 228 void Init(CPDF_RenderContext* pParent); 229 static class CPDF_Type3Cache* GetCachedType3(CPDF_Type3Font* pFont); 230 static CPDF_GraphicStates* CloneObjStates(const CPDF_GraphicStates* pPathObj, 231 FX_BOOL bStroke); 232 CPDF_TransferFunc* GetTransferFunc(CPDF_Object* pObject) const; 233 FX_ARGB GetFillArgb(const CPDF_PageObject* pObj, 234 FX_BOOL bType3 = FALSE) const; 235 FX_ARGB GetStrokeArgb(const CPDF_PageObject* pObj) const; 236 CPDF_RenderContext* m_pContext; 237 FX_BOOL m_bStopped; 238 void DitherObjectArea(const CPDF_PageObject* pObj, 239 const CFX_Matrix* pObj2Device); 240 FX_BOOL GetObjectClippedRect(const CPDF_PageObject* pObj, 241 const CFX_Matrix* pObj2Device, 242 FX_BOOL bLogical, 243 FX_RECT& rect) const; 244 void GetScaledMatrix(CFX_Matrix& matrix) const; 245 246 protected: 247 static const int kRenderMaxRecursionDepth = 64; 248 static int s_CurrentRecursionDepth; 249 250 CFX_RenderDevice* m_pDevice; 251 CFX_Matrix m_DeviceMatrix; 252 CPDF_ClipPath m_LastClipPath; 253 const CPDF_PageObject* m_pCurObj; 254 const CPDF_PageObject* m_pStopObj; 255 CPDF_GraphicStates m_InitialStates; 256 int m_HalftoneLimit; 257 std::unique_ptr<IPDF_ObjectRenderer> m_pObjectRenderer; 258 FX_BOOL m_bPrint; 259 int m_Transparency; 260 int m_DitherBits; 261 FX_BOOL m_bDropObjects; 262 FX_BOOL m_bStdCS; 263 FX_DWORD m_GroupFamily; 264 FX_BOOL m_bLoadMask; 265 CPDF_Type3Char* m_pType3Char; 266 FX_ARGB m_T3FillColor; 267 int m_curBlend; 268 }; 269 class CPDF_ImageLoader { 270 public: CPDF_ImageLoader()271 CPDF_ImageLoader() 272 : m_pBitmap(nullptr), 273 m_pMask(nullptr), 274 m_MatteColor(0), 275 m_bCached(FALSE), 276 m_nDownsampleWidth(0), 277 m_nDownsampleHeight(0) {} 278 ~CPDF_ImageLoader(); 279 280 FX_BOOL Start(const CPDF_ImageObject* pImage, 281 CPDF_PageRenderCache* pCache, 282 CPDF_ImageLoaderHandle*& LoadHandle, 283 FX_BOOL bStdCS = FALSE, 284 FX_DWORD GroupFamily = 0, 285 FX_BOOL bLoadMask = FALSE, 286 CPDF_RenderStatus* pRenderStatus = NULL, 287 int32_t nDownsampleWidth = 0, 288 int32_t nDownsampleHeight = 0); 289 FX_BOOL Continue(CPDF_ImageLoaderHandle* LoadHandle, IFX_Pause* pPause); 290 291 CFX_DIBSource* m_pBitmap; 292 CFX_DIBSource* m_pMask; 293 FX_DWORD m_MatteColor; 294 FX_BOOL m_bCached; 295 296 protected: 297 int32_t m_nDownsampleWidth; 298 int32_t m_nDownsampleHeight; 299 }; 300 class CPDF_ImageLoaderHandle { 301 public: 302 CPDF_ImageLoaderHandle(); 303 ~CPDF_ImageLoaderHandle(); 304 305 FX_BOOL Start(CPDF_ImageLoader* pImageLoader, 306 const CPDF_ImageObject* pImage, 307 CPDF_PageRenderCache* pCache, 308 FX_BOOL bStdCS = FALSE, 309 FX_DWORD GroupFamily = 0, 310 FX_BOOL bLoadMask = FALSE, 311 CPDF_RenderStatus* pRenderStatus = NULL, 312 int32_t nDownsampleWidth = 0, 313 int32_t nDownsampleHeight = 0); 314 FX_BOOL Continue(IFX_Pause* pPause); 315 316 protected: 317 CPDF_ImageLoader* m_pImageLoader; 318 CPDF_PageRenderCache* m_pCache; 319 CPDF_ImageObject* m_pImage; 320 int32_t m_nDownsampleWidth; 321 int32_t m_nDownsampleHeight; 322 }; 323 324 class CPDF_ImageRenderer : public IPDF_ObjectRenderer { 325 public: 326 CPDF_ImageRenderer(); 327 ~CPDF_ImageRenderer() override; 328 329 // IPDF_ObjectRenderer 330 FX_BOOL Start(CPDF_RenderStatus* pStatus, 331 const CPDF_PageObject* pObj, 332 const CFX_Matrix* pObj2Device, 333 FX_BOOL bStdCS, 334 int blendType = FXDIB_BLEND_NORMAL) override; 335 FX_BOOL Continue(IFX_Pause* pPause) override; 336 337 FX_BOOL Start(CPDF_RenderStatus* pStatus, 338 const CFX_DIBSource* pDIBSource, 339 FX_ARGB bitmap_argb, 340 int bitmap_alpha, 341 const CFX_Matrix* pImage2Device, 342 FX_DWORD flags, 343 FX_BOOL bStdCS, 344 int blendType = FXDIB_BLEND_NORMAL); 345 346 protected: 347 CPDF_RenderStatus* m_pRenderStatus; 348 CPDF_ImageObject* m_pImageObject; 349 int m_Status; 350 const CFX_Matrix* m_pObj2Device; 351 CFX_Matrix m_ImageMatrix; 352 CPDF_ImageLoader m_Loader; 353 const CFX_DIBSource* m_pDIBSource; 354 CFX_DIBitmap* m_pClone; 355 int m_BitmapAlpha; 356 FX_BOOL m_bPatternColor; 357 CPDF_Pattern* m_pPattern; 358 FX_ARGB m_FillArgb; 359 FX_DWORD m_Flags; 360 CFX_ImageTransformer* m_pTransformer; 361 void* m_DeviceHandle; 362 CPDF_ImageLoaderHandle* m_LoadHandle; 363 FX_BOOL m_bStdCS; 364 int m_BlendType; 365 FX_BOOL StartBitmapAlpha(); 366 FX_BOOL StartDIBSource(); 367 FX_BOOL StartRenderDIBSource(); 368 FX_BOOL StartLoadDIBSource(); 369 FX_BOOL DrawMaskedImage(); 370 FX_BOOL DrawPatternImage(const CFX_Matrix* pObj2Device); 371 }; 372 373 class CPDF_ScaledRenderBuffer { 374 public: 375 CPDF_ScaledRenderBuffer(); 376 ~CPDF_ScaledRenderBuffer(); 377 378 FX_BOOL Initialize(CPDF_RenderContext* pContext, 379 CFX_RenderDevice* pDevice, 380 const FX_RECT& pRect, 381 const CPDF_PageObject* pObj, 382 const CPDF_RenderOptions* pOptions = NULL, 383 int max_dpi = 0); GetDevice()384 CFX_RenderDevice* GetDevice() { 385 return m_pBitmapDevice ? m_pBitmapDevice.get() : m_pDevice; 386 } GetMatrix()387 CFX_Matrix* GetMatrix() { return &m_Matrix; } 388 void OutputToDevice(); 389 390 private: 391 CFX_RenderDevice* m_pDevice; 392 CPDF_RenderContext* m_pContext; 393 FX_RECT m_Rect; 394 const CPDF_PageObject* m_pObject; 395 std::unique_ptr<CFX_FxgeDevice> m_pBitmapDevice; 396 CFX_Matrix m_Matrix; 397 }; 398 399 class CPDF_DeviceBuffer { 400 public: 401 CPDF_DeviceBuffer(); 402 ~CPDF_DeviceBuffer(); 403 FX_BOOL Initialize(CPDF_RenderContext* pContext, 404 CFX_RenderDevice* pDevice, 405 FX_RECT* pRect, 406 const CPDF_PageObject* pObj, 407 int max_dpi = 0); 408 void OutputToDevice(); GetBitmap()409 CFX_DIBitmap* GetBitmap() const { return m_pBitmap.get(); } GetMatrix()410 const CFX_Matrix* GetMatrix() const { return &m_Matrix; } 411 412 private: 413 CFX_RenderDevice* m_pDevice; 414 CPDF_RenderContext* m_pContext; 415 FX_RECT m_Rect; 416 const CPDF_PageObject* m_pObject; 417 std::unique_ptr<CFX_DIBitmap> m_pBitmap; 418 CFX_Matrix m_Matrix; 419 }; 420 421 class CPDF_ImageCacheEntry { 422 public: 423 CPDF_ImageCacheEntry(CPDF_Document* pDoc, CPDF_Stream* pStream); 424 ~CPDF_ImageCacheEntry(); 425 void ClearImageData(); 426 void Reset(const CFX_DIBitmap* pBitmap); 427 FX_BOOL GetCachedBitmap(CFX_DIBSource*& pBitmap, 428 CFX_DIBSource*& pMask, 429 FX_DWORD& MatteColor, 430 CPDF_Dictionary* pPageResources, 431 FX_BOOL bStdCS = FALSE, 432 FX_DWORD GroupFamily = 0, 433 FX_BOOL bLoadMask = FALSE, 434 CPDF_RenderStatus* pRenderStatus = NULL, 435 int32_t downsampleWidth = 0, 436 int32_t downsampleHeight = 0); EstimateSize()437 FX_DWORD EstimateSize() const { return m_dwCacheSize; } GetTimeCount()438 FX_DWORD GetTimeCount() const { return m_dwTimeCount; } GetStream()439 CPDF_Stream* GetStream() const { return m_pStream; } SetTimeCount(FX_DWORD dwTimeCount)440 void SetTimeCount(FX_DWORD dwTimeCount) { m_dwTimeCount = dwTimeCount; } 441 int m_dwTimeCount; 442 443 public: 444 int StartGetCachedBitmap(CPDF_Dictionary* pFormResources, 445 CPDF_Dictionary* pPageResources, 446 FX_BOOL bStdCS = FALSE, 447 FX_DWORD GroupFamily = 0, 448 FX_BOOL bLoadMask = FALSE, 449 CPDF_RenderStatus* pRenderStatus = NULL, 450 int32_t downsampleWidth = 0, 451 int32_t downsampleHeight = 0); 452 int Continue(IFX_Pause* pPause); 453 CFX_DIBSource* DetachBitmap(); 454 CFX_DIBSource* DetachMask(); 455 CFX_DIBSource* m_pCurBitmap; 456 CFX_DIBSource* m_pCurMask; 457 FX_DWORD m_MatteColor; 458 CPDF_RenderStatus* m_pRenderStatus; 459 460 protected: 461 void ContinueGetCachedBitmap(); 462 463 CPDF_Document* m_pDocument; 464 CPDF_Stream* m_pStream; 465 CFX_DIBSource* m_pCachedBitmap; 466 CFX_DIBSource* m_pCachedMask; 467 FX_DWORD m_dwCacheSize; 468 void CalcSize(); 469 }; 470 typedef struct { 471 FX_FLOAT m_DecodeMin; 472 FX_FLOAT m_DecodeStep; 473 int m_ColorKeyMin; 474 int m_ColorKeyMax; 475 } DIB_COMP_DATA; 476 477 class CPDF_DIBSource : public CFX_DIBSource { 478 public: 479 CPDF_DIBSource(); 480 ~CPDF_DIBSource() override; 481 482 FX_BOOL Load(CPDF_Document* pDoc, 483 const CPDF_Stream* pStream, 484 CPDF_DIBSource** ppMask, 485 FX_DWORD* pMatteColor, 486 CPDF_Dictionary* pFormResources, 487 CPDF_Dictionary* pPageResources, 488 FX_BOOL bStdCS = FALSE, 489 FX_DWORD GroupFamily = 0, 490 FX_BOOL bLoadMask = FALSE); 491 492 // CFX_DIBSource 493 FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) const override; 494 uint8_t* GetBuffer() const override; 495 const uint8_t* GetScanline(int line) const override; 496 void DownSampleScanline(int line, 497 uint8_t* dest_scan, 498 int dest_bpp, 499 int dest_width, 500 FX_BOOL bFlipX, 501 int clip_left, 502 int clip_width) const override; 503 void SetDownSampleSize(int dest_width, int dest_height) const override; 504 505 CFX_DIBitmap* GetBitmap() const; 506 void ReleaseBitmap(CFX_DIBitmap*) const; 507 void ClearImageData(); 508 509 int StartLoadDIBSource(CPDF_Document* pDoc, 510 const CPDF_Stream* pStream, 511 FX_BOOL bHasMask, 512 CPDF_Dictionary* pFormResources, 513 CPDF_Dictionary* pPageResources, 514 FX_BOOL bStdCS = FALSE, 515 FX_DWORD GroupFamily = 0, 516 FX_BOOL bLoadMask = FALSE); 517 int ContinueLoadDIBSource(IFX_Pause* pPause); 518 int StratLoadMask(); 519 int StartLoadMaskDIB(); 520 int ContinueLoadMaskDIB(IFX_Pause* pPause); 521 int ContinueToLoadMask(); 522 CPDF_DIBSource* DetachMask(); 523 CPDF_DIBSource* m_pMask; 524 FX_DWORD m_MatteColor; 525 void* m_pJbig2Context; 526 CPDF_StreamAcc* m_pGlobalStream; 527 FX_BOOL m_bStdCS; 528 int m_Status; 529 CPDF_Stream* m_pMaskStream; 530 FX_BOOL m_bHasMask; 531 532 private: 533 bool LoadColorInfo(const CPDF_Dictionary* pFormResources, 534 const CPDF_Dictionary* pPageResources); 535 DIB_COMP_DATA* GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, 536 FX_BOOL& bColorKey); 537 CPDF_DIBSource* LoadMask(FX_DWORD& MatteColor); 538 CPDF_DIBSource* LoadMaskDIB(CPDF_Stream* pMask); 539 void LoadJpxBitmap(); 540 void LoadPalette(); 541 int CreateDecoder(); 542 void TranslateScanline24bpp(uint8_t* dest_scan, 543 const uint8_t* src_scan) const; 544 void ValidateDictParam(); 545 void DownSampleScanline1Bit(int orig_Bpp, 546 int dest_Bpp, 547 FX_DWORD src_width, 548 const uint8_t* pSrcLine, 549 uint8_t* dest_scan, 550 int dest_width, 551 FX_BOOL bFlipX, 552 int clip_left, 553 int clip_width) const; 554 void DownSampleScanline8Bit(int orig_Bpp, 555 int dest_Bpp, 556 FX_DWORD src_width, 557 const uint8_t* pSrcLine, 558 uint8_t* dest_scan, 559 int dest_width, 560 FX_BOOL bFlipX, 561 int clip_left, 562 int clip_width) const; 563 void DownSampleScanline32Bit(int orig_Bpp, 564 int dest_Bpp, 565 FX_DWORD src_width, 566 const uint8_t* pSrcLine, 567 uint8_t* dest_scan, 568 int dest_width, 569 FX_BOOL bFlipX, 570 int clip_left, 571 int clip_width) const; 572 FX_BOOL TransMask() const; 573 574 CPDF_Document* m_pDocument; 575 const CPDF_Stream* m_pStream; 576 CPDF_StreamAcc* m_pStreamAcc; 577 const CPDF_Dictionary* m_pDict; 578 CPDF_ColorSpace* m_pColorSpace; 579 FX_DWORD m_Family; 580 FX_DWORD m_bpc; 581 FX_DWORD m_bpc_orig; 582 FX_DWORD m_nComponents; 583 FX_DWORD m_GroupFamily; 584 FX_BOOL m_bLoadMask; 585 FX_BOOL m_bDefaultDecode; 586 FX_BOOL m_bImageMask; 587 FX_BOOL m_bDoBpcCheck; 588 FX_BOOL m_bColorKey; 589 DIB_COMP_DATA* m_pCompData; 590 uint8_t* m_pLineBuf; 591 uint8_t* m_pMaskedLine; 592 std::unique_ptr<CFX_DIBitmap> m_pCachedBitmap; 593 ICodec_ScanlineDecoder* m_pDecoder; 594 }; 595 596 #define FPDF_HUGE_IMAGE_SIZE 60000000 597 class CPDF_DIBTransferFunc : public CFX_FilteredDIB { 598 public: 599 CPDF_DIBTransferFunc(const CPDF_TransferFunc* pTransferFunc); 600 ~CPDF_DIBTransferFunc() override; 601 602 // CFX_FilteredDIB 603 FXDIB_Format GetDestFormat() override; GetDestPalette()604 FX_ARGB* GetDestPalette() override { return NULL; } 605 void TranslateScanline(uint8_t* dest_buf, 606 const uint8_t* src_buf) const override; 607 void TranslateDownSamples(uint8_t* dest_buf, 608 const uint8_t* src_buf, 609 int pixels, 610 int Bpp) const override; 611 612 const uint8_t* m_RampR; 613 const uint8_t* m_RampG; 614 const uint8_t* m_RampB; 615 }; 616 617 struct _CPDF_UniqueKeyGen { 618 void Generate(int count, ...); 619 FX_CHAR m_Key[128]; 620 int m_KeyLen; 621 }; 622 623 #endif // CORE_SRC_FPDFAPI_FPDF_RENDER_RENDER_INT_H_ 624