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