1*3ac0a46fSAndroid Build Coastguard Worker // Copyright 2016 The PDFium Authors 2*3ac0a46fSAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*3ac0a46fSAndroid Build Coastguard Worker // found in the LICENSE file. 4*3ac0a46fSAndroid Build Coastguard Worker 5*3ac0a46fSAndroid Build Coastguard Worker // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6*3ac0a46fSAndroid Build Coastguard Worker 7*3ac0a46fSAndroid Build Coastguard Worker #ifndef XFA_FGAS_GRAPHICS_CFGAS_GEGRAPHICS_H_ 8*3ac0a46fSAndroid Build Coastguard Worker #define XFA_FGAS_GRAPHICS_CFGAS_GEGRAPHICS_H_ 9*3ac0a46fSAndroid Build Coastguard Worker 10*3ac0a46fSAndroid Build Coastguard Worker #include <memory> 11*3ac0a46fSAndroid Build Coastguard Worker #include <vector> 12*3ac0a46fSAndroid Build Coastguard Worker 13*3ac0a46fSAndroid Build Coastguard Worker #include "core/fxcrt/fx_coordinates.h" 14*3ac0a46fSAndroid Build Coastguard Worker #include "core/fxcrt/fx_memory.h" 15*3ac0a46fSAndroid Build Coastguard Worker #include "core/fxcrt/retain_ptr.h" 16*3ac0a46fSAndroid Build Coastguard Worker #include "core/fxcrt/unowned_ptr.h" 17*3ac0a46fSAndroid Build Coastguard Worker #include "core/fxge/cfx_fillrenderoptions.h" 18*3ac0a46fSAndroid Build Coastguard Worker #include "core/fxge/cfx_graphstatedata.h" 19*3ac0a46fSAndroid Build Coastguard Worker #include "third_party/base/containers/span.h" 20*3ac0a46fSAndroid Build Coastguard Worker #include "xfa/fgas/graphics/cfgas_gecolor.h" 21*3ac0a46fSAndroid Build Coastguard Worker 22*3ac0a46fSAndroid Build Coastguard Worker class CFGAS_GEPath; 23*3ac0a46fSAndroid Build Coastguard Worker class CFX_DIBBase; 24*3ac0a46fSAndroid Build Coastguard Worker class CFX_RenderDevice; 25*3ac0a46fSAndroid Build Coastguard Worker 26*3ac0a46fSAndroid Build Coastguard Worker class CFGAS_GEGraphics { 27*3ac0a46fSAndroid Build Coastguard Worker public: 28*3ac0a46fSAndroid Build Coastguard Worker class StateRestorer { 29*3ac0a46fSAndroid Build Coastguard Worker public: 30*3ac0a46fSAndroid Build Coastguard Worker FX_STACK_ALLOCATED(); 31*3ac0a46fSAndroid Build Coastguard Worker 32*3ac0a46fSAndroid Build Coastguard Worker explicit StateRestorer(CFGAS_GEGraphics* graphics); 33*3ac0a46fSAndroid Build Coastguard Worker ~StateRestorer(); 34*3ac0a46fSAndroid Build Coastguard Worker 35*3ac0a46fSAndroid Build Coastguard Worker private: 36*3ac0a46fSAndroid Build Coastguard Worker UnownedPtr<CFGAS_GEGraphics> const graphics_; 37*3ac0a46fSAndroid Build Coastguard Worker }; 38*3ac0a46fSAndroid Build Coastguard Worker 39*3ac0a46fSAndroid Build Coastguard Worker explicit CFGAS_GEGraphics(CFX_RenderDevice* renderDevice); 40*3ac0a46fSAndroid Build Coastguard Worker ~CFGAS_GEGraphics(); 41*3ac0a46fSAndroid Build Coastguard Worker 42*3ac0a46fSAndroid Build Coastguard Worker CFX_RectF GetClipRect() const; 43*3ac0a46fSAndroid Build Coastguard Worker const CFX_Matrix* GetMatrix() const; 44*3ac0a46fSAndroid Build Coastguard Worker CFX_RenderDevice* GetRenderDevice(); 45*3ac0a46fSAndroid Build Coastguard Worker 46*3ac0a46fSAndroid Build Coastguard Worker void SetLineCap(CFX_GraphStateData::LineCap lineCap); 47*3ac0a46fSAndroid Build Coastguard Worker void SetLineDash(float dashPhase, pdfium::span<const float> dashArray); 48*3ac0a46fSAndroid Build Coastguard Worker void SetSolidLineDash(); 49*3ac0a46fSAndroid Build Coastguard Worker void SetLineWidth(float lineWidth); 50*3ac0a46fSAndroid Build Coastguard Worker void EnableActOnDash(); 51*3ac0a46fSAndroid Build Coastguard Worker void SetStrokeColor(const CFGAS_GEColor& color); 52*3ac0a46fSAndroid Build Coastguard Worker void SetFillColor(const CFGAS_GEColor& color); 53*3ac0a46fSAndroid Build Coastguard Worker void SetClipRect(const CFX_RectF& rect); 54*3ac0a46fSAndroid Build Coastguard Worker void StrokePath(const CFGAS_GEPath& path, const CFX_Matrix& matrix); 55*3ac0a46fSAndroid Build Coastguard Worker void FillPath(const CFGAS_GEPath& path, 56*3ac0a46fSAndroid Build Coastguard Worker CFX_FillRenderOptions::FillType fill_type, 57*3ac0a46fSAndroid Build Coastguard Worker const CFX_Matrix& matrix); 58*3ac0a46fSAndroid Build Coastguard Worker void ConcatMatrix(const CFX_Matrix& matrix); 59*3ac0a46fSAndroid Build Coastguard Worker 60*3ac0a46fSAndroid Build Coastguard Worker private: 61*3ac0a46fSAndroid Build Coastguard Worker struct TInfo { 62*3ac0a46fSAndroid Build Coastguard Worker TInfo(); 63*3ac0a46fSAndroid Build Coastguard Worker explicit TInfo(const TInfo& info); 64*3ac0a46fSAndroid Build Coastguard Worker TInfo& operator=(const TInfo& other); 65*3ac0a46fSAndroid Build Coastguard Worker 66*3ac0a46fSAndroid Build Coastguard Worker CFX_GraphStateData graphState; 67*3ac0a46fSAndroid Build Coastguard Worker CFX_Matrix CTM; 68*3ac0a46fSAndroid Build Coastguard Worker bool isActOnDash = false; 69*3ac0a46fSAndroid Build Coastguard Worker CFGAS_GEColor strokeColor{nullptr}; 70*3ac0a46fSAndroid Build Coastguard Worker CFGAS_GEColor fillColor{nullptr}; 71*3ac0a46fSAndroid Build Coastguard Worker }; 72*3ac0a46fSAndroid Build Coastguard Worker 73*3ac0a46fSAndroid Build Coastguard Worker void SaveGraphState(); 74*3ac0a46fSAndroid Build Coastguard Worker void RestoreGraphState(); 75*3ac0a46fSAndroid Build Coastguard Worker 76*3ac0a46fSAndroid Build Coastguard Worker void RenderDeviceStrokePath(const CFGAS_GEPath& path, 77*3ac0a46fSAndroid Build Coastguard Worker const CFX_Matrix& matrix); 78*3ac0a46fSAndroid Build Coastguard Worker void RenderDeviceFillPath(const CFGAS_GEPath& path, 79*3ac0a46fSAndroid Build Coastguard Worker CFX_FillRenderOptions::FillType fill_type, 80*3ac0a46fSAndroid Build Coastguard Worker const CFX_Matrix& matrix); 81*3ac0a46fSAndroid Build Coastguard Worker void FillPathWithPattern(const CFGAS_GEPath& path, 82*3ac0a46fSAndroid Build Coastguard Worker const CFX_FillRenderOptions& fill_options, 83*3ac0a46fSAndroid Build Coastguard Worker const CFX_Matrix& matrix); 84*3ac0a46fSAndroid Build Coastguard Worker void FillPathWithShading(const CFGAS_GEPath& path, 85*3ac0a46fSAndroid Build Coastguard Worker const CFX_FillRenderOptions& fill_options, 86*3ac0a46fSAndroid Build Coastguard Worker const CFX_Matrix& matrix); 87*3ac0a46fSAndroid Build Coastguard Worker void SetDIBitsWithMatrix(RetainPtr<CFX_DIBBase> source, 88*3ac0a46fSAndroid Build Coastguard Worker const CFX_Matrix& matrix); 89*3ac0a46fSAndroid Build Coastguard Worker 90*3ac0a46fSAndroid Build Coastguard Worker UnownedPtr<CFX_RenderDevice> const m_renderDevice; 91*3ac0a46fSAndroid Build Coastguard Worker TInfo m_info; 92*3ac0a46fSAndroid Build Coastguard Worker std::vector<std::unique_ptr<TInfo>> m_infoStack; 93*3ac0a46fSAndroid Build Coastguard Worker }; 94*3ac0a46fSAndroid Build Coastguard Worker 95*3ac0a46fSAndroid Build Coastguard Worker #endif // XFA_FGAS_GRAPHICS_CFGAS_GEGRAPHICS_H_ 96