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