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