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