blob: f429ac1703ce315c6ec131dde671984c5e34f7d6 [file] [log] [blame]
Dan Sinclair1770c022016-03-14 14:14:16 -04001// 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
Dan Sinclaird9828fd2017-03-30 10:58:49 -04007#ifndef XFA_FDE_CFDE_RENDERDEVICE_H_
8#define XFA_FDE_CFDE_RENDERDEVICE_H_
Dan Sinclair1770c022016-03-14 14:14:16 -04009
tsepez6db6fbc2017-01-20 12:22:16 -080010#include <vector>
11
dsinclair74a34fc2016-09-29 16:41:42 -070012#include "core/fxge/cfx_renderdevice.h"
tsepeze6477992017-01-05 12:57:00 -080013#include "xfa/fgas/font/cfgas_gefont.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040014
dsinclairacd0d592016-04-21 11:06:27 -070015class CFDE_Brush;
16class CFDE_Path;
17class CFDE_Pen;
npm9ada2d82016-08-10 07:51:38 -070018class CFX_GraphStateData;
dsinclairacd0d592016-04-21 11:06:27 -070019
Dan Sinclair0cb9b8c2017-01-10 16:38:10 -050020class CFDE_RenderDevice {
Dan Sinclair1770c022016-03-14 14:14:16 -040021 public:
tsepezd19e9122016-11-02 15:43:18 -070022 CFDE_RenderDevice(CFX_RenderDevice* pDevice, bool bOwnerDevice);
Dan Sinclair0cb9b8c2017-01-10 16:38:10 -050023 ~CFDE_RenderDevice();
Dan Sinclair1770c022016-03-14 14:14:16 -040024
dsinclairacd0d592016-04-21 11:06:27 -070025 int32_t GetWidth() const;
26 int32_t GetHeight() const;
dsinclairfe433f12016-06-06 12:03:31 -070027 void SaveState();
28 void RestoreState();
tsepezd19e9122016-11-02 15:43:18 -070029 bool SetClipPath(const CFDE_Path* pClip);
dsinclairacd0d592016-04-21 11:06:27 -070030 CFDE_Path* GetClipPath() const;
tsepezd19e9122016-11-02 15:43:18 -070031 bool SetClipRect(const CFX_RectF& rtClip);
dsinclairacd0d592016-04-21 11:06:27 -070032 const CFX_RectF& GetClipRect();
Dan Sinclair1770c022016-03-14 14:14:16 -040033
Dan Sinclair05df0752017-03-14 14:43:42 -040034 float GetDpiX() const;
35 float GetDpiY() const;
dsinclairacd0d592016-04-21 11:06:27 -070036
Tom Sepezf0799fe2017-03-28 09:31:32 -070037 bool DrawImage(const CFX_RetainPtr<CFX_DIBSource>& pDib,
tsepezd19e9122016-11-02 15:43:18 -070038 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,
tsepeze6477992017-01-05 12:57:00 -080043 const CFX_RetainPtr<CFGAS_GEFont>& pFont,
tsepezd19e9122016-11-02 15:43:18 -070044 const FXTEXT_CHARPOS* pCharPos,
45 int32_t iCount,
Dan Sinclair05df0752017-03-14 14:43:42 -040046 float fFontSize,
tsepezd19e9122016-11-02 15:43:18 -070047 const CFX_Matrix* pMatrix = nullptr);
48 bool DrawBezier(CFDE_Pen* pPen,
Dan Sinclair05df0752017-03-14 14:43:42 -040049 float fPenWidth,
tsepezd19e9122016-11-02 15:43:18 -070050 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,
Dan Sinclair05df0752017-03-14 14:43:42 -040056 float fPenWidth,
tsepez6db6fbc2017-01-20 12:22:16 -080057 const std::vector<CFX_PointF>& points,
tsepezd19e9122016-11-02 15:43:18 -070058 bool bClosed,
Dan Sinclair05df0752017-03-14 14:43:42 -040059 float fTension = 0.5f,
tsepezd19e9122016-11-02 15:43:18 -070060 const CFX_Matrix* pMatrix = nullptr);
61 bool DrawEllipse(CFDE_Pen* pPen,
Dan Sinclair05df0752017-03-14 14:43:42 -040062 float fPenWidth,
tsepezd19e9122016-11-02 15:43:18 -070063 const CFX_RectF& rect,
64 const CFX_Matrix* pMatrix = nullptr);
65 bool DrawLines(CFDE_Pen* pPen,
Dan Sinclair05df0752017-03-14 14:43:42 -040066 float fPenWidth,
tsepez6db6fbc2017-01-20 12:22:16 -080067 const std::vector<CFX_PointF>& points,
tsepezd19e9122016-11-02 15:43:18 -070068 const CFX_Matrix* pMatrix = nullptr);
69 bool DrawLine(CFDE_Pen* pPen,
Dan Sinclair05df0752017-03-14 14:43:42 -040070 float fPenWidth,
tsepezd19e9122016-11-02 15:43:18 -070071 const CFX_PointF& pt1,
72 const CFX_PointF& pt2,
73 const CFX_Matrix* pMatrix = nullptr);
74 bool DrawPath(CFDE_Pen* pPen,
Dan Sinclair05df0752017-03-14 14:43:42 -040075 float fPenWidth,
tsepezd19e9122016-11-02 15:43:18 -070076 const CFDE_Path* pPath,
77 const CFX_Matrix* pMatrix = nullptr);
78 bool DrawPolygon(CFDE_Pen* pPen,
Dan Sinclair05df0752017-03-14 14:43:42 -040079 float fPenWidth,
tsepez6db6fbc2017-01-20 12:22:16 -080080 const std::vector<CFX_PointF>& points,
tsepezd19e9122016-11-02 15:43:18 -070081 const CFX_Matrix* pMatrix = nullptr);
82 bool DrawRectangle(CFDE_Pen* pPen,
Dan Sinclair05df0752017-03-14 14:43:42 -040083 float fPenWidth,
tsepezd19e9122016-11-02 15:43:18 -070084 const CFX_RectF& rect,
thestigcfb77cc2016-06-10 12:21:53 -070085 const CFX_Matrix* pMatrix = nullptr);
tsepezd19e9122016-11-02 15:43:18 -070086 bool FillClosedCurve(CFDE_Brush* pBrush,
tsepez6db6fbc2017-01-20 12:22:16 -080087 const std::vector<CFX_PointF>& points,
Dan Sinclair05df0752017-03-14 14:43:42 -040088 float fTension = 0.5f,
tsepezd19e9122016-11-02 15:43:18 -070089 const CFX_Matrix* pMatrix = nullptr);
90 bool FillEllipse(CFDE_Brush* pBrush,
91 const CFX_RectF& rect,
thestigcfb77cc2016-06-10 12:21:53 -070092 const CFX_Matrix* pMatrix = nullptr);
tsepezd19e9122016-11-02 15:43:18 -070093 bool FillPath(CFDE_Brush* pBrush,
94 const CFDE_Path* pPath,
95 const CFX_Matrix* pMatrix = nullptr);
96 bool FillPolygon(CFDE_Brush* pBrush,
tsepez6db6fbc2017-01-20 12:22:16 -080097 const std::vector<CFX_PointF>& points,
thestigcfb77cc2016-06-10 12:21:53 -070098 const CFX_Matrix* pMatrix = nullptr);
tsepezd19e9122016-11-02 15:43:18 -070099 bool FillRectangle(CFDE_Brush* pBrush,
100 const CFX_RectF& rect,
101 const CFX_Matrix* pMatrix = nullptr);
dsinclair25c223d2016-04-12 09:51:45 -0700102
tsepezd19e9122016-11-02 15:43:18 -0700103 bool DrawSolidString(CFDE_Brush* pBrush,
tsepeze6477992017-01-05 12:57:00 -0800104 const CFX_RetainPtr<CFGAS_GEFont>& pFont,
tsepezd19e9122016-11-02 15:43:18 -0700105 const FXTEXT_CHARPOS* pCharPos,
106 int32_t iCount,
Dan Sinclair05df0752017-03-14 14:43:42 -0400107 float fFontSize,
tsepezd19e9122016-11-02 15:43:18 -0700108 const CFX_Matrix* pMatrix);
109 bool DrawStringPath(CFDE_Brush* pBrush,
tsepeze6477992017-01-05 12:57:00 -0800110 const CFX_RetainPtr<CFGAS_GEFont>& pFont,
tsepezd19e9122016-11-02 15:43:18 -0700111 const FXTEXT_CHARPOS* pCharPos,
112 int32_t iCount,
Dan Sinclair05df0752017-03-14 14:43:42 -0400113 float fFontSize,
tsepezd19e9122016-11-02 15:43:18 -0700114 const CFX_Matrix* pMatrix);
Dan Sinclair1770c022016-03-14 14:14:16 -0400115
116 protected:
tsepezd19e9122016-11-02 15:43:18 -0700117 bool CreatePen(CFDE_Pen* pPen,
Dan Sinclair05df0752017-03-14 14:43:42 -0400118 float fPenWidth,
tsepezd19e9122016-11-02 15:43:18 -0700119 CFX_GraphStateData& graphState);
dsinclair25c223d2016-04-12 09:51:45 -0700120
weilicddf8252016-08-04 15:43:59 -0700121 CFX_RenderDevice* const m_pDevice;
Dan Sinclair1770c022016-03-14 14:14:16 -0400122 CFX_RectF m_rtClip;
tsepezd19e9122016-11-02 15:43:18 -0700123 bool m_bOwnerDevice;
Dan Sinclair1770c022016-03-14 14:14:16 -0400124 int32_t m_iCharCount;
125};
126
Dan Sinclaird9828fd2017-03-30 10:58:49 -0400127#endif // XFA_FDE_CFDE_RENDERDEVICE_H_