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/cpdf_shadingobject.h" | |
8 | |
9 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h" | |
10 #include "core/fpdfapi/fpdf_page/pageint.h" | |
11 #include "core/fpdfapi/fpdf_parser/cpdf_document.h" | |
12 | |
13 CPDF_ShadingObject::CPDF_ShadingObject() : m_pShading(nullptr) {} | |
14 | |
15 CPDF_ShadingObject::~CPDF_ShadingObject() {} | |
16 | |
17 CPDF_ShadingObject* CPDF_ShadingObject::Clone() const { | |
18 CPDF_ShadingObject* obj = new CPDF_ShadingObject; | |
19 obj->CopyData(this); | |
20 | |
21 obj->m_pShading = m_pShading; | |
22 if (obj->m_pShading && obj->m_pShading->document()) { | |
23 CPDF_DocPageData* pDocPageData = obj->m_pShading->document()->GetPageData(); | |
24 CPDF_Pattern* pattern = pDocPageData->GetPattern( | |
25 obj->m_pShading->GetShadingObject(), m_pShading->IsShadingObject(), | |
26 obj->m_pShading->parent_matrix()); | |
27 obj->m_pShading = pattern ? pattern->AsShadingPattern() : nullptr; | |
28 } | |
29 obj->m_Matrix = m_Matrix; | |
30 return obj; | |
31 } | |
32 | |
33 CPDF_PageObject::Type CPDF_ShadingObject::GetType() const { | |
34 return SHADING; | |
35 } | |
36 | |
37 void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) { | |
38 if (m_ClipPath) | |
39 m_ClipPath.Transform(matrix); | |
40 | |
41 m_Matrix.Concat(matrix); | |
42 if (m_ClipPath) { | |
43 CalcBoundingBox(); | |
44 } else { | |
45 matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom); | |
46 } | |
47 } | |
48 | |
49 bool CPDF_ShadingObject::IsShading() const { | |
50 return true; | |
51 } | |
52 | |
53 CPDF_ShadingObject* CPDF_ShadingObject::AsShading() { | |
54 return this; | |
55 } | |
56 | |
57 const CPDF_ShadingObject* CPDF_ShadingObject::AsShading() const { | |
58 return this; | |
59 } | |
60 | |
61 void CPDF_ShadingObject::CalcBoundingBox() { | |
62 if (!m_ClipPath) | |
63 return; | |
64 CFX_FloatRect rect = m_ClipPath.GetClipBox(); | |
65 m_Left = rect.left; | |
66 m_Bottom = rect.bottom; | |
67 m_Right = rect.right; | |
68 m_Top = rect.top; | |
69 } | |
OLD | NEW |