• 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() {}
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 }
21 
IsPath() const22 bool CPDF_PathObject::IsPath() const {
23   return true;
24 }
25 
AsPath()26 CPDF_PathObject* CPDF_PathObject::AsPath() {
27   return this;
28 }
29 
AsPath() const30 const CPDF_PathObject* CPDF_PathObject::AsPath() const {
31   return this;
32 }
33 
CalcBoundingBox()34 void CPDF_PathObject::CalcBoundingBox() {
35   if (!m_Path)
36     return;
37   CFX_FloatRect rect;
38   FX_FLOAT width = m_GraphState.GetLineWidth();
39   if (m_bStroke && width != 0) {
40     rect = m_Path.GetBoundingBox(width, m_GraphState.GetMiterLimit());
41   } else {
42     rect = m_Path.GetBoundingBox();
43   }
44   m_Matrix.TransformRect(rect);
45 
46   if (width == 0 && m_bStroke) {
47     rect.left += -0.5f;
48     rect.right += 0.5f;
49     rect.bottom += -0.5f;
50     rect.top += 0.5f;
51   }
52   m_Left = rect.left;
53   m_Right = rect.right;
54   m_Top = rect.top;
55   m_Bottom = rect.bottom;
56 }
57