1 // Copyright 2016 PDFium Authors. All rights reserved. 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 <memory> 11 12 #include "core/fxcrt/fx_coordinates.h" 13 #include "core/fxcrt/fx_system.h" 14 #include "core/fxcrt/retain_ptr.h" 15 #include "core/fxge/fx_dib.h" 16 17 class CFX_DIBBase; 18 class CFX_DIBitmap; 19 class CFX_Font; 20 class CFX_GraphStateData; 21 class CFX_ImageRenderer; 22 class CFX_Matrix; 23 class CFX_PathData; 24 class CPDF_ShadingPattern; 25 class PauseIndicatorIface; 26 class TextCharPos; 27 struct FX_RECT; 28 29 enum class DeviceType : uint8_t { 30 kUnknown, 31 kDisplay, 32 kPrinter, 33 }; 34 35 class RenderDeviceDriverIface { 36 public: 37 virtual ~RenderDeviceDriverIface(); 38 39 virtual DeviceType GetDeviceType() const = 0; 40 virtual int GetDeviceCaps(int caps_id) const = 0; 41 42 virtual bool StartRendering(); 43 virtual void EndRendering(); 44 virtual void SaveState() = 0; 45 virtual void RestoreState(bool bKeepSaved) = 0; 46 47 virtual void SetBaseClip(const FX_RECT& rect); 48 virtual bool SetClip_PathFill(const CFX_PathData* pPathData, 49 const CFX_Matrix* pObject2Device, 50 int fill_mode) = 0; 51 virtual bool SetClip_PathStroke(const CFX_PathData* pPathData, 52 const CFX_Matrix* pObject2Device, 53 const CFX_GraphStateData* pGraphState); 54 virtual bool DrawPath(const CFX_PathData* pPathData, 55 const CFX_Matrix* pObject2Device, 56 const CFX_GraphStateData* pGraphState, 57 uint32_t fill_color, 58 uint32_t stroke_color, 59 int fill_mode, 60 BlendMode blend_type) = 0; 61 virtual bool SetPixel(int x, int y, uint32_t color); 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(int nChars, 100 const TextCharPos* pCharPos, 101 CFX_Font* pFont, 102 const CFX_Matrix& mtObject2Device, 103 float font_size, 104 uint32_t color); 105 virtual int GetDriverType() const; 106 virtual void ClearDriver(); 107 virtual bool DrawShading(const CPDF_ShadingPattern* pPattern, 108 const CFX_Matrix* pMatrix, 109 const FX_RECT& clip_rect, 110 int alpha, 111 bool bAlphaMode); 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 #if defined _SKIA_SUPPORT_ || defined _SKIA_SUPPORT_PATHS_ 119 virtual void Flush(); 120 #endif 121 }; 122 123 #endif // CORE_FXGE_RENDERDEVICEDRIVER_IFACE_H_ 124