1 // Copyright 2016 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_RENDERDEVICEDRIVER_IFACE_H_ 8 #define CORE_FXGE_RENDERDEVICEDRIVER_IFACE_H_ 9 10 #include <stdint.h> 11 12 #include <memory> 13 14 #include "core/fxcrt/fx_coordinates.h" 15 #include "core/fxcrt/retain_ptr.h" 16 #include "core/fxge/dib/fx_dib.h" 17 #include "third_party/base/containers/span.h" 18 19 class CFX_DIBBase; 20 class CFX_DIBitmap; 21 class CFX_Font; 22 class CFX_GraphStateData; 23 class CFX_ImageRenderer; 24 class CFX_Matrix; 25 class CFX_Path; 26 class CPDF_ShadingPattern; 27 class PauseIndicatorIface; 28 class TextCharPos; 29 struct CFX_FillRenderOptions; 30 struct CFX_TextRenderOptions; 31 struct FX_RECT; 32 33 enum class DeviceType : bool { 34 kDisplay, 35 kPrinter, 36 }; 37 38 class RenderDeviceDriverIface { 39 public: 40 virtual ~RenderDeviceDriverIface(); 41 42 virtual DeviceType GetDeviceType() const = 0; 43 virtual int GetDeviceCaps(int caps_id) const = 0; 44 45 virtual void SaveState() = 0; 46 virtual void RestoreState(bool bKeepSaved) = 0; 47 48 virtual void SetBaseClip(const FX_RECT& rect); 49 virtual bool SetClip_PathFill(const CFX_Path& path, 50 const CFX_Matrix* pObject2Device, 51 const CFX_FillRenderOptions& fill_options) = 0; 52 virtual bool SetClip_PathStroke(const CFX_Path& path, 53 const CFX_Matrix* pObject2Device, 54 const CFX_GraphStateData* pGraphState); 55 virtual bool DrawPath(const CFX_Path& path, 56 const CFX_Matrix* pObject2Device, 57 const CFX_GraphStateData* pGraphState, 58 uint32_t fill_color, 59 uint32_t stroke_color, 60 const CFX_FillRenderOptions& fill_options, 61 BlendMode blend_type) = 0; 62 virtual bool FillRectWithBlend(const FX_RECT& rect, 63 uint32_t fill_color, 64 BlendMode blend_type); 65 virtual bool DrawCosmeticLine(const CFX_PointF& ptMoveTo, 66 const CFX_PointF& ptLineTo, 67 uint32_t color, 68 BlendMode blend_type); 69 70 virtual bool GetClipBox(FX_RECT* pRect) = 0; 71 virtual bool GetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap, 72 int left, 73 int top); 74 virtual RetainPtr<CFX_DIBitmap> GetBackDrop(); 75 virtual bool SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, 76 uint32_t color, 77 const FX_RECT& src_rect, 78 int dest_left, 79 int dest_top, 80 BlendMode blend_type) = 0; 81 virtual bool StretchDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, 82 uint32_t color, 83 int dest_left, 84 int dest_top, 85 int dest_width, 86 int dest_height, 87 const FX_RECT* pClipRect, 88 const FXDIB_ResampleOptions& options, 89 BlendMode blend_type) = 0; 90 virtual bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, 91 int bitmap_alpha, 92 uint32_t color, 93 const CFX_Matrix& matrix, 94 const FXDIB_ResampleOptions& options, 95 std::unique_ptr<CFX_ImageRenderer>* handle, 96 BlendMode blend_type) = 0; 97 virtual bool ContinueDIBits(CFX_ImageRenderer* handle, 98 PauseIndicatorIface* pPause); 99 virtual bool DrawDeviceText(pdfium::span<const TextCharPos> pCharPos, 100 CFX_Font* pFont, 101 const CFX_Matrix& mtObject2Device, 102 float font_size, 103 uint32_t color, 104 const CFX_TextRenderOptions& options); 105 virtual int GetDriverType() const; 106 virtual bool DrawShading(const CPDF_ShadingPattern* pPattern, 107 const CFX_Matrix* pMatrix, 108 const FX_RECT& clip_rect, 109 int alpha, 110 bool bAlphaMode); 111 #if defined(_SKIA_SUPPORT_) 112 virtual bool SetBitsWithMask(const RetainPtr<CFX_DIBBase>& pBitmap, 113 const RetainPtr<CFX_DIBBase>& pMask, 114 int left, 115 int top, 116 int bitmap_alpha, 117 BlendMode blend_type); 118 virtual void SetGroupKnockout(bool group_knockout); 119 #endif 120 121 // Multiplies the device by a constant alpha, returning `true` on success. 122 virtual bool MultiplyAlpha(float alpha) = 0; 123 124 // Multiplies the device by an alpha mask, returning `true` on success. 125 virtual bool MultiplyAlpha(const RetainPtr<CFX_DIBBase>& mask) = 0; 126 }; 127 128 #endif // CORE_FXGE_RENDERDEVICEDRIVER_IFACE_H_ 129