xref: /aosp_15_r20/external/pdfium/core/fxge/win32/cps_printer_driver.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
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,
46                 BlendMode blend_type) override;
47   bool GetClipBox(FX_RECT* pRect) override;
48   bool SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
49                  uint32_t color,
50                  const FX_RECT& src_rect,
51                  int left,
52                  int top,
53                  BlendMode blend_type) override;
54   bool StretchDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
55                      uint32_t color,
56                      int dest_left,
57                      int dest_top,
58                      int dest_width,
59                      int dest_height,
60                      const FX_RECT* pClipRect,
61                      const FXDIB_ResampleOptions& options,
62                      BlendMode blend_type) override;
63   bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
64                    int bitmap_alpha,
65                    uint32_t color,
66                    const CFX_Matrix& matrix,
67                    const FXDIB_ResampleOptions& options,
68                    std::unique_ptr<CFX_ImageRenderer>* handle,
69                    BlendMode blend_type) override;
70   bool DrawDeviceText(pdfium::span<const TextCharPos> pCharPos,
71                       CFX_Font* pFont,
72                       const CFX_Matrix& mtObject2Device,
73                       float font_size,
74                       uint32_t color,
75                       const CFX_TextRenderOptions& options) override;
76   bool MultiplyAlpha(float alpha) override;
77   bool MultiplyAlpha(const RetainPtr<CFX_DIBBase>& mask) override;
78 
79   HDC m_hDC;
80   int m_Width;
81   int m_Height;
82   int m_nBitsPerPixel;
83   int m_HorzSize;
84   int m_VertSize;
85   CFX_PSRenderer m_PSRenderer;
86 };
87 
88 #endif  // CORE_FXGE_WIN32_CPS_PRINTER_DRIVER_H_
89