| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fpdfapi/fpdf_page/include/cpdf_shadingobject.h" | 7 #include "core/fpdfapi/fpdf_page/include/cpdf_shadingobject.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h" | 9 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h" |
| 10 #include "core/fpdfapi/fpdf_page/pageint.h" | 10 #include "core/fpdfapi/fpdf_page/pageint.h" |
| 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 12 | 12 |
| 13 CPDF_ShadingObject::CPDF_ShadingObject() : m_pShading(nullptr) {} | 13 CPDF_ShadingObject::CPDF_ShadingObject() : m_pShading(nullptr) {} |
| 14 | 14 |
| 15 CPDF_ShadingObject::~CPDF_ShadingObject() {} | 15 CPDF_ShadingObject::~CPDF_ShadingObject() {} |
| 16 | 16 |
| 17 CPDF_ShadingObject* CPDF_ShadingObject::Clone() const { | 17 CPDF_ShadingObject* CPDF_ShadingObject::Clone() const { |
| 18 CPDF_ShadingObject* obj = new CPDF_ShadingObject; | 18 CPDF_ShadingObject* obj = new CPDF_ShadingObject; |
| 19 obj->CopyData(this); | 19 obj->CopyData(this); |
| 20 | 20 |
| 21 obj->m_pShading = m_pShading; | 21 obj->m_pShading = m_pShading; |
| 22 if (obj->m_pShading && obj->m_pShading->m_pDocument) { | 22 if (obj->m_pShading && obj->m_pShading->document()) { |
| 23 CPDF_DocPageData* pDocPageData = | 23 CPDF_DocPageData* pDocPageData = obj->m_pShading->document()->GetPageData(); |
| 24 obj->m_pShading->m_pDocument->GetPageData(); | 24 CPDF_Pattern* pattern = pDocPageData->GetPattern( |
| 25 obj->m_pShading = (CPDF_ShadingPattern*)pDocPageData->GetPattern( | |
| 26 obj->m_pShading->m_pShadingObj, m_pShading->m_bShadingObj, | 25 obj->m_pShading->m_pShadingObj, m_pShading->m_bShadingObj, |
| 27 &obj->m_pShading->m_ParentMatrix); | 26 obj->m_pShading->parent_matrix()); |
| 27 obj->m_pShading = pattern ? pattern->AsShadingPattern() : nullptr; |
| 28 } | 28 } |
| 29 obj->m_Matrix = m_Matrix; | 29 obj->m_Matrix = m_Matrix; |
| 30 return obj; | 30 return obj; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) { | 33 void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) { |
| 34 if (!m_ClipPath.IsNull()) { | 34 if (!m_ClipPath.IsNull()) { |
| 35 m_ClipPath.GetModify(); | 35 m_ClipPath.GetModify(); |
| 36 m_ClipPath.Transform(matrix); | 36 m_ClipPath.Transform(matrix); |
| 37 } | 37 } |
| 38 m_Matrix.Concat(matrix); | 38 m_Matrix.Concat(matrix); |
| 39 if (!m_ClipPath.IsNull()) { | 39 if (!m_ClipPath.IsNull()) { |
| 40 CalcBoundingBox(); | 40 CalcBoundingBox(); |
| 41 } else { | 41 } else { |
| 42 matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom); | 42 matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 void CPDF_ShadingObject::CalcBoundingBox() { | 46 void CPDF_ShadingObject::CalcBoundingBox() { |
| 47 if (m_ClipPath.IsNull()) { | 47 if (m_ClipPath.IsNull()) { |
| 48 return; | 48 return; |
| 49 } | 49 } |
| 50 CFX_FloatRect rect = m_ClipPath.GetClipBox(); | 50 CFX_FloatRect rect = m_ClipPath.GetClipBox(); |
| 51 m_Left = rect.left; | 51 m_Left = rect.left; |
| 52 m_Bottom = rect.bottom; | 52 m_Bottom = rect.bottom; |
| 53 m_Right = rect.right; | 53 m_Right = rect.right; |
| 54 m_Top = rect.top; | 54 m_Top = rect.top; |
| 55 } | 55 } |
| OLD | NEW |