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