1 // Copyright 2014 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 "../../../include/fpdfapi/fpdf_page.h"
8 #include "../../../include/fpdfapi/fpdf_pageobj.h"
9 #include "../../../include/fpdfapi/fpdf_module.h"
10 #include "pageint.h"
CopyData(const CPDF_PageObject * pSrc)11 void CPDF_PathObject::CopyData(const CPDF_PageObject* pSrc)
12 {
13     const CPDF_PathObject* pSrcObj = (const CPDF_PathObject*)pSrc;
14     m_Path = pSrcObj->m_Path;
15     m_FillType = pSrcObj->m_FillType;
16     m_bStroke = pSrcObj->m_bStroke;
17     m_Matrix = pSrcObj->m_Matrix;
18 }
Transform(const CPDF_Matrix & matrix)19 void CPDF_PathObject::Transform(const CPDF_Matrix& matrix)
20 {
21     m_Matrix.Concat(matrix);
22     CalcBoundingBox();
23 }
SetGraphState(CPDF_GraphState GraphState)24 void CPDF_PathObject::SetGraphState(CPDF_GraphState GraphState)
25 {
26     m_GraphState = GraphState;
27     CalcBoundingBox();
28 }
CalcBoundingBox()29 void CPDF_PathObject::CalcBoundingBox()
30 {
31     if (m_Path.IsNull()) {
32         return;
33     }
34     CFX_FloatRect rect;
35     FX_FLOAT width = m_GraphState.GetObject()->m_LineWidth;
36     if (m_bStroke && width != 0) {
37         rect = m_Path.GetBoundingBox(width, m_GraphState.GetObject()->m_MiterLimit);
38     } else {
39         rect = m_Path.GetBoundingBox();
40     }
41     rect.Transform(&m_Matrix);
42     if (width == 0 && m_bStroke) {
43         rect.left += -0.5f;
44         rect.right += 0.5f;
45         rect.bottom += -0.5f;
46         rect.top += 0.5f;
47     }
48     m_Left = rect.left;
49     m_Right = rect.right;
50     m_Top = rect.top;
51     m_Bottom = rect.bottom;
52 }
53