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