1 // Copyright 2016 The PDFium Authors 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_shadingobject.h" 8 9 #include <utility> 10 11 #include "core/fpdfapi/page/cpdf_shadingpattern.h" 12 CPDF_ShadingObject(int32_t content_stream,RetainPtr<CPDF_ShadingPattern> pattern,const CFX_Matrix & matrix)13CPDF_ShadingObject::CPDF_ShadingObject(int32_t content_stream, 14 RetainPtr<CPDF_ShadingPattern> pattern, 15 const CFX_Matrix& matrix) 16 : CPDF_PageObject(content_stream), 17 m_pShading(std::move(pattern)), 18 m_Matrix(matrix) {} 19 20 CPDF_ShadingObject::~CPDF_ShadingObject() = default; 21 GetType() const22CPDF_PageObject::Type CPDF_ShadingObject::GetType() const { 23 return Type::kShading; 24 } 25 Transform(const CFX_Matrix & matrix)26void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) { 27 if (m_ClipPath.HasRef()) 28 m_ClipPath.Transform(matrix); 29 30 m_Matrix.Concat(matrix); 31 if (m_ClipPath.HasRef()) 32 CalcBoundingBox(); 33 else 34 SetRect(matrix.TransformRect(GetRect())); 35 SetDirty(true); 36 } 37 IsShading() const38bool CPDF_ShadingObject::IsShading() const { 39 return true; 40 } 41 AsShading()42CPDF_ShadingObject* CPDF_ShadingObject::AsShading() { 43 return this; 44 } 45 AsShading() const46const CPDF_ShadingObject* CPDF_ShadingObject::AsShading() const { 47 return this; 48 } 49 CalcBoundingBox()50void CPDF_ShadingObject::CalcBoundingBox() { 51 if (!m_ClipPath.HasRef()) 52 return; 53 SetRect(m_ClipPath.GetClipBox()); 54 } 55