OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_FXGE_WIN32_WIN32_INT_H_ | 7 #ifndef CORE_FXGE_WIN32_WIN32_INT_H_ |
8 #define CORE_FXGE_WIN32_WIN32_INT_H_ | 8 #define CORE_FXGE_WIN32_WIN32_INT_H_ |
9 | 9 |
10 #include <windows.h> | 10 #include <windows.h> |
11 | 11 |
12 #include "core/fxge/cfx_pathdata.h" | 12 #include "core/fxge/cfx_pathdata.h" |
13 #include "core/fxge/ifx_renderdevicedriver.h" | 13 #include "core/fxge/ifx_renderdevicedriver.h" |
14 #include "core/fxge/win32/dwrite_int.h" | 14 #include "core/fxge/win32/dwrite_int.h" |
15 | 15 |
16 struct FXTEXT_CHARPOS; | 16 struct FXTEXT_CHARPOS; |
17 struct WINDIB_Open_Args_; | 17 struct WINDIB_Open_Args_; |
18 | 18 |
19 typedef HANDLE(__stdcall* FuncType_GdiAddFontMemResourceEx)(PVOID pbFont, | 19 typedef HANDLE(__stdcall* FuncType_GdiAddFontMemResourceEx)(PVOID pbFont, |
20 DWORD cbFont, | 20 DWORD cbFont, |
21 PVOID pdv, | 21 PVOID pdv, |
22 DWORD* pcFonts); | 22 DWORD* pcFonts); |
23 typedef BOOL(__stdcall* FuncType_GdiRemoveFontMemResourceEx)(HANDLE handle); | 23 typedef BOOL(__stdcall* FuncType_GdiRemoveFontMemResourceEx)(HANDLE handle); |
24 | 24 |
25 class CGdiplusExt { | 25 class CGdiplusExt { |
26 public: | 26 public: |
27 CGdiplusExt(); | 27 CGdiplusExt(); |
28 ~CGdiplusExt(); | 28 ~CGdiplusExt(); |
29 void Load(); | 29 void Load(); |
30 FX_BOOL IsAvailable() { return !!m_hModule; } | 30 bool IsAvailable() { return !!m_hModule; } |
31 FX_BOOL StretchBitMask(HDC hDC, | 31 bool StretchBitMask(HDC hDC, |
32 BOOL bMonoDevice, | 32 BOOL bMonoDevice, |
33 const CFX_DIBitmap* pBitmap, | 33 const CFX_DIBitmap* pBitmap, |
34 int dest_left, | 34 int dest_left, |
35 int dest_top, | 35 int dest_top, |
36 int dest_width, | 36 int dest_width, |
37 int dest_height, | 37 int dest_height, |
38 uint32_t argb, | 38 uint32_t argb, |
39 const FX_RECT* pClipRect, | 39 const FX_RECT* pClipRect, |
40 int flags); | 40 int flags); |
41 FX_BOOL StretchDIBits(HDC hDC, | 41 bool StretchDIBits(HDC hDC, |
42 const CFX_DIBitmap* pBitmap, | 42 const CFX_DIBitmap* pBitmap, |
43 int dest_left, | 43 int dest_left, |
44 int dest_top, | 44 int dest_top, |
45 int dest_width, | 45 int dest_width, |
46 int dest_height, | 46 int dest_height, |
47 const FX_RECT* pClipRect, | 47 const FX_RECT* pClipRect, |
48 int flags); | 48 int flags); |
49 FX_BOOL DrawPath(HDC hDC, | 49 bool DrawPath(HDC hDC, |
50 const CFX_PathData* pPathData, | 50 const CFX_PathData* pPathData, |
51 const CFX_Matrix* pObject2Device, | 51 const CFX_Matrix* pObject2Device, |
52 const CFX_GraphStateData* pGraphState, | 52 const CFX_GraphStateData* pGraphState, |
53 uint32_t fill_argb, | 53 uint32_t fill_argb, |
54 uint32_t stroke_argb, | 54 uint32_t stroke_argb, |
55 int fill_mode); | 55 int fill_mode); |
56 | 56 |
57 void* LoadMemFont(uint8_t* pData, uint32_t size); | 57 void* LoadMemFont(uint8_t* pData, uint32_t size); |
58 void DeleteMemFont(void* pFontCollection); | 58 void DeleteMemFont(void* pFontCollection); |
59 FX_BOOL GdipCreateFromImage(void* bitmap, void** graphics); | 59 bool GdipCreateFromImage(void* bitmap, void** graphics); |
60 void GdipDeleteGraphics(void* graphics); | 60 void GdipDeleteGraphics(void* graphics); |
61 void GdipSetTextRenderingHint(void* graphics, int mode); | 61 void GdipSetTextRenderingHint(void* graphics, int mode); |
62 void GdipSetPageUnit(void* graphics, uint32_t unit); | 62 void GdipSetPageUnit(void* graphics, uint32_t unit); |
63 void GdipSetWorldTransform(void* graphics, void* pMatrix); | 63 void GdipSetWorldTransform(void* graphics, void* pMatrix); |
64 FX_BOOL GdipDrawDriverString(void* graphics, | 64 bool GdipDrawDriverString(void* graphics, |
65 unsigned short* text, | 65 unsigned short* text, |
66 int length, | 66 int length, |
67 void* font, | 67 void* font, |
68 void* brush, | 68 void* brush, |
69 void* positions, | 69 void* positions, |
70 int flags, | 70 int flags, |
71 const void* matrix); | 71 const void* matrix); |
72 void GdipCreateBrush(uint32_t fill_argb, void** pBrush); | 72 void GdipCreateBrush(uint32_t fill_argb, void** pBrush); |
73 void GdipDeleteBrush(void* pBrush); | 73 void GdipDeleteBrush(void* pBrush); |
74 void GdipCreateMatrix(FX_FLOAT a, | 74 void GdipCreateMatrix(FX_FLOAT a, |
75 FX_FLOAT b, | 75 FX_FLOAT b, |
76 FX_FLOAT c, | 76 FX_FLOAT c, |
77 FX_FLOAT d, | 77 FX_FLOAT d, |
78 FX_FLOAT e, | 78 FX_FLOAT e, |
79 FX_FLOAT f, | 79 FX_FLOAT f, |
80 void** matrix); | 80 void** matrix); |
81 void GdipDeleteMatrix(void* matrix); | 81 void GdipDeleteMatrix(void* matrix); |
82 FX_BOOL GdipCreateFontFamilyFromName(const FX_WCHAR* name, | 82 bool GdipCreateFontFamilyFromName(const FX_WCHAR* name, |
83 void* pFontCollection, | 83 void* pFontCollection, |
84 void** pFamily); | 84 void** pFamily); |
85 void GdipDeleteFontFamily(void* pFamily); | 85 void GdipDeleteFontFamily(void* pFamily); |
86 FX_BOOL GdipCreateFontFromFamily(void* pFamily, | 86 bool GdipCreateFontFromFamily(void* pFamily, |
87 FX_FLOAT font_size, | 87 FX_FLOAT font_size, |
88 int fontstyle, | 88 int fontstyle, |
89 int flag, | 89 int flag, |
90 void** pFont); | 90 void** pFont); |
91 void* GdipCreateFontFromCollection(void* pFontCollection, | 91 void* GdipCreateFontFromCollection(void* pFontCollection, |
92 FX_FLOAT font_size, | 92 FX_FLOAT font_size, |
93 int fontstyle); | 93 int fontstyle); |
94 void GdipDeleteFont(void* pFont); | 94 void GdipDeleteFont(void* pFont); |
95 FX_BOOL GdipCreateBitmap(CFX_DIBitmap* pBitmap, void** bitmap); | 95 bool GdipCreateBitmap(CFX_DIBitmap* pBitmap, void** bitmap); |
96 void GdipDisposeImage(void* bitmap); | 96 void GdipDisposeImage(void* bitmap); |
97 void GdipGetFontSize(void* pFont, FX_FLOAT* size); | 97 void GdipGetFontSize(void* pFont, FX_FLOAT* size); |
98 void* GdiAddFontMemResourceEx(void* pFontdata, | 98 void* GdiAddFontMemResourceEx(void* pFontdata, |
99 uint32_t size, | 99 uint32_t size, |
100 void* pdv, | 100 void* pdv, |
101 uint32_t* num_face); | 101 uint32_t* num_face); |
102 FX_BOOL GdiRemoveFontMemResourceEx(void* handle); | 102 bool GdiRemoveFontMemResourceEx(void* handle); |
103 CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args); | 103 CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args); |
104 | 104 |
105 FARPROC m_Functions[100]; | 105 FARPROC m_Functions[100]; |
106 FuncType_GdiAddFontMemResourceEx m_pGdiAddFontMemResourceEx; | 106 FuncType_GdiAddFontMemResourceEx m_pGdiAddFontMemResourceEx; |
107 FuncType_GdiRemoveFontMemResourceEx m_pGdiRemoveFontMemResourseEx; | 107 FuncType_GdiRemoveFontMemResourceEx m_pGdiRemoveFontMemResourseEx; |
108 | 108 |
109 protected: | 109 protected: |
110 HMODULE m_hModule; | 110 HMODULE m_hModule; |
111 HMODULE m_GdiModule; | 111 HMODULE m_GdiModule; |
112 }; | 112 }; |
113 | 113 |
114 class CWin32Platform { | 114 class CWin32Platform { |
115 public: | 115 public: |
116 FX_BOOL m_bHalfTone; | 116 bool m_bHalfTone; |
117 CGdiplusExt m_GdiplusExt; | 117 CGdiplusExt m_GdiplusExt; |
118 CDWriteExt m_DWriteExt; | 118 CDWriteExt m_DWriteExt; |
119 }; | 119 }; |
120 | 120 |
121 class CGdiDeviceDriver : public IFX_RenderDeviceDriver { | 121 class CGdiDeviceDriver : public IFX_RenderDeviceDriver { |
122 protected: | 122 protected: |
123 CGdiDeviceDriver(HDC hDC, int device_class); | 123 CGdiDeviceDriver(HDC hDC, int device_class); |
124 ~CGdiDeviceDriver() override; | 124 ~CGdiDeviceDriver() override; |
125 | 125 |
126 // IFX_RenderDeviceDriver | 126 // IFX_RenderDeviceDriver |
127 int GetDeviceCaps(int caps_id) const override; | 127 int GetDeviceCaps(int caps_id) const override; |
128 void SaveState() override; | 128 void SaveState() override; |
129 void RestoreState(bool bKeepSaved) override; | 129 void RestoreState(bool bKeepSaved) override; |
130 FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, | 130 bool SetClip_PathFill(const CFX_PathData* pPathData, |
131 const CFX_Matrix* pObject2Device, | 131 const CFX_Matrix* pObject2Device, |
132 int fill_mode) override; | 132 int fill_mode) override; |
133 FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, | 133 bool SetClip_PathStroke(const CFX_PathData* pPathData, |
134 const CFX_Matrix* pObject2Device, | 134 const CFX_Matrix* pObject2Device, |
135 const CFX_GraphStateData* pGraphState) override; | 135 const CFX_GraphStateData* pGraphState) override; |
136 FX_BOOL DrawPath(const CFX_PathData* pPathData, | 136 bool DrawPath(const CFX_PathData* pPathData, |
137 const CFX_Matrix* pObject2Device, | 137 const CFX_Matrix* pObject2Device, |
138 const CFX_GraphStateData* pGraphState, | 138 const CFX_GraphStateData* pGraphState, |
139 uint32_t fill_color, | 139 uint32_t fill_color, |
140 uint32_t stroke_color, | 140 uint32_t stroke_color, |
141 int fill_mode, | 141 int fill_mode, |
142 int blend_type) override; | 142 int blend_type) override; |
143 FX_BOOL FillRectWithBlend(const FX_RECT* pRect, | 143 bool FillRectWithBlend(const FX_RECT* pRect, |
144 uint32_t fill_color, | 144 uint32_t fill_color, |
145 int blend_type) override; | 145 int blend_type) override; |
146 FX_BOOL DrawCosmeticLine(FX_FLOAT x1, | 146 bool DrawCosmeticLine(FX_FLOAT x1, |
147 FX_FLOAT y1, | 147 FX_FLOAT y1, |
148 FX_FLOAT x2, | 148 FX_FLOAT x2, |
149 FX_FLOAT y2, | 149 FX_FLOAT y2, |
150 uint32_t color, | 150 uint32_t color, |
151 int blend_type) override; | 151 int blend_type) override; |
152 FX_BOOL GetClipBox(FX_RECT* pRect) override; | 152 bool GetClipBox(FX_RECT* pRect) override; |
153 void* GetPlatformSurface() const override; | 153 void* GetPlatformSurface() const override; |
154 | 154 |
155 void DrawLine(FX_FLOAT x1, | 155 void DrawLine(FX_FLOAT x1, |
156 FX_FLOAT y1, | 156 FX_FLOAT y1, |
157 FX_FLOAT x2, | 157 FX_FLOAT x2, |
158 FX_FLOAT y2, | 158 FX_FLOAT y2, |
159 const CFX_Matrix* pMatrix); | 159 const CFX_Matrix* pMatrix); |
160 | 160 |
161 FX_BOOL GDI_SetDIBits(CFX_DIBitmap* pBitmap, | 161 bool GDI_SetDIBits(CFX_DIBitmap* pBitmap, |
162 const FX_RECT* pSrcRect, | 162 const FX_RECT* pSrcRect, |
163 int left, | 163 int left, |
164 int top); | 164 int top); |
165 FX_BOOL GDI_StretchDIBits(CFX_DIBitmap* pBitmap, | 165 bool GDI_StretchDIBits(CFX_DIBitmap* pBitmap, |
166 int dest_left, | 166 int dest_left, |
167 int dest_top, | 167 int dest_top, |
168 int dest_width, | 168 int dest_width, |
169 int dest_height, | 169 int dest_height, |
170 uint32_t flags); | 170 uint32_t flags); |
171 FX_BOOL GDI_StretchBitMask(CFX_DIBitmap* pBitmap, | 171 bool GDI_StretchBitMask(CFX_DIBitmap* pBitmap, |
172 int dest_left, | 172 int dest_left, |
173 int dest_top, | 173 int dest_top, |
174 int dest_width, | 174 int dest_width, |
175 int dest_height, | 175 int dest_height, |
176 uint32_t bitmap_color, | 176 uint32_t bitmap_color, |
177 uint32_t flags); | 177 uint32_t flags); |
178 | 178 |
179 HDC m_hDC; | 179 HDC m_hDC; |
180 int m_Width; | 180 int m_Width; |
181 int m_Height; | 181 int m_Height; |
182 int m_nBitsPerPixel; | 182 int m_nBitsPerPixel; |
183 int m_DeviceClass; | 183 int m_DeviceClass; |
184 int m_RenderCaps; | 184 int m_RenderCaps; |
185 }; | 185 }; |
186 | 186 |
187 class CGdiDisplayDriver : public CGdiDeviceDriver { | 187 class CGdiDisplayDriver : public CGdiDeviceDriver { |
188 public: | 188 public: |
189 explicit CGdiDisplayDriver(HDC hDC); | 189 explicit CGdiDisplayDriver(HDC hDC); |
190 ~CGdiDisplayDriver() override; | 190 ~CGdiDisplayDriver() override; |
191 | 191 |
192 protected: | 192 protected: |
193 FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) override; | 193 bool GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) override; |
194 FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, | 194 bool SetDIBits(const CFX_DIBSource* pBitmap, |
195 uint32_t color, | 195 uint32_t color, |
196 const FX_RECT* pSrcRect, | 196 const FX_RECT* pSrcRect, |
197 int left, | 197 int left, |
198 int top, | 198 int top, |
199 int blend_type) override; | 199 int blend_type) override; |
200 FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, | 200 bool StretchDIBits(const CFX_DIBSource* pBitmap, |
201 uint32_t color, | 201 uint32_t color, |
202 int dest_left, | 202 int dest_left, |
203 int dest_top, | 203 int dest_top, |
204 int dest_width, | 204 int dest_width, |
205 int dest_height, | 205 int dest_height, |
206 const FX_RECT* pClipRect, | 206 const FX_RECT* pClipRect, |
207 uint32_t flags, | 207 uint32_t flags, |
208 int blend_type) override; | 208 int blend_type) override; |
209 FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, | 209 bool StartDIBits(const CFX_DIBSource* pBitmap, |
210 int bitmap_alpha, | 210 int bitmap_alpha, |
211 uint32_t color, | 211 uint32_t color, |
212 const CFX_Matrix* pMatrix, | 212 const CFX_Matrix* pMatrix, |
213 uint32_t render_flags, | 213 uint32_t render_flags, |
214 void*& handle, | 214 void*& handle, |
215 int blend_type) override; | 215 int blend_type) override; |
216 FX_BOOL UseFoxitStretchEngine(const CFX_DIBSource* pSource, | 216 bool UseFoxitStretchEngine(const CFX_DIBSource* pSource, |
217 uint32_t color, | 217 uint32_t color, |
218 int dest_left, | 218 int dest_left, |
219 int dest_top, | 219 int dest_top, |
220 int dest_width, | 220 int dest_width, |
221 int dest_height, | 221 int dest_height, |
222 const FX_RECT* pClipRect, | 222 const FX_RECT* pClipRect, |
223 int render_flags); | 223 int render_flags); |
224 }; | 224 }; |
225 | 225 |
226 class CGdiPrinterDriver : public CGdiDeviceDriver { | 226 class CGdiPrinterDriver : public CGdiDeviceDriver { |
227 public: | 227 public: |
228 explicit CGdiPrinterDriver(HDC hDC); | 228 explicit CGdiPrinterDriver(HDC hDC); |
229 ~CGdiPrinterDriver() override; | 229 ~CGdiPrinterDriver() override; |
230 | 230 |
231 protected: | 231 protected: |
232 int GetDeviceCaps(int caps_id) const override; | 232 int GetDeviceCaps(int caps_id) const override; |
233 FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, | 233 bool SetDIBits(const CFX_DIBSource* pBitmap, |
234 uint32_t color, | 234 uint32_t color, |
235 const FX_RECT* pSrcRect, | 235 const FX_RECT* pSrcRect, |
236 int left, | 236 int left, |
237 int top, | 237 int top, |
238 int blend_type) override; | 238 int blend_type) override; |
239 FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, | 239 bool StretchDIBits(const CFX_DIBSource* pBitmap, |
240 uint32_t color, | 240 uint32_t color, |
241 int dest_left, | 241 int dest_left, |
242 int dest_top, | 242 int dest_top, |
243 int dest_width, | 243 int dest_width, |
244 int dest_height, | 244 int dest_height, |
245 const FX_RECT* pClipRect, | 245 const FX_RECT* pClipRect, |
246 uint32_t flags, | 246 uint32_t flags, |
247 int blend_type) override; | 247 int blend_type) override; |
248 FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, | 248 bool StartDIBits(const CFX_DIBSource* pBitmap, |
249 int bitmap_alpha, | 249 int bitmap_alpha, |
250 uint32_t color, | 250 uint32_t color, |
251 const CFX_Matrix* pMatrix, | 251 const CFX_Matrix* pMatrix, |
252 uint32_t render_flags, | 252 uint32_t render_flags, |
253 void*& handle, | 253 void*& handle, |
254 int blend_type) override; | 254 int blend_type) override; |
255 FX_BOOL DrawDeviceText(int nChars, | 255 bool DrawDeviceText(int nChars, |
256 const FXTEXT_CHARPOS* pCharPos, | 256 const FXTEXT_CHARPOS* pCharPos, |
257 CFX_Font* pFont, | 257 CFX_Font* pFont, |
258 const CFX_Matrix* pObject2Device, | 258 const CFX_Matrix* pObject2Device, |
259 FX_FLOAT font_size, | 259 FX_FLOAT font_size, |
260 uint32_t color) override; | 260 uint32_t color) override; |
261 | 261 |
262 const int m_HorzSize; | 262 const int m_HorzSize; |
263 const int m_VertSize; | 263 const int m_VertSize; |
264 }; | 264 }; |
265 | 265 |
266 #endif // CORE_FXGE_WIN32_WIN32_INT_H_ | 266 #endif // CORE_FXGE_WIN32_WIN32_INT_H_ |
OLD | NEW |