• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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()17 void CFX_GraphState::Emplace() {
18   m_Ref.Emplace();
19 }
20 
SetLineDash(std::vector<float> dashes,float phase)21 void 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)27 void CFX_GraphState::SetLineDashPhase(float phase) {
28   CFX_GraphStateData* pData = m_Ref.GetPrivateCopy();
29   pData->set_dash_phase(phase);
30 }
31 
GetLineDashArray() const32 std::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() const40 size_t CFX_GraphState::GetLineDashSize() const {
41   return m_Ref.GetObject() ? m_Ref.GetObject()->dash_array().size() : 0;
42 }
43 
GetLineDashPhase() const44 float CFX_GraphState::GetLineDashPhase() const {
45   return m_Ref.GetObject() ? m_Ref.GetObject()->dash_phase() : 1.0f;
46 }
47 
GetLineWidth() const48 float CFX_GraphState::GetLineWidth() const {
49   return m_Ref.GetObject() ? m_Ref.GetObject()->line_width() : 1.0f;
50 }
51 
SetLineWidth(float width)52 void CFX_GraphState::SetLineWidth(float width) {
53   m_Ref.GetPrivateCopy()->set_line_width(width);
54 }
55 
GetLineCap() const56 CFX_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)60 void CFX_GraphState::SetLineCap(CFX_GraphStateData::LineCap cap) {
61   m_Ref.GetPrivateCopy()->set_line_cap(cap);
62 }
63 
GetLineJoin() const64 CFX_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)69 void CFX_GraphState::SetLineJoin(CFX_GraphStateData::LineJoin join) {
70   m_Ref.GetPrivateCopy()->set_line_join(join);
71 }
72 
GetMiterLimit() const73 float CFX_GraphState::GetMiterLimit() const {
74   return m_Ref.GetObject() ? m_Ref.GetObject()->miter_limit() : 10.f;
75 }
76 
SetMiterLimit(float limit)77 void CFX_GraphState::SetMiterLimit(float limit) {
78   m_Ref.GetPrivateCopy()->set_miter_limit(limit);
79 }
80