• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/page/cpdf_pathobject.h"
8 
CPDF_PathObject()9 CPDF_PathObject::CPDF_PathObject() : m_FillType(0), m_bStroke(false) {}
10 
~CPDF_PathObject()11 CPDF_PathObject::~CPDF_PathObject() {}
12 
GetType() const13 CPDF_PageObject::Type CPDF_PathObject::GetType() const {
14   return PATH;
15 }
16 
Transform(const CFX_Matrix & matrix)17 void CPDF_PathObject::Transform(const CFX_Matrix& matrix) {
18   m_Matrix.Concat(matrix);
19   CalcBoundingBox();
20   SetDirty(true);
21 }
22 
IsPath() const23 bool CPDF_PathObject::IsPath() const {
24   return true;
25 }
26 
AsPath()27 CPDF_PathObject* CPDF_PathObject::AsPath() {
28   return this;
29 }
30 
AsPath() const31 const CPDF_PathObject* CPDF_PathObject::AsPath() const {
32   return this;
33 }
34 
CalcBoundingBox()35 void CPDF_PathObject::CalcBoundingBox() {
36   if (!m_Path.HasRef())
37     return;
38   CFX_FloatRect rect;
39   float width = m_GraphState.GetLineWidth();
40   if (m_bStroke && width != 0) {
41     rect = m_Path.GetBoundingBox(width, m_GraphState.GetMiterLimit());
42   } else {
43     rect = m_Path.GetBoundingBox();
44   }
45   rect = m_Matrix.TransformRect(rect);
46 
47   if (width == 0 && m_bStroke) {
48     rect.left += -0.5f;
49     rect.right += 0.5f;
50     rect.bottom += -0.5f;
51     rect.top += 0.5f;
52   }
53   m_Left = rect.left;
54   m_Right = rect.right;
55   m_Top = rect.top;
56   m_Bottom = rect.bottom;
57 }
58