OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../../../third_party/base/numerics/safe_math.h" | 7 #include "../../../../third_party/base/numerics/safe_math.h" |
8 #include "../../../include/fxcrt/fx_system.h" | 8 #include "../../../include/fxcrt/fx_system.h" |
9 #include "../../../include/fxge/fx_ge.h" | 9 #include "../../../include/fxge/fx_ge.h" |
10 | 10 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 m_Mask = new_mask; | 110 m_Mask = new_mask; |
111 return; | 111 return; |
112 } | 112 } |
113 ASSERT(FALSE); | 113 ASSERT(FALSE); |
114 } | 114 } |
115 CFX_PathData::CFX_PathData() { | 115 CFX_PathData::CFX_PathData() { |
116 m_PointCount = m_AllocCount = 0; | 116 m_PointCount = m_AllocCount = 0; |
117 m_pPoints = NULL; | 117 m_pPoints = NULL; |
118 } | 118 } |
119 CFX_PathData::~CFX_PathData() { | 119 CFX_PathData::~CFX_PathData() { |
120 if (m_pPoints) { | |
121 FX_Free(m_pPoints); | 120 FX_Free(m_pPoints); |
122 } | |
123 } | 121 } |
124 void CFX_PathData::SetPointCount(int nPoints) { | 122 void CFX_PathData::SetPointCount(int nPoints) { |
125 m_PointCount = nPoints; | 123 m_PointCount = nPoints; |
126 if (m_AllocCount < nPoints) { | 124 if (m_AllocCount < nPoints) { |
127 if (m_pPoints) { | |
128 FX_Free(m_pPoints); | 125 FX_Free(m_pPoints); |
129 m_pPoints = NULL; | |
130 } | |
131 m_pPoints = FX_Alloc(FX_PATHPOINT, nPoints); | 126 m_pPoints = FX_Alloc(FX_PATHPOINT, nPoints); |
132 m_AllocCount = nPoints; | 127 m_AllocCount = nPoints; |
133 } | 128 } |
134 } | 129 } |
135 void CFX_PathData::AllocPointCount(int nPoints) { | 130 void CFX_PathData::AllocPointCount(int nPoints) { |
136 if (m_AllocCount < nPoints) { | 131 if (m_AllocCount < nPoints) { |
137 FX_PATHPOINT* pNewBuf = FX_Alloc(FX_PATHPOINT, nPoints); | 132 FX_PATHPOINT* pNewBuf = FX_Alloc(FX_PATHPOINT, nPoints); |
138 if (m_PointCount) { | 133 if (m_PointCount) { |
139 FXSYS_memcpy(pNewBuf, m_pPoints, m_PointCount * sizeof(FX_PATHPOINT)); | 134 FXSYS_memcpy(pNewBuf, m_pPoints, m_PointCount * sizeof(FX_PATHPOINT)); |
140 } | 135 } |
141 if (m_pPoints) { | |
142 FX_Free(m_pPoints); | 136 FX_Free(m_pPoints); |
143 } | |
144 m_pPoints = pNewBuf; | 137 m_pPoints = pNewBuf; |
145 m_AllocCount = nPoints; | 138 m_AllocCount = nPoints; |
146 } | 139 } |
147 } | 140 } |
148 CFX_PathData::CFX_PathData(const CFX_PathData& src) { | 141 CFX_PathData::CFX_PathData(const CFX_PathData& src) { |
149 m_PointCount = m_AllocCount = src.m_PointCount; | 142 m_PointCount = m_AllocCount = src.m_PointCount; |
150 m_pPoints = FX_Alloc(FX_PATHPOINT, src.m_PointCount); | 143 m_pPoints = FX_Alloc(FX_PATHPOINT, src.m_PointCount); |
151 FXSYS_memcpy(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount); | 144 FXSYS_memcpy(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount); |
152 } | 145 } |
153 void CFX_PathData::TrimPoints(int nPoints) { | 146 void CFX_PathData::TrimPoints(int nPoints) { |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 m_MiterLimit = 10 * 1.0f; | 626 m_MiterLimit = 10 * 1.0f; |
634 m_LineWidth = 1.0f; | 627 m_LineWidth = 1.0f; |
635 } | 628 } |
636 CFX_GraphStateData::CFX_GraphStateData(const CFX_GraphStateData& src) { | 629 CFX_GraphStateData::CFX_GraphStateData(const CFX_GraphStateData& src) { |
637 m_DashArray = NULL; | 630 m_DashArray = NULL; |
638 Copy(src); | 631 Copy(src); |
639 } | 632 } |
640 void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) { | 633 void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) { |
641 m_LineCap = src.m_LineCap; | 634 m_LineCap = src.m_LineCap; |
642 m_DashCount = src.m_DashCount; | 635 m_DashCount = src.m_DashCount; |
643 if (m_DashArray) { | |
644 FX_Free(m_DashArray); | 636 FX_Free(m_DashArray); |
645 } | |
646 m_DashArray = NULL; | 637 m_DashArray = NULL; |
647 m_DashPhase = src.m_DashPhase; | 638 m_DashPhase = src.m_DashPhase; |
648 m_LineJoin = src.m_LineJoin; | 639 m_LineJoin = src.m_LineJoin; |
649 m_MiterLimit = src.m_MiterLimit; | 640 m_MiterLimit = src.m_MiterLimit; |
650 m_LineWidth = src.m_LineWidth; | 641 m_LineWidth = src.m_LineWidth; |
651 if (m_DashCount) { | 642 if (m_DashCount) { |
652 m_DashArray = FX_Alloc(FX_FLOAT, m_DashCount); | 643 m_DashArray = FX_Alloc(FX_FLOAT, m_DashCount); |
653 FXSYS_memcpy(m_DashArray, src.m_DashArray, m_DashCount * sizeof(FX_FLOAT)); | 644 FXSYS_memcpy(m_DashArray, src.m_DashArray, m_DashCount * sizeof(FX_FLOAT)); |
654 } | 645 } |
655 } | 646 } |
656 CFX_GraphStateData::~CFX_GraphStateData() { | 647 CFX_GraphStateData::~CFX_GraphStateData() { |
657 if (m_DashArray) { | |
658 FX_Free(m_DashArray); | 648 FX_Free(m_DashArray); |
659 } | |
660 } | 649 } |
661 void CFX_GraphStateData::SetDashCount(int count) { | 650 void CFX_GraphStateData::SetDashCount(int count) { |
662 if (m_DashArray) { | |
663 FX_Free(m_DashArray); | 651 FX_Free(m_DashArray); |
664 } | |
665 m_DashArray = NULL; | 652 m_DashArray = NULL; |
666 m_DashCount = count; | 653 m_DashCount = count; |
667 if (count == 0) { | 654 if (count == 0) { |
668 return; | 655 return; |
669 } | 656 } |
670 m_DashArray = FX_Alloc(FX_FLOAT, count); | 657 m_DashArray = FX_Alloc(FX_FLOAT, count); |
671 } | 658 } |
OLD | NEW |