Remove two more unused variables that compilers now complain about.
[pdfium.git] / core / src / fxge / win32 / win32_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 #ifndef CORE_SRC_FXGE_WIN32_WIN32_INT_H_
7 #define CORE_SRC_FXGE_WIN32_WIN32_INT_H_
8
9 #include "../../../include/fxge/fx_ge.h"
10
11 struct WINDIB_Open_Args_;
12 class CGdiplusExt {
13  public:
14   CGdiplusExt();
15   ~CGdiplusExt();
16   void Load();
17   FX_BOOL IsAvailable() { return m_hModule != NULL; }
18   FX_BOOL StretchBitMask(HDC hDC,
19                          BOOL bMonoDevice,
20                          const CFX_DIBitmap* pBitmap,
21                          int dest_left,
22                          int dest_top,
23                          int dest_width,
24                          int dest_height,
25                          FX_DWORD argb,
26                          const FX_RECT* pClipRect,
27                          int flags);
28   FX_BOOL StretchDIBits(HDC hDC,
29                         const CFX_DIBitmap* pBitmap,
30                         int dest_left,
31                         int dest_top,
32                         int dest_width,
33                         int dest_height,
34                         const FX_RECT* pClipRect,
35                         int flags);
36   FX_BOOL DrawPath(HDC hDC,
37                    const CFX_PathData* pPathData,
38                    const CFX_AffineMatrix* pObject2Device,
39                    const CFX_GraphStateData* pGraphState,
40                    FX_DWORD fill_argb,
41                    FX_DWORD stroke_argb,
42                    int fill_mode);
43
44   void* LoadMemFont(uint8_t* pData, FX_DWORD size);
45   void DeleteMemFont(void* pFontCollection);
46   FX_BOOL GdipCreateFromImage(void* bitmap, void** graphics);
47   void GdipDeleteGraphics(void* graphics);
48   void GdipSetTextRenderingHint(void* graphics, int mode);
49   void GdipSetPageUnit(void* graphics, FX_DWORD unit);
50   void GdipSetWorldTransform(void* graphics, void* pMatrix);
51   FX_BOOL GdipDrawDriverString(void* graphics,
52                                unsigned short* text,
53                                int length,
54                                void* font,
55                                void* brush,
56                                void* positions,
57                                int flags,
58                                const void* matrix);
59   void GdipCreateBrush(FX_DWORD fill_argb, void** pBrush);
60   void GdipDeleteBrush(void* pBrush);
61   void GdipCreateMatrix(FX_FLOAT a,
62                         FX_FLOAT b,
63                         FX_FLOAT c,
64                         FX_FLOAT d,
65                         FX_FLOAT e,
66                         FX_FLOAT f,
67                         void** matrix);
68   void GdipDeleteMatrix(void* matrix);
69   FX_BOOL GdipCreateFontFamilyFromName(const FX_WCHAR* name,
70                                        void* pFontCollection,
71                                        void** pFamily);
72   void GdipDeleteFontFamily(void* pFamily);
73   FX_BOOL GdipCreateFontFromFamily(void* pFamily,
74                                    FX_FLOAT font_size,
75                                    int fontstyle,
76                                    int flag,
77                                    void** pFont);
78   void* GdipCreateFontFromCollection(void* pFontCollection,
79                                      FX_FLOAT font_size,
80                                      int fontstyle);
81   void GdipDeleteFont(void* pFont);
82   FX_BOOL GdipCreateBitmap(CFX_DIBitmap* pBitmap, void** bitmap);
83   void GdipDisposeImage(void* bitmap);
84   void GdipGetFontSize(void* pFont, FX_FLOAT* size);
85   void* GdiAddFontMemResourceEx(void* pFontdata,
86                                 FX_DWORD size,
87                                 void* pdv,
88                                 FX_DWORD* num_face);
89   FX_BOOL GdiRemoveFontMemResourceEx(void* handle);
90   void* m_Functions[100];
91   void* m_pGdiAddFontMemResourceEx;
92   void* m_pGdiRemoveFontMemResourseEx;
93   CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args);
94
95  protected:
96   HMODULE m_hModule;
97   HMODULE m_GdiModule;
98 };
99 #include "dwrite_int.h"
100 class CWin32Platform {
101  public:
102   FX_BOOL m_bHalfTone;
103   CGdiplusExt m_GdiplusExt;
104   CDWriteExt m_DWriteExt;
105 };
106
107 class CGdiDeviceDriver : public IFX_RenderDeviceDriver {
108  protected:
109   // IFX_RenderDeviceDriver
110   int GetDeviceCaps(int caps_id) override;
111   void SaveState() override { SaveDC(m_hDC); }
112   void RestoreState(FX_BOOL bKeepSaved = FALSE) override {
113     RestoreDC(m_hDC, -1);
114     if (bKeepSaved) {
115       SaveDC(m_hDC);
116     }
117   }
118   FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
119                            const CFX_AffineMatrix* pObject2Device,
120                            int fill_mode) override;
121   FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData,
122                              const CFX_AffineMatrix* pObject2Device,
123                              const CFX_GraphStateData* pGraphState) override;
124   FX_BOOL DrawPath(const CFX_PathData* pPathData,
125                    const CFX_AffineMatrix* pObject2Device,
126                    const CFX_GraphStateData* pGraphState,
127                    FX_DWORD fill_color,
128                    FX_DWORD stroke_color,
129                    int fill_mode,
130                    int alpha_flag,
131                    void* pIccTransform,
132                    int blend_type) override;
133   FX_BOOL FillRect(const FX_RECT* pRect,
134                    FX_DWORD fill_color,
135                    int alpha_flag,
136                    void* pIccTransform,
137                    int blend_type) override;
138   FX_BOOL DrawCosmeticLine(FX_FLOAT x1,
139                            FX_FLOAT y1,
140                            FX_FLOAT x2,
141                            FX_FLOAT y2,
142                            FX_DWORD color,
143                            int alpha_flag,
144                            void* pIccTransform,
145                            int blend_type) override;
146   FX_BOOL GetClipBox(FX_RECT* pRect) override;
147   void* GetPlatformSurface() override { return (void*)m_hDC; }
148
149   virtual void* GetClipRgn();
150   virtual FX_BOOL SetClipRgn(void* pRgn);
151   virtual FX_BOOL DeleteDeviceRgn(void* pRgn);
152   virtual void DrawLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2);
153
154   FX_BOOL GDI_SetDIBits(const CFX_DIBitmap* pBitmap,
155                         const FX_RECT* pSrcRect,
156                         int left,
157                         int top,
158                         void* pIccTransform);
159   FX_BOOL GDI_StretchDIBits(const CFX_DIBitmap* pBitmap,
160                             int dest_left,
161                             int dest_top,
162                             int dest_width,
163                             int dest_height,
164                             FX_DWORD flags,
165                             void* pIccTransform);
166   FX_BOOL GDI_StretchBitMask(const CFX_DIBitmap* pBitmap,
167                              int dest_left,
168                              int dest_top,
169                              int dest_width,
170                              int dest_height,
171                              FX_DWORD bitmap_color,
172                              FX_DWORD flags,
173                              int alpha_flag,
174                              void* pIccTransform);
175   HDC m_hDC;
176   int m_Width, m_Height, m_nBitsPerPixel;
177   int m_DeviceClass, m_RenderCaps;
178   CGdiDeviceDriver(HDC hDC, int device_class);
179   ~CGdiDeviceDriver() override {}
180 };
181
182 class CGdiDisplayDriver : public CGdiDeviceDriver {
183  public:
184   CGdiDisplayDriver(HDC hDC);
185
186  protected:
187   virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap,
188                             int left,
189                             int top,
190                             void* pIccTransform = NULL,
191                             FX_BOOL bDEdge = FALSE);
192   virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap,
193                             FX_DWORD color,
194                             const FX_RECT* pSrcRect,
195                             int left,
196                             int top,
197                             int blend_type,
198                             int alpha_flag,
199                             void* pIccTransform);
200   virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap,
201                                 FX_DWORD color,
202                                 int dest_left,
203                                 int dest_top,
204                                 int dest_width,
205                                 int dest_height,
206                                 const FX_RECT* pClipRect,
207                                 FX_DWORD flags,
208                                 int alpha_flag,
209                                 void* pIccTransform,
210                                 int blend_type);
211   virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap,
212                               int bitmap_alpha,
213                               FX_DWORD color,
214                               const CFX_AffineMatrix* pMatrix,
215                               FX_DWORD render_flags,
216                               void*& handle,
217                               int alpha_flag,
218                               void* pIccTransform,
219                               int blend_type) {
220     return FALSE;
221   }
222   FX_BOOL UseFoxitStretchEngine(const CFX_DIBSource* pSource,
223                                 FX_DWORD color,
224                                 int dest_left,
225                                 int dest_top,
226                                 int dest_width,
227                                 int dest_height,
228                                 const FX_RECT* pClipRect,
229                                 int render_flags,
230                                 int alpha_flag = 0,
231                                 void* pIccTransform = NULL,
232                                 int blend_type = FXDIB_BLEND_NORMAL);
233 };
234 class CGdiPrinterDriver : public CGdiDeviceDriver {
235  public:
236   CGdiPrinterDriver(HDC hDC);
237
238  protected:
239   virtual int GetDeviceCaps(int caps_id);
240   virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap,
241                             FX_DWORD color,
242                             const FX_RECT* pSrcRect,
243                             int left,
244                             int top,
245                             int blend_type,
246                             int alpha_flag,
247                             void* pIccTransform);
248   virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap,
249                                 FX_DWORD color,
250                                 int dest_left,
251                                 int dest_top,
252                                 int dest_width,
253                                 int dest_height,
254                                 const FX_RECT* pClipRect,
255                                 FX_DWORD flags,
256                                 int alpha_flag,
257                                 void* pIccTransform,
258                                 int blend_type);
259   virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap,
260                               int bitmap_alpha,
261                               FX_DWORD color,
262                               const CFX_AffineMatrix* pMatrix,
263                               FX_DWORD render_flags,
264                               void*& handle,
265                               int alpha_flag,
266                               void* pIccTransform,
267                               int blend_type);
268   int m_HorzSize, m_VertSize;
269   FX_BOOL m_bSupportROP;
270 };
271
272 class CPSOutput : public IFX_PSOutput {
273  public:
274   explicit CPSOutput(HDC hDC);
275   ~CPSOutput() override;
276
277   // IFX_PSOutput
278   void Release() override { delete this; }
279   void OutputPS(const FX_CHAR* string, int len) override;
280
281   void Init();
282
283   HDC m_hDC;
284   FX_CHAR* m_pBuf;
285 };
286
287 class CPSPrinterDriver : public IFX_RenderDeviceDriver {
288  public:
289   CPSPrinterDriver();
290   FX_BOOL Init(HDC hDC, int ps_level, FX_BOOL bCmykOutput);
291   ~CPSPrinterDriver() override;
292
293  protected:
294   // IFX_RenderDeviceDriver
295   int GetDeviceCaps(int caps_id);
296   FX_BOOL IsPSPrintDriver() override { return TRUE; }
297   FX_BOOL StartRendering() override;
298   void EndRendering() override;
299   void SaveState() override;
300   void RestoreState(FX_BOOL bKeepSaved = FALSE) override;
301   FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
302                            const CFX_AffineMatrix* pObject2Device,
303                            int fill_mode) override;
304   FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData,
305                              const CFX_AffineMatrix* pObject2Device,
306                              const CFX_GraphStateData* pGraphState) override;
307   FX_BOOL DrawPath(const CFX_PathData* pPathData,
308                    const CFX_AffineMatrix* pObject2Device,
309                    const CFX_GraphStateData* pGraphState,
310                    FX_DWORD fill_color,
311                    FX_DWORD stroke_color,
312                    int fill_mode,
313                    int alpha_flag,
314                    void* pIccTransform,
315                    int blend_type) override;
316   FX_BOOL GetClipBox(FX_RECT* pRect) override;
317   FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap,
318                     FX_DWORD color,
319                     const FX_RECT* pSrcRect,
320                     int left,
321                     int top,
322                     int blend_type,
323                     int alpha_flag,
324                     void* pIccTransform) override;
325   FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap,
326                         FX_DWORD color,
327                         int dest_left,
328                         int dest_top,
329                         int dest_width,
330                         int dest_height,
331                         const FX_RECT* pClipRect,
332                         FX_DWORD flags,
333                         int alpha_flag,
334                         void* pIccTransform,
335                         int blend_type) override;
336   FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap,
337                       int bitmap_alpha,
338                       FX_DWORD color,
339                       const CFX_AffineMatrix* pMatrix,
340                       FX_DWORD render_flags,
341                       void*& handle,
342                       int alpha_flag,
343                       void* pIccTransform,
344                       int blend_type) override;
345   FX_BOOL DrawDeviceText(int nChars,
346                          const FXTEXT_CHARPOS* pCharPos,
347                          CFX_Font* pFont,
348                          CFX_FontCache* pCache,
349                          const CFX_AffineMatrix* pObject2Device,
350                          FX_FLOAT font_size,
351                          FX_DWORD color,
352                          int alpha_flag,
353                          void* pIccTransform) override;
354   void* GetPlatformSurface() override { return (void*)m_hDC; }
355
356   HDC m_hDC;
357   FX_BOOL m_bCmykOutput;
358   int m_Width, m_Height, m_nBitsPerPixel;
359   int m_HorzSize, m_VertSize;
360   CPSOutput* m_pPSOutput;
361   CFX_PSRenderer m_PSRenderer;
362 };
363 void _Color2Argb(FX_ARGB& argb,
364                  FX_DWORD color,
365                  int alpha_flag,
366                  void* pIccTransform);
367
368 #endif  // CORE_SRC_FXGE_WIN32_WIN32_INT_H_