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