Re-land else-after-returns
[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     void*                       m_DeviceHandle;
257     void*           m_LoadHandle;
258     FX_BOOL                             m_bStdCS;
259     int                                 m_BlendType;
260     FX_BOOL                             StartBitmapAlpha();
261     FX_BOOL                             StartDIBSource();
262     FX_BOOL                             StartRenderDIBSource();
263     FX_BOOL                             StartLoadDIBSource();
264     FX_BOOL                             DrawMaskedImage();
265     FX_BOOL                             DrawPatternImage(const CFX_Matrix* pObj2Device);
266 };
267 class CPDF_ScaledRenderBuffer
268 {
269 public:
270     CPDF_ScaledRenderBuffer();
271     ~CPDF_ScaledRenderBuffer();
272     FX_BOOL                             Initialize(CPDF_RenderContext* pContext, CFX_RenderDevice* pDevice, FX_RECT* pRect,
273                                    const CPDF_PageObject* pObj, const CPDF_RenderOptions *pOptions = NULL, int max_dpi = 0);
274     CFX_RenderDevice*   GetDevice()
275     {
276         return m_pBitmapDevice ? m_pBitmapDevice : m_pDevice;
277     }
278     CFX_AffineMatrix*   GetMatrix()
279     {
280         return &m_Matrix;
281     }
282     void                                OutputToDevice();
283 private:
284     CFX_RenderDevice*   m_pDevice;
285     CPDF_RenderContext* m_pContext;
286     FX_RECT                             m_Rect;
287     const CPDF_PageObject* m_pObject;
288     CFX_FxgeDevice*     m_pBitmapDevice;
289     CFX_AffineMatrix    m_Matrix;
290 };
291 class ICodec_ScanlineDecoder;
292 class CPDF_QuickStretcher
293 {
294 public:
295     CPDF_QuickStretcher();
296     ~CPDF_QuickStretcher();
297     FX_BOOL             Start(CPDF_ImageObject* pImageObj, CFX_AffineMatrix* pImage2Device, const FX_RECT* pClipBox);
298     FX_BOOL             Continue(IFX_Pause* pPause);
299     CFX_DIBitmap*       m_pBitmap;
300     int                 m_ResultLeft, m_ResultTop, m_ClipLeft, m_ClipTop;
301     int                 m_DestWidth, m_DestHeight, m_ResultWidth, m_ResultHeight;
302     int                 m_Bpp, m_SrcWidth, m_SrcHeight;
303     FX_BOOL             m_bFlipX, m_bFlipY;
304     CPDF_ColorSpace*    m_pCS;
305     ICodec_ScanlineDecoder*     m_pDecoder;
306     CPDF_StreamAcc m_StreamAcc;
307     int                 m_LineIndex;
308 };
309 class CPDF_DeviceBuffer
310 {
311 public:
312     CPDF_DeviceBuffer();
313     ~CPDF_DeviceBuffer();
314     FX_BOOL                             Initialize(CPDF_RenderContext* pContext, CFX_RenderDevice* pDevice, FX_RECT* pRect,
315                                    const CPDF_PageObject* pObj, int max_dpi = 0);
316     void                                OutputToDevice();
317     CFX_DIBitmap*               GetBitmap() const
318     {
319         return m_pBitmap;
320     }
321     const CFX_AffineMatrix*     GetMatrix() const
322     {
323         return &m_Matrix;
324     }
325 private:
326     CFX_RenderDevice*   m_pDevice;
327     CPDF_RenderContext* m_pContext;
328     FX_RECT                             m_Rect;
329     const CPDF_PageObject* m_pObject;
330     CFX_DIBitmap*               m_pBitmap;
331     CFX_AffineMatrix    m_Matrix;
332 };
333 class CPDF_ImageCache
334 {
335 public:
336     CPDF_ImageCache(CPDF_Document* pDoc, CPDF_Stream* pStream);
337     ~CPDF_ImageCache();
338     void                                ClearImageData();
339     void                                Reset(const CFX_DIBitmap* pBitmap);
340     FX_BOOL                             GetCachedBitmap(CFX_DIBSource*& pBitmap, CFX_DIBSource*& pMask, FX_DWORD& MatteColor, CPDF_Dictionary* pPageResources,
341                                         FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE,
342                                         CPDF_RenderStatus* pRenderStatus = NULL, int32_t downsampleWidth = 0, int32_t downsampleHeight = 0);
343     FX_DWORD                    EstimateSize() const
344     {
345         return m_dwCacheSize;
346     }
347     FX_DWORD                    GetTimeCount() const
348     {
349         return m_dwTimeCount;
350     }
351     CPDF_Stream*                GetStream() const
352     {
353         return m_pStream;
354     }
355     void                                SetTimeCount(FX_DWORD dwTimeCount)
356     {
357         m_dwTimeCount = dwTimeCount;
358     }
359     int                                 m_dwTimeCount;
360 public:
361     int                                 StartGetCachedBitmap(CPDF_Dictionary* pFormResources, CPDF_Dictionary* pPageResources,
362             FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0,
363             FX_BOOL bLoadMask = FALSE, CPDF_RenderStatus* pRenderStatus = NULL, int32_t downsampleWidth = 0, int32_t downsampleHeight = 0);
364     int                                 Continue(IFX_Pause* pPause);
365     int                                 ContinueGetCachedBitmap();
366     CFX_DIBSource*              DetachBitmap();
367     CFX_DIBSource*              DetachMask();
368     CFX_DIBSource*              m_pCurBitmap;
369     CFX_DIBSource*              m_pCurMask;
370     FX_DWORD                    m_MatteColor;
371     CPDF_RenderStatus*  m_pRenderStatus;
372 protected:
373     CPDF_Document*              m_pDocument;
374     CPDF_Stream*                m_pStream;
375     CFX_DIBSource*              m_pCachedBitmap;
376     CFX_DIBSource*              m_pCachedMask;
377     FX_DWORD                    m_dwCacheSize;
378     void        CalcSize();
379 };
380 typedef struct {
381     FX_FLOAT                    m_DecodeMin;
382     FX_FLOAT                    m_DecodeStep;
383     int                                 m_ColorKeyMin;
384     int                                 m_ColorKeyMax;
385 } DIB_COMP_DATA;
386 class CPDF_DIBSource : public CFX_DIBSource
387 {
388 public:
389     CPDF_DIBSource();
390     virtual ~CPDF_DIBSource();
391     FX_BOOL                             Load(CPDF_Document* pDoc, const CPDF_Stream* pStream,
392                              CPDF_DIBSource** ppMask, FX_DWORD* pMatteColor,
393                              CPDF_Dictionary* pFormResources, CPDF_Dictionary* pPageResources,
394                              FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE);
395     virtual FX_BOOL             SkipToScanline(int line, IFX_Pause* pPause) const;
396     virtual     uint8_t*        GetBuffer() const;
397     virtual const uint8_t*      GetScanline(int line) const;
398     virtual void                DownSampleScanline(int line, uint8_t* dest_scan, int dest_bpp,
399                                            int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const;
400     virtual void                SetDownSampleSize(int dest_width, int dest_height) const;
401     CFX_DIBitmap*               GetBitmap() const;
402     void                                ReleaseBitmap(CFX_DIBitmap*) const;
403     void                                ClearImageData();
404 public:
405     int                                 StartLoadDIBSource(CPDF_Document* pDoc, const CPDF_Stream* pStream, FX_BOOL bHasMask,
406                                            CPDF_Dictionary* pFormResources, CPDF_Dictionary* pPageResources,
407                                            FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE);
408     int                                 ContinueLoadDIBSource(IFX_Pause* pPause);
409     int                                 StratLoadMask();
410     int                                 StartLoadMaskDIB();
411     int                                 ContinueLoadMaskDIB(IFX_Pause* pPause);
412     int                                 ContinueToLoadMask();
413     CPDF_DIBSource*             DetachMask();
414     CPDF_DIBSource*             m_pMask;
415     FX_DWORD                    m_MatteColor;
416     void*                       m_pJbig2Context;
417     CPDF_StreamAcc*             m_pGlobalStream;
418     FX_BOOL                             m_bStdCS;
419     int                                 m_Status;
420     CPDF_Object*                m_pMaskStream;
421     FX_BOOL                             m_bHasMask;
422 protected:
423     FX_BOOL                             LoadColorInfo(CPDF_Dictionary* pFormResources, CPDF_Dictionary* pPageResources);
424     DIB_COMP_DATA*      GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, FX_BOOL& bColorKey);
425     CPDF_DIBSource*             LoadMask(FX_DWORD& MatteColor);
426     CPDF_DIBSource*             LoadMaskDIB(CPDF_Stream* pMask);
427     void                                LoadJpxBitmap();
428     void                                LoadPalette();
429     int                                 CreateDecoder();
430     void                                TranslateScanline24bpp(uint8_t* dest_scan, const uint8_t* src_scan) const;
431     void                ValidateDictParam();
432     CPDF_Document*              m_pDocument;
433     const CPDF_Stream*  m_pStream;
434     CPDF_StreamAcc*             m_pStreamAcc;
435     const CPDF_Dictionary*      m_pDict;
436     CPDF_ColorSpace*    m_pColorSpace;
437     FX_DWORD                    m_Family;
438     FX_DWORD                    m_bpc;
439     FX_DWORD                    m_bpc_orig;
440     FX_DWORD                    m_nComponents;
441     FX_DWORD                    m_GroupFamily;
442     FX_BOOL                             m_bLoadMask;
443     FX_BOOL                             m_bDefaultDecode;
444     FX_BOOL                             m_bImageMask;
445     FX_BOOL                             m_bDoBpcCheck;
446     FX_BOOL                             m_bColorKey;
447     DIB_COMP_DATA*              m_pCompData;
448     uint8_t*                    m_pLineBuf;
449     uint8_t*                    m_pMaskedLine;
450     nonstd::unique_ptr<CFX_DIBitmap> m_pCachedBitmap;
451     ICodec_ScanlineDecoder*     m_pDecoder;
452 };
453 #define FPDF_HUGE_IMAGE_SIZE    60000000
454 class CPDF_DIBTransferFunc : public CFX_FilteredDIB
455 {
456 public:
457     CPDF_DIBTransferFunc(const CPDF_TransferFunc* pTransferFunc);
458     virtual FXDIB_Format        GetDestFormat();
459     virtual FX_ARGB*            GetDestPalette()
460     {
461         return NULL;
462     }
463     virtual void                        TranslateScanline(uint8_t* dest_buf, const uint8_t* src_buf) const;
464     virtual void                        TranslateDownSamples(uint8_t* dest_buf, const uint8_t* src_buf, int pixels, int Bpp) const;
465     const uint8_t*                              m_RampR;
466     const uint8_t*                              m_RampG;
467     const uint8_t*                              m_RampB;
468 };
469 struct _CPDF_UniqueKeyGen {
470     void                Generate(int count, ...);
471     FX_CHAR             m_Key[128];
472     int                 m_KeyLen;
473 };
474
475 #endif  // CORE_SRC_FPDFAPI_FPDF_RENDER_RENDER_INT_H_