Initial commit.
[pdfium.git] / core / src / fxge / win32 / win32_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 struct  WINDIB_Open_Args_;\r
8 class CGdiplusExt\r
9 {\r
10 public:\r
11     CGdiplusExt();\r
12     ~CGdiplusExt();\r
13     void                        Load();\r
14     FX_BOOL                     IsAvailable()\r
15     {\r
16         return m_hModule != NULL;\r
17     }\r
18     FX_BOOL                     StretchBitMask(HDC hDC, BOOL bMonoDevice, const CFX_DIBitmap* pBitmap, int dest_left, int dest_top,\r
19                                    int dest_width, int dest_height, FX_DWORD argb, const FX_RECT* pClipRect, int flags);\r
20     FX_BOOL                     StretchDIBits(HDC hDC, const CFX_DIBitmap* pBitmap, int dest_left, int dest_top,\r
21                                   int dest_width, int dest_height, const FX_RECT* pClipRect, int flags);\r
22     FX_BOOL                     DrawPath(HDC hDC, const CFX_PathData* pPathData,\r
23                              const CFX_AffineMatrix* pObject2Device,\r
24                              const CFX_GraphStateData* pGraphState,\r
25                              FX_DWORD fill_argb,\r
26                              FX_DWORD stroke_argb,\r
27                              int fill_mode\r
28                       );\r
29 \r
30     void*                       LoadMemFont(FX_BYTE* pData, FX_DWORD size);\r
31     void                        DeleteMemFont(void* pFontCollection);\r
32     FX_BOOL         GdipCreateFromImage(void* bitmap, void** graphics);\r
33     void            GdipDeleteGraphics(void* graphics);\r
34     void            GdipSetTextRenderingHint(void* graphics, int mode);\r
35     void            GdipSetPageUnit(void* graphics, FX_DWORD unit);\r
36     void            GdipSetWorldTransform(void* graphics, void* pMatrix);\r
37     FX_BOOL         GdipDrawDriverString(void *graphics,  unsigned short *text, int length, void *font, void* brush, void *positions, int flags, const void *matrix);\r
38     void            GdipCreateBrush(FX_DWORD fill_argb, void** pBrush);\r
39     void            GdipDeleteBrush(void* pBrush);\r
40     void            GdipCreateMatrix(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, void** matrix);\r
41     void            GdipDeleteMatrix(void* matrix);\r
42     FX_BOOL         GdipCreateFontFamilyFromName(FX_LPCWSTR name, void* pFontCollection, void**pFamily);\r
43     void            GdipDeleteFontFamily(void* pFamily);\r
44     FX_BOOL         GdipCreateFontFromFamily(void* pFamily, FX_FLOAT font_size, int fontstyle, int flag, void** pFont);\r
45     void*           GdipCreateFontFromCollection(void* pFontCollection, FX_FLOAT font_size, int fontstyle);\r
46     void            GdipDeleteFont(void* pFont);\r
47     FX_BOOL         GdipCreateBitmap(CFX_DIBitmap* pBitmap, void**bitmap);\r
48     void            GdipDisposeImage(void* bitmap);\r
49     void            GdipGetFontSize(void *pFont, FX_FLOAT *size);\r
50     void*           GdiAddFontMemResourceEx(void *pFontdata, FX_DWORD size, void* pdv, FX_DWORD* num_face);\r
51     FX_BOOL         GdiRemoveFontMemResourceEx(void* handle);\r
52     void*                       m_Functions[100];\r
53     void*           m_pGdiAddFontMemResourceEx;\r
54     void*           m_pGdiRemoveFontMemResourseEx;\r
55     CFX_DIBitmap*       LoadDIBitmap(WINDIB_Open_Args_ args);\r
56 protected:\r
57     HMODULE                     m_hModule;\r
58     HMODULE         m_GdiModule;\r
59 };\r
60 #include "dwrite_int.h"\r
61 class CWin32Platform : public CFX_Object\r
62 {\r
63 public:\r
64     FX_BOOL                     m_bHalfTone;\r
65     CGdiplusExt         m_GdiplusExt;\r
66     CDWriteExt      m_DWriteExt;\r
67 };\r
68 class CGdiDeviceDriver : public IFX_RenderDeviceDriver\r
69 {\r
70 protected:\r
71     virtual int         GetDeviceCaps(int caps_id);\r
72     virtual void        SaveState()\r
73     {\r
74         SaveDC(m_hDC);\r
75     }\r
76     virtual void        RestoreState(FX_BOOL bKeepSaved = FALSE)\r
77     {\r
78         RestoreDC(m_hDC, -1);\r
79         if (bKeepSaved) {\r
80             SaveDC(m_hDC);\r
81         }\r
82     }\r
83     virtual FX_BOOL     SetClip_PathFill(const CFX_PathData* pPathData,\r
84                                      const CFX_AffineMatrix* pObject2Device,\r
85                                      int fill_mode\r
86                                     );\r
87     virtual FX_BOOL     SetClip_PathStroke(const CFX_PathData* pPathData,\r
88                                        const CFX_AffineMatrix* pObject2Device,\r
89                                        const CFX_GraphStateData* pGraphState\r
90                                       );\r
91     virtual FX_BOOL     DrawPath(const CFX_PathData* pPathData,\r
92                              const CFX_AffineMatrix* pObject2Device,\r
93                              const CFX_GraphStateData* pGraphState,\r
94                              FX_DWORD fill_color,\r
95                              FX_DWORD stroke_color,\r
96                              int fill_mode,\r
97                              int alpha_flag,\r
98                              void* pIccTransform,\r
99                              int        blend_type\r
100                             );\r
101     virtual FX_BOOL FillRect(const FX_RECT* pRect,\r
102                              FX_DWORD fill_color,\r
103                              int alpha_flag, void* pIccTransform, int blend_type);\r
104     virtual FX_BOOL     DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2, FX_DWORD color,\r
105                                      int alpha_flag, void* pIccTransform, int blend_type);\r
106     virtual FX_LPVOID GetClipRgn() ;\r
107     virtual FX_BOOL SetClipRgn(FX_LPVOID pRgn) ;\r
108     virtual FX_BOOL GetClipBox(FX_RECT* pRect);\r
109     virtual FX_BOOL DeleteDeviceRgn(FX_LPVOID pRgn);\r
110     virtual void        DrawLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2);\r
111     virtual void*       GetPlatformSurface()\r
112     {\r
113         return (void*)m_hDC;\r
114     }\r
115     FX_BOOL                     GDI_SetDIBits(const CFX_DIBitmap* pBitmap, const FX_RECT* pSrcRect, int left, int top,\r
116                                   void* pIccTransform);\r
117     FX_BOOL                     GDI_StretchDIBits(const CFX_DIBitmap* pBitmap, int dest_left, int dest_top,\r
118                                       int dest_width, int dest_height, FX_DWORD flags,\r
119                                       void* pIccTransform);\r
120     FX_BOOL                     GDI_StretchBitMask(const CFX_DIBitmap* pBitmap, int dest_left, int dest_top,\r
121                                        int dest_width, int dest_height, FX_DWORD bitmap_color, FX_DWORD flags,\r
122                                        int alpha_flag, void* pIccTransform);\r
123     HDC                         m_hDC;\r
124     int                         m_Width, m_Height, m_nBitsPerPixel;\r
125     int                         m_DeviceClass, m_RenderCaps;\r
126     CGdiDeviceDriver(HDC hDC, int device_class);\r
127     ~CGdiDeviceDriver() {}\r
128 };\r
129 class CGdiDisplayDriver : public CGdiDeviceDriver\r
130 {\r
131 public:\r
132     CGdiDisplayDriver(HDC hDC);\r
133 protected:\r
134     virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void* pIccTransform = NULL, FX_BOOL bDEdge = FALSE);\r
135     virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, const FX_RECT* pSrcRect, int left, int top, int blend_type,\r
136                               int alpha_flag, void* pIccTransform);\r
137     virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top,\r
138                                   int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flags,\r
139                                   int alpha_flag, void* pIccTransform, int blend_type);\r
140     virtual FX_BOOL     StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD color,\r
141                                 const CFX_AffineMatrix* pMatrix, FX_DWORD render_flags, FX_LPVOID& handle,\r
142                                 int alpha_flag, void* pIccTransform, int blend_type)\r
143     {\r
144         return FALSE;\r
145     }\r
146     FX_BOOL                     UseFoxitStretchEngine(const CFX_DIBSource* pSource, FX_DWORD color, int dest_left, int dest_top,\r
147                                           int dest_width, int dest_height, const FX_RECT* pClipRect, int render_flags,\r
148                                           int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);\r
149 };\r
150 class CGdiPrinterDriver : public CGdiDeviceDriver\r
151 {\r
152 public:\r
153     CGdiPrinterDriver(HDC hDC);\r
154 protected:\r
155     virtual int         GetDeviceCaps(int caps_id);\r
156     virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, const FX_RECT* pSrcRect, int left, int top, int blend_type,\r
157                               int alpha_flag, void* pIccTransform);\r
158     virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top,\r
159                                   int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flags,\r
160                                   int alpha_flag, void* pIccTransform, int blend_type);\r
161     virtual FX_BOOL     StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD color,\r
162                                 const CFX_AffineMatrix* pMatrix, FX_DWORD render_flags, FX_LPVOID& handle,\r
163                                 int alpha_flag, void* pIccTransform, int blend_type);\r
164     int                         m_HorzSize, m_VertSize;\r
165     FX_BOOL                     m_bSupportROP;\r
166 };\r
167 class CPSOutput : public IFX_PSOutput, public CFX_Object\r
168 {\r
169 public:\r
170     CPSOutput(HDC hDC);\r
171     virtual ~CPSOutput();\r
172     virtual void                        Release()\r
173     {\r
174         delete this;\r
175     }\r
176     void Init();\r
177     virtual void        OutputPS(FX_LPCSTR string, int len);\r
178     HDC                         m_hDC;\r
179     FX_LPSTR        m_pBuf;\r
180 };\r
181 class CPSPrinterDriver : public IFX_RenderDeviceDriver\r
182 {\r
183 public:\r
184     CPSPrinterDriver();\r
185     FX_BOOL                     Init(HDC hDC, int ps_level, FX_BOOL bCmykOutput);\r
186     ~CPSPrinterDriver();\r
187 protected:\r
188     virtual FX_BOOL IsPSPrintDriver()\r
189     {\r
190         return TRUE;\r
191     }\r
192     virtual int         GetDeviceCaps(int caps_id);\r
193     virtual FX_BOOL     StartRendering();\r
194     virtual void        EndRendering();\r
195     virtual void        SaveState();\r
196     virtual void        RestoreState(FX_BOOL bKeepSaved = FALSE);\r
197     virtual FX_BOOL     SetClip_PathFill(const CFX_PathData* pPathData,\r
198                                      const CFX_AffineMatrix* pObject2Device,\r
199                                      int fill_mode\r
200                                     );\r
201     virtual FX_BOOL     SetClip_PathStroke(const CFX_PathData* pPathData,\r
202                                        const CFX_AffineMatrix* pObject2Device,\r
203                                        const CFX_GraphStateData* pGraphState\r
204                                       );\r
205     virtual FX_BOOL     DrawPath(const CFX_PathData* pPathData,\r
206                              const CFX_AffineMatrix* pObject2Device,\r
207                              const CFX_GraphStateData* pGraphState,\r
208                              FX_DWORD fill_color,\r
209                              FX_DWORD stroke_color,\r
210                              int fill_mode,\r
211                              int alpha_flag,\r
212                              void* pIccTransform,\r
213                              int blend_type\r
214                             );\r
215     virtual FX_BOOL GetClipBox(FX_RECT* pRect);\r
216     virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, const FX_RECT* pSrcRect, int left, int top, int blend_type,\r
217                               int alpha_flag, void* pIccTransform);\r
218     virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top,\r
219                                   int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flags,\r
220                                   int alpha_flag, void* pIccTransform, int blend_type);\r
221     virtual FX_BOOL     StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD color,\r
222                                 const CFX_AffineMatrix* pMatrix, FX_DWORD render_flags, FX_LPVOID& handle,\r
223                                 int alpha_flag, void* pIccTransform, int blend_type);\r
224     virtual FX_BOOL DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont,\r
225                                    CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FLOAT font_size, FX_DWORD color,\r
226                                    int alpha_flag, void* pIccTransform);\r
227     virtual void*       GetPlatformSurface()\r
228     {\r
229         return (void*)m_hDC;\r
230     }\r
231     HDC                         m_hDC;\r
232     FX_BOOL                     m_bCmykOutput;\r
233     int                         m_Width, m_Height, m_nBitsPerPixel;\r
234     int                         m_HorzSize, m_VertSize;\r
235     CPSOutput*          m_pPSOutput;\r
236     CFX_PSRenderer      m_PSRenderer;\r
237 };\r
238 void _Color2Argb(FX_ARGB& argb, FX_DWORD color, int alpha_flag, void* pIccTransform);\r