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 #include "core/fxge/cfx_graphstate.h" 8 9 #include <utility> 10 11 CFX_GraphState::CFX_GraphState() = default; 12 CFX_GraphState(const CFX_GraphState & that)13CFX_GraphState::CFX_GraphState(const CFX_GraphState& that) 14 : m_Ref(that.m_Ref) {} 15 16 CFX_GraphState::~CFX_GraphState() = default; 17 Emplace()18void CFX_GraphState::Emplace() { 19 m_Ref.Emplace(); 20 } 21 SetLineDash(std::vector<float> dashes,float phase,float scale)22void CFX_GraphState::SetLineDash(std::vector<float> dashes, 23 float phase, 24 float scale) { 25 CFX_GraphStateData* pData = m_Ref.GetPrivateCopy(); 26 pData->m_DashPhase = phase * scale; 27 for (float& val : dashes) 28 val *= scale; 29 pData->m_DashArray = std::move(dashes); 30 } 31 GetLineWidth() const32float CFX_GraphState::GetLineWidth() const { 33 return m_Ref.GetObject() ? m_Ref.GetObject()->m_LineWidth : 1.f; 34 } 35 SetLineWidth(float width)36void CFX_GraphState::SetLineWidth(float width) { 37 m_Ref.GetPrivateCopy()->m_LineWidth = width; 38 } 39 GetLineCap() const40CFX_GraphStateData::LineCap CFX_GraphState::GetLineCap() const { 41 return m_Ref.GetObject() ? m_Ref.GetObject()->m_LineCap 42 : CFX_GraphStateData::LineCapButt; 43 } SetLineCap(CFX_GraphStateData::LineCap cap)44void CFX_GraphState::SetLineCap(CFX_GraphStateData::LineCap cap) { 45 m_Ref.GetPrivateCopy()->m_LineCap = cap; 46 } 47 GetLineJoin() const48CFX_GraphStateData::LineJoin CFX_GraphState::GetLineJoin() const { 49 return m_Ref.GetObject() ? m_Ref.GetObject()->m_LineJoin 50 : CFX_GraphStateData::LineJoinMiter; 51 } 52 SetLineJoin(CFX_GraphStateData::LineJoin join)53void CFX_GraphState::SetLineJoin(CFX_GraphStateData::LineJoin join) { 54 m_Ref.GetPrivateCopy()->m_LineJoin = join; 55 } 56 GetMiterLimit() const57float CFX_GraphState::GetMiterLimit() const { 58 return m_Ref.GetObject() ? m_Ref.GetObject()->m_MiterLimit : 10.f; 59 } 60 SetMiterLimit(float limit)61void CFX_GraphState::SetMiterLimit(float limit) { 62 m_Ref.GetPrivateCopy()->m_MiterLimit = limit; 63 } 64