1 // Copyright 2014 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 XFA_FDE_FDE_GEDEVICE_H_ 8 #define XFA_FDE_FDE_GEDEVICE_H_ 9 10 #include <vector> 11 12 #include "core/fxge/cfx_renderdevice.h" 13 #include "xfa/fgas/font/cfgas_gefont.h" 14 15 class CFDE_Brush; 16 class CFDE_Path; 17 class CFDE_Pen; 18 class CFX_GraphStateData; 19 20 class CFDE_RenderDevice { 21 public: 22 CFDE_RenderDevice(CFX_RenderDevice* pDevice, bool bOwnerDevice); 23 ~CFDE_RenderDevice(); 24 25 int32_t GetWidth() const; 26 int32_t GetHeight() const; 27 void SaveState(); 28 void RestoreState(); 29 bool SetClipPath(const CFDE_Path* pClip); 30 CFDE_Path* GetClipPath() const; 31 bool SetClipRect(const CFX_RectF& rtClip); 32 const CFX_RectF& GetClipRect(); 33 34 FX_FLOAT GetDpiX() const; 35 FX_FLOAT GetDpiY() const; 36 37 bool DrawImage(CFX_DIBSource* pDib, 38 const CFX_RectF* pSrcRect, 39 const CFX_RectF& dstRect, 40 const CFX_Matrix* pImgMatrix = nullptr, 41 const CFX_Matrix* pDevMatrix = nullptr); 42 bool DrawString(CFDE_Brush* pBrush, 43 const CFX_RetainPtr<CFGAS_GEFont>& pFont, 44 const FXTEXT_CHARPOS* pCharPos, 45 int32_t iCount, 46 FX_FLOAT fFontSize, 47 const CFX_Matrix* pMatrix = nullptr); 48 bool DrawBezier(CFDE_Pen* pPen, 49 FX_FLOAT fPenWidth, 50 const CFX_PointF& pt1, 51 const CFX_PointF& pt2, 52 const CFX_PointF& pt3, 53 const CFX_PointF& pt4, 54 const CFX_Matrix* pMatrix = nullptr); 55 bool DrawCurve(CFDE_Pen* pPen, 56 FX_FLOAT fPenWidth, 57 const std::vector<CFX_PointF>& points, 58 bool bClosed, 59 FX_FLOAT fTension = 0.5f, 60 const CFX_Matrix* pMatrix = nullptr); 61 bool DrawEllipse(CFDE_Pen* pPen, 62 FX_FLOAT fPenWidth, 63 const CFX_RectF& rect, 64 const CFX_Matrix* pMatrix = nullptr); 65 bool DrawLines(CFDE_Pen* pPen, 66 FX_FLOAT fPenWidth, 67 const std::vector<CFX_PointF>& points, 68 const CFX_Matrix* pMatrix = nullptr); 69 bool DrawLine(CFDE_Pen* pPen, 70 FX_FLOAT fPenWidth, 71 const CFX_PointF& pt1, 72 const CFX_PointF& pt2, 73 const CFX_Matrix* pMatrix = nullptr); 74 bool DrawPath(CFDE_Pen* pPen, 75 FX_FLOAT fPenWidth, 76 const CFDE_Path* pPath, 77 const CFX_Matrix* pMatrix = nullptr); 78 bool DrawPolygon(CFDE_Pen* pPen, 79 FX_FLOAT fPenWidth, 80 const std::vector<CFX_PointF>& points, 81 const CFX_Matrix* pMatrix = nullptr); 82 bool DrawRectangle(CFDE_Pen* pPen, 83 FX_FLOAT fPenWidth, 84 const CFX_RectF& rect, 85 const CFX_Matrix* pMatrix = nullptr); 86 bool FillClosedCurve(CFDE_Brush* pBrush, 87 const std::vector<CFX_PointF>& points, 88 FX_FLOAT fTension = 0.5f, 89 const CFX_Matrix* pMatrix = nullptr); 90 bool FillEllipse(CFDE_Brush* pBrush, 91 const CFX_RectF& rect, 92 const CFX_Matrix* pMatrix = nullptr); 93 bool FillPath(CFDE_Brush* pBrush, 94 const CFDE_Path* pPath, 95 const CFX_Matrix* pMatrix = nullptr); 96 bool FillPolygon(CFDE_Brush* pBrush, 97 const std::vector<CFX_PointF>& points, 98 const CFX_Matrix* pMatrix = nullptr); 99 bool FillRectangle(CFDE_Brush* pBrush, 100 const CFX_RectF& rect, 101 const CFX_Matrix* pMatrix = nullptr); 102 103 bool DrawSolidString(CFDE_Brush* pBrush, 104 const CFX_RetainPtr<CFGAS_GEFont>& pFont, 105 const FXTEXT_CHARPOS* pCharPos, 106 int32_t iCount, 107 FX_FLOAT fFontSize, 108 const CFX_Matrix* pMatrix); 109 bool DrawStringPath(CFDE_Brush* pBrush, 110 const CFX_RetainPtr<CFGAS_GEFont>& pFont, 111 const FXTEXT_CHARPOS* pCharPos, 112 int32_t iCount, 113 FX_FLOAT fFontSize, 114 const CFX_Matrix* pMatrix); 115 116 protected: 117 bool CreatePen(CFDE_Pen* pPen, 118 FX_FLOAT fPenWidth, 119 CFX_GraphStateData& graphState); 120 121 CFX_RenderDevice* const m_pDevice; 122 CFX_RectF m_rtClip; 123 bool m_bOwnerDevice; 124 int32_t m_iCharCount; 125 }; 126 127 #endif // XFA_FDE_FDE_GEDEVICE_H_ 128