OLD | NEW |
| (Empty) |
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/fpdfapi/fpdf_page/cpdf_pathobject.h" | |
8 | |
9 CPDF_PathObject::CPDF_PathObject() {} | |
10 | |
11 CPDF_PathObject::~CPDF_PathObject() {} | |
12 | |
13 CPDF_PathObject* CPDF_PathObject::Clone() const { | |
14 CPDF_PathObject* obj = new CPDF_PathObject; | |
15 obj->CopyData(this); | |
16 | |
17 obj->m_Path = m_Path; | |
18 obj->m_FillType = m_FillType; | |
19 obj->m_bStroke = m_bStroke; | |
20 obj->m_Matrix = m_Matrix; | |
21 return obj; | |
22 } | |
23 | |
24 CPDF_PageObject::Type CPDF_PathObject::GetType() const { | |
25 return PATH; | |
26 } | |
27 | |
28 void CPDF_PathObject::Transform(const CFX_Matrix& matrix) { | |
29 m_Matrix.Concat(matrix); | |
30 CalcBoundingBox(); | |
31 } | |
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 | |
45 void CPDF_PathObject::CalcBoundingBox() { | |
46 if (!m_Path) | |
47 return; | |
48 CFX_FloatRect rect; | |
49 FX_FLOAT width = m_GraphState.GetLineWidth(); | |
50 if (m_bStroke && width != 0) { | |
51 rect = m_Path.GetBoundingBox(width, m_GraphState.GetMiterLimit()); | |
52 } else { | |
53 rect = m_Path.GetBoundingBox(); | |
54 } | |
55 rect.Transform(&m_Matrix); | |
56 if (width == 0 && m_bStroke) { | |
57 rect.left += -0.5f; | |
58 rect.right += 0.5f; | |
59 rect.bottom += -0.5f; | |
60 rect.top += 0.5f; | |
61 } | |
62 m_Left = rect.left; | |
63 m_Right = rect.right; | |
64 m_Top = rect.top; | |
65 m_Bottom = rect.bottom; | |
66 } | |
OLD | NEW |