OLD | NEW |
(Empty) | |
| 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/fpdf_page/include/cpdf_shadingobject.h" |
| 8 |
| 9 #include "core/fpdfapi/fpdf_page/pageint.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 11 |
| 12 CPDF_ShadingObject::CPDF_ShadingObject() : m_pShading(nullptr) {} |
| 13 |
| 14 CPDF_ShadingObject::~CPDF_ShadingObject() {} |
| 15 |
| 16 CPDF_ShadingObject* CPDF_ShadingObject::Clone() const { |
| 17 CPDF_ShadingObject* obj = new CPDF_ShadingObject; |
| 18 obj->CopyData(this); |
| 19 |
| 20 obj->m_pShading = m_pShading; |
| 21 if (obj->m_pShading && obj->m_pShading->m_pDocument) { |
| 22 CPDF_DocPageData* pDocPageData = |
| 23 obj->m_pShading->m_pDocument->GetPageData(); |
| 24 obj->m_pShading = (CPDF_ShadingPattern*)pDocPageData->GetPattern( |
| 25 obj->m_pShading->m_pShadingObj, m_pShading->m_bShadingObj, |
| 26 &obj->m_pShading->m_ParentMatrix); |
| 27 } |
| 28 obj->m_Matrix = m_Matrix; |
| 29 return obj; |
| 30 } |
| 31 |
| 32 void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) { |
| 33 if (!m_ClipPath.IsNull()) { |
| 34 m_ClipPath.GetModify(); |
| 35 m_ClipPath.Transform(matrix); |
| 36 } |
| 37 m_Matrix.Concat(matrix); |
| 38 if (!m_ClipPath.IsNull()) { |
| 39 CalcBoundingBox(); |
| 40 } else { |
| 41 matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom); |
| 42 } |
| 43 } |
| 44 |
| 45 void CPDF_ShadingObject::CalcBoundingBox() { |
| 46 if (m_ClipPath.IsNull()) { |
| 47 return; |
| 48 } |
| 49 CFX_FloatRect rect = m_ClipPath.GetClipBox(); |
| 50 m_Left = rect.left; |
| 51 m_Bottom = rect.bottom; |
| 52 m_Right = rect.right; |
| 53 m_Top = rect.top; |
| 54 } |
OLD | NEW |