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 #include "core/fxge/cfx_graphstate.h" 8 9 #include <utility> 10 11 CFX_GraphState::CFX_GraphState() = default; 12 13 CFX_GraphState::CFX_GraphState(const CFX_GraphState& that) = default; 14 15 CFX_GraphState::~CFX_GraphState() = default; 16 Emplace()17void CFX_GraphState::Emplace() { 18 m_Ref.Emplace(); 19 } 20 SetLineDash(std::vector<float> dashes,float phase)21void CFX_GraphState::SetLineDash(std::vector<float> dashes, float phase) { 22 CFX_GraphStateData* pData = m_Ref.GetPrivateCopy(); 23 pData->set_dash_phase(phase); 24 pData->set_dash_array(std::move(dashes)); 25 } 26 SetLineDashPhase(float phase)27void CFX_GraphState::SetLineDashPhase(float phase) { 28 CFX_GraphStateData* pData = m_Ref.GetPrivateCopy(); 29 pData->set_dash_phase(phase); 30 } 31 GetLineDashArray() const32std::vector<float> CFX_GraphState::GetLineDashArray() const { 33 std::vector<float> ret; 34 if (m_Ref.GetObject()) { 35 ret = m_Ref.GetObject()->dash_array(); 36 } 37 return ret; 38 } 39 GetLineDashSize() const40size_t CFX_GraphState::GetLineDashSize() const { 41 return m_Ref.GetObject() ? m_Ref.GetObject()->dash_array().size() : 0; 42 } 43 GetLineDashPhase() const44float CFX_GraphState::GetLineDashPhase() const { 45 return m_Ref.GetObject() ? m_Ref.GetObject()->dash_phase() : 1.0f; 46 } 47 GetLineWidth() const48float CFX_GraphState::GetLineWidth() const { 49 return m_Ref.GetObject() ? m_Ref.GetObject()->line_width() : 1.0f; 50 } 51 SetLineWidth(float width)52void CFX_GraphState::SetLineWidth(float width) { 53 m_Ref.GetPrivateCopy()->set_line_width(width); 54 } 55 GetLineCap() const56CFX_GraphStateData::LineCap CFX_GraphState::GetLineCap() const { 57 return m_Ref.GetObject() ? m_Ref.GetObject()->line_cap() 58 : CFX_GraphStateData::LineCap::kButt; 59 } SetLineCap(CFX_GraphStateData::LineCap cap)60void CFX_GraphState::SetLineCap(CFX_GraphStateData::LineCap cap) { 61 m_Ref.GetPrivateCopy()->set_line_cap(cap); 62 } 63 GetLineJoin() const64CFX_GraphStateData::LineJoin CFX_GraphState::GetLineJoin() const { 65 return m_Ref.GetObject() ? m_Ref.GetObject()->line_join() 66 : CFX_GraphStateData::LineJoin::kMiter; 67 } 68 SetLineJoin(CFX_GraphStateData::LineJoin join)69void CFX_GraphState::SetLineJoin(CFX_GraphStateData::LineJoin join) { 70 m_Ref.GetPrivateCopy()->set_line_join(join); 71 } 72 GetMiterLimit() const73float CFX_GraphState::GetMiterLimit() const { 74 return m_Ref.GetObject() ? m_Ref.GetObject()->miter_limit() : 10.f; 75 } 76 SetMiterLimit(float limit)77void CFX_GraphState::SetMiterLimit(float limit) { 78 m_Ref.GetPrivateCopy()->set_miter_limit(limit); 79 } 80