| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fpdfapi/fpdf_page/include/cpdf_pathobject.h" | 7 #include "core/fpdfapi/fpdf_page/include/cpdf_pathobject.h" |
| 8 | 8 |
| 9 CPDF_PathObject::CPDF_PathObject() {} | 9 CPDF_PathObject::CPDF_PathObject() {} |
| 10 | 10 |
| 11 CPDF_PathObject::~CPDF_PathObject() {} | 11 CPDF_PathObject::~CPDF_PathObject() {} |
| 12 | 12 |
| 13 CPDF_PathObject* CPDF_PathObject::Clone() const { | 13 CPDF_PathObject* CPDF_PathObject::Clone() const { |
| 14 CPDF_PathObject* obj = new CPDF_PathObject; | 14 CPDF_PathObject* obj = new CPDF_PathObject; |
| 15 obj->CopyData(this); | 15 obj->CopyData(this); |
| 16 | 16 |
| 17 obj->m_Path = m_Path; | 17 obj->m_Path = m_Path; |
| 18 obj->m_FillType = m_FillType; | 18 obj->m_FillType = m_FillType; |
| 19 obj->m_bStroke = m_bStroke; | 19 obj->m_bStroke = m_bStroke; |
| 20 obj->m_Matrix = m_Matrix; | 20 obj->m_Matrix = m_Matrix; |
| 21 return obj; | 21 return obj; |
| 22 } | 22 } |
| 23 | 23 |
| 24 CPDF_PageObject::Type CPDF_PathObject::GetType() const { |
| 25 return PATH; |
| 26 } |
| 27 |
| 24 void CPDF_PathObject::Transform(const CFX_Matrix& matrix) { | 28 void CPDF_PathObject::Transform(const CFX_Matrix& matrix) { |
| 25 m_Matrix.Concat(matrix); | 29 m_Matrix.Concat(matrix); |
| 26 CalcBoundingBox(); | 30 CalcBoundingBox(); |
| 27 } | 31 } |
| 28 | 32 |
| 33 bool CPDF_PathObject::IsPath() const { |
| 34 return true; |
| 35 } |
| 36 |
| 37 CPDF_PathObject* CPDF_PathObject::AsPath() { |
| 38 return this; |
| 39 } |
| 40 |
| 41 const CPDF_PathObject* CPDF_PathObject::AsPath() const { |
| 42 return this; |
| 43 } |
| 44 |
| 29 void CPDF_PathObject::CalcBoundingBox() { | 45 void CPDF_PathObject::CalcBoundingBox() { |
| 30 if (m_Path.IsNull()) { | 46 if (m_Path.IsNull()) { |
| 31 return; | 47 return; |
| 32 } | 48 } |
| 33 CFX_FloatRect rect; | 49 CFX_FloatRect rect; |
| 34 FX_FLOAT width = m_GraphState.GetObject()->m_LineWidth; | 50 FX_FLOAT width = m_GraphState.GetObject()->m_LineWidth; |
| 35 if (m_bStroke && width != 0) { | 51 if (m_bStroke && width != 0) { |
| 36 rect = m_Path.GetBoundingBox(width, m_GraphState.GetObject()->m_MiterLimit); | 52 rect = m_Path.GetBoundingBox(width, m_GraphState.GetObject()->m_MiterLimit); |
| 37 } else { | 53 } else { |
| 38 rect = m_Path.GetBoundingBox(); | 54 rect = m_Path.GetBoundingBox(); |
| 39 } | 55 } |
| 40 rect.Transform(&m_Matrix); | 56 rect.Transform(&m_Matrix); |
| 41 if (width == 0 && m_bStroke) { | 57 if (width == 0 && m_bStroke) { |
| 42 rect.left += -0.5f; | 58 rect.left += -0.5f; |
| 43 rect.right += 0.5f; | 59 rect.right += 0.5f; |
| 44 rect.bottom += -0.5f; | 60 rect.bottom += -0.5f; |
| 45 rect.top += 0.5f; | 61 rect.top += 0.5f; |
| 46 } | 62 } |
| 47 m_Left = rect.left; | 63 m_Left = rect.left; |
| 48 m_Right = rect.right; | 64 m_Right = rect.right; |
| 49 m_Top = rect.top; | 65 m_Top = rect.top; |
| 50 m_Bottom = rect.bottom; | 66 m_Bottom = rect.bottom; |
| 51 } | 67 } |
| OLD | NEW |