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