• 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_CPS_PRINTER_DRIVER_H_
8 #define CORE_FXGE_WIN32_CPS_PRINTER_DRIVER_H_
9 
10 #include <windows.h>
11 
12 #include <memory>
13 
14 #include "core/fxge/cfx_windowsrenderdevice.h"
15 #include "core/fxge/renderdevicedriver_iface.h"
16 #include "core/fxge/win32/cfx_psrenderer.h"
17 
18 class CFX_PSFontTracker;
19 
20 class CPSPrinterDriver final : public RenderDeviceDriverIface {
21  public:
22   CPSPrinterDriver(HDC hDC,
23                    WindowsPrintMode mode,
24                    CFX_PSFontTracker* ps_font_tracker,
25                    const EncoderIface* encoder_iface);
26   ~CPSPrinterDriver() override;
27 
28  private:
29   // RenderDeviceDriverIface:
30   DeviceType GetDeviceType() const override;
31   int GetDeviceCaps(int caps_id) const override;
32   void SaveState() override;
33   void RestoreState(bool bKeepSaved) override;
34   bool SetClip_PathFill(const CFX_Path& paath,
35                         const CFX_Matrix* pObject2Device,
36                         const CFX_FillRenderOptions& fill_options) override;
37   bool SetClip_PathStroke(const CFX_Path& path,
38                           const CFX_Matrix* pObject2Device,
39                           const CFX_GraphStateData* pGraphState) override;
40   bool DrawPath(const CFX_Path& path,
41                 const CFX_Matrix* pObject2Device,
42                 const CFX_GraphStateData* pGraphState,
43                 uint32_t fill_color,
44                 uint32_t stroke_color,
45                 const CFX_FillRenderOptions& fill_options) override;
46   FX_RECT GetClipBox() const override;
47   bool SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
48                  uint32_t color,
49                  const FX_RECT& src_rect,
50                  int left,
51                  int top,
52                  BlendMode blend_type) override;
53   bool StretchDIBits(RetainPtr<const CFX_DIBBase> bitmap,
54                      uint32_t color,
55                      int dest_left,
56                      int dest_top,
57                      int dest_width,
58                      int dest_height,
59                      const FX_RECT* pClipRect,
60                      const FXDIB_ResampleOptions& options,
61                      BlendMode blend_type) override;
62   StartResult StartDIBits(RetainPtr<const CFX_DIBBase> bitmap,
63                           float alpha,
64                           uint32_t color,
65                           const CFX_Matrix& matrix,
66                           const FXDIB_ResampleOptions& options,
67                           BlendMode blend_type) override;
68   bool DrawDeviceText(pdfium::span<const TextCharPos> pCharPos,
69                       CFX_Font* pFont,
70                       const CFX_Matrix& mtObject2Device,
71                       float font_size,
72                       uint32_t color,
73                       const CFX_TextRenderOptions& options) override;
74   bool MultiplyAlpha(float alpha) override;
75   bool MultiplyAlphaMask(RetainPtr<const CFX_DIBitmap> mask) override;
76 
77   HDC m_hDC;
78   int m_Width;
79   int m_Height;
80   int m_nBitsPerPixel;
81   int m_HorzSize;
82   int m_VertSize;
83   CFX_PSRenderer m_PSRenderer;
84 };
85 
86 #endif  // CORE_FXGE_WIN32_CPS_PRINTER_DRIVER_H_
87