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