summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_page/cpdf_graphstate.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-08-31 10:26:38 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-31 10:26:38 -0700
commit4d9df422c340b3bc33e044d3d94e1ff9582e1260 (patch)
tree8ad5a366cac2a11a133a7e7babd76497a737e554 /core/fpdfapi/fpdf_page/cpdf_graphstate.cpp
parent21ce1a68bb9f80bfbd4f295fd3b7181e56502fdc (diff)
downloadpdfium-4d9df422c340b3bc33e044d3d94e1ff9582e1260.tar.xz
Make CPDF_GraphState have a CPDF_GraphStateData instead of inheriting.
Get callers out of the copy-before-write business, and let the class manage it instead. Review-Url: https://codereview.chromium.org/2292363002
Diffstat (limited to 'core/fpdfapi/fpdf_page/cpdf_graphstate.cpp')
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_graphstate.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_graphstate.cpp b/core/fpdfapi/fpdf_page/cpdf_graphstate.cpp
new file mode 100644
index 0000000000..5a8dbe841a
--- /dev/null
+++ b/core/fpdfapi/fpdf_page/cpdf_graphstate.cpp
@@ -0,0 +1,61 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fpdfapi/fpdf_page/cpdf_graphstate.h"
+
+#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
+
+CPDF_GraphState::CPDF_GraphState() {}
+
+CPDF_GraphState::CPDF_GraphState(const CPDF_GraphState& that)
+ : m_Ref(that.m_Ref) {}
+
+CPDF_GraphState::~CPDF_GraphState() {}
+
+void CPDF_GraphState::Emplace() {
+ m_Ref.Emplace();
+}
+
+void CPDF_GraphState::SetLineDash(CPDF_Array* pArray,
+ FX_FLOAT phase,
+ FX_FLOAT scale) {
+ CFX_GraphStateData* pData = m_Ref.GetPrivateCopy();
+ pData->m_DashPhase = phase * scale;
+ pData->SetDashCount(static_cast<int>(pArray->GetCount()));
+ for (size_t i = 0; i < pArray->GetCount(); i++)
+ pData->m_DashArray[i] = pArray->GetNumberAt(i) * scale;
+}
+
+FX_FLOAT CPDF_GraphState::GetLineWidth() const {
+ return m_Ref.GetObject()->m_LineWidth;
+}
+
+void CPDF_GraphState::SetLineWidth(FX_FLOAT width) {
+ m_Ref.GetPrivateCopy()->m_LineWidth = width;
+}
+
+CFX_GraphStateData::LineCap CPDF_GraphState::GetLineCap() const {
+ return m_Ref.GetObject()->m_LineCap;
+}
+void CPDF_GraphState::SetLineCap(CFX_GraphStateData::LineCap cap) {
+ m_Ref.GetPrivateCopy()->m_LineCap = cap;
+}
+
+CFX_GraphStateData::LineJoin CPDF_GraphState::GetLineJoin() const {
+ return m_Ref.GetObject()->m_LineJoin;
+}
+
+void CPDF_GraphState::SetLineJoin(CFX_GraphStateData::LineJoin join) {
+ m_Ref.GetPrivateCopy()->m_LineJoin = join;
+}
+
+FX_FLOAT CPDF_GraphState::GetMiterLimit() const {
+ return m_Ref.GetObject()->m_MiterLimit;
+}
+
+void CPDF_GraphState::SetMiterLimit(FX_FLOAT limit) {
+ m_Ref.GetPrivateCopy()->m_MiterLimit = limit;
+}