• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The PDFium Authors
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_FXGE_WIN32_CGDI_DEVICE_DRIVER_H_
8 #define CORE_FXGE_WIN32_CGDI_DEVICE_DRIVER_H_
9 
10 #include <windows.h>
11 
12 #include <optional>
13 
14 #include "core/fxcrt/retain_ptr.h"
15 #include "core/fxge/renderdevicedriver_iface.h"
16 
17 class CFX_DIBBase;
18 
19 class CGdiDeviceDriver : public RenderDeviceDriverIface {
20  protected:
21   CGdiDeviceDriver(HDC hDC, DeviceType device_type);
22   ~CGdiDeviceDriver() override;
23 
24   // RenderDeviceDriverIface:
25   DeviceType GetDeviceType() const override;
26   int GetDeviceCaps(int caps_id) const override;
27   void SaveState() override;
28   void RestoreState(bool bKeepSaved) override;
29   void SetBaseClip(const FX_RECT& rect) override;
30   bool SetClip_PathFill(const CFX_Path& path,
31                         const CFX_Matrix* pObject2Device,
32                         const CFX_FillRenderOptions& fill_options) override;
33   bool SetClip_PathStroke(const CFX_Path& path,
34                           const CFX_Matrix* pObject2Device,
35                           const CFX_GraphStateData* pGraphState) override;
36   bool DrawPath(const CFX_Path& path,
37                 const CFX_Matrix* pObject2Device,
38                 const CFX_GraphStateData* pGraphState,
39                 uint32_t fill_color,
40                 uint32_t stroke_color,
41                 const CFX_FillRenderOptions& fill_options) override;
42   bool FillRect(const FX_RECT& rect, uint32_t fill_color) override;
43   bool DrawCosmeticLine(const CFX_PointF& ptMoveTo,
44                         const CFX_PointF& ptLineTo,
45                         uint32_t color) override;
46   FX_RECT GetClipBox() const override;
47   bool MultiplyAlpha(float alpha) override;
48   bool MultiplyAlphaMask(RetainPtr<const CFX_DIBitmap> mask) override;
49 
50   void DrawLine(float x1, float y1, float x2, float y2);
51 
52   bool GDI_SetDIBits(RetainPtr<const CFX_DIBBase> source,
53                      const FX_RECT& src_rect,
54                      int left,
55                      int top);
56   bool GDI_StretchDIBits(RetainPtr<const CFX_DIBBase> source,
57                          int dest_left,
58                          int dest_top,
59                          int dest_width,
60                          int dest_height,
61                          const FXDIB_ResampleOptions& options);
62   bool GDI_StretchBitMask(RetainPtr<const CFX_DIBBase> source,
63                           int dest_left,
64                           int dest_top,
65                           int dest_width,
66                           int dest_height,
67                           uint32_t bitmap_color);
68 
69   const HDC m_hDC;
70   bool m_bMetafileDCType;
71   int m_Width;
72   int m_Height;
73   int m_nBitsPerPixel;
74   const DeviceType m_DeviceType;
75   int m_RenderCaps;
76   std::optional<FX_RECT> m_BaseClipBox;
77 };
78 
79 #endif  // CORE_FXGE_WIN32_CGDI_DEVICE_DRIVER_H_
80