• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_graphstatedata.h"
8 
9 #include "core/fxcrt/fx_memory.h"
10 #include "core/fxcrt/fx_system.h"
11 
CFX_GraphStateData()12 CFX_GraphStateData::CFX_GraphStateData()
13     : m_LineCap(LineCapButt),
14       m_DashCount(0),
15       m_DashArray(nullptr),
16       m_DashPhase(0),
17       m_LineJoin(LineJoinMiter),
18       m_MiterLimit(10 * 1.0f),
19       m_LineWidth(1.0f) {}
20 
CFX_GraphStateData(const CFX_GraphStateData & src)21 CFX_GraphStateData::CFX_GraphStateData(const CFX_GraphStateData& src) {
22   m_DashArray = nullptr;
23   Copy(src);
24 }
25 
Copy(const CFX_GraphStateData & src)26 void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) {
27   m_LineCap = src.m_LineCap;
28   m_DashCount = src.m_DashCount;
29   FX_Free(m_DashArray);
30   m_DashArray = nullptr;
31   m_DashPhase = src.m_DashPhase;
32   m_LineJoin = src.m_LineJoin;
33   m_MiterLimit = src.m_MiterLimit;
34   m_LineWidth = src.m_LineWidth;
35   if (m_DashCount) {
36     m_DashArray = FX_Alloc(float, m_DashCount);
37     memcpy(m_DashArray, src.m_DashArray, m_DashCount * sizeof(float));
38   }
39 }
40 
~CFX_GraphStateData()41 CFX_GraphStateData::~CFX_GraphStateData() {
42   FX_Free(m_DashArray);
43 }
44 
SetDashCount(int count)45 void CFX_GraphStateData::SetDashCount(int count) {
46   FX_Free(m_DashArray);
47   m_DashArray = nullptr;
48   m_DashCount = count;
49   if (count == 0)
50     return;
51   m_DashArray = FX_Alloc(float, count);
52 }
53