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(int32_t content_stream)9CPDF_PathObject::CPDF_PathObject(int32_t content_stream) 10 : CPDF_PageObject(content_stream) {} 11 CPDF_PathObject()12CPDF_PathObject::CPDF_PathObject() : CPDF_PathObject(kNoContentStream) {} 13 14 CPDF_PathObject::~CPDF_PathObject() = default; 15 GetType() const16CPDF_PageObject::Type CPDF_PathObject::GetType() const { 17 return PATH; 18 } 19 Transform(const CFX_Matrix & matrix)20void CPDF_PathObject::Transform(const CFX_Matrix& matrix) { 21 m_Matrix.Concat(matrix); 22 CalcBoundingBox(); 23 SetDirty(true); 24 } 25 IsPath() const26bool CPDF_PathObject::IsPath() const { 27 return true; 28 } 29 AsPath()30CPDF_PathObject* CPDF_PathObject::AsPath() { 31 return this; 32 } 33 AsPath() const34const CPDF_PathObject* CPDF_PathObject::AsPath() const { 35 return this; 36 } 37 CalcBoundingBox()38void CPDF_PathObject::CalcBoundingBox() { 39 if (!m_Path.HasRef()) 40 return; 41 CFX_FloatRect rect; 42 float width = m_GraphState.GetLineWidth(); 43 if (m_bStroke && width != 0) { 44 rect = m_Path.GetBoundingBox(width, m_GraphState.GetMiterLimit()); 45 } else { 46 rect = m_Path.GetBoundingBox(); 47 } 48 rect = m_Matrix.TransformRect(rect); 49 50 if (width == 0 && m_bStroke) 51 rect.Inflate(0.5f, 0.5f); 52 SetRect(rect); 53 } 54