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