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/page/cpdf_shadingobject.h" 8 9 #include "core/fpdfapi/page/cpdf_shadingpattern.h" 10 #include "core/fpdfapi/parser/cpdf_document.h" 11 CPDF_ShadingObject(int32_t content_stream,CPDF_ShadingPattern * pattern,const CFX_Matrix & matrix)12CPDF_ShadingObject::CPDF_ShadingObject(int32_t content_stream, 13 CPDF_ShadingPattern* pattern, 14 const CFX_Matrix& matrix) 15 : CPDF_PageObject(content_stream), m_pShading(pattern), m_Matrix(matrix) {} 16 ~CPDF_ShadingObject()17CPDF_ShadingObject::~CPDF_ShadingObject() {} 18 GetType() const19CPDF_PageObject::Type CPDF_ShadingObject::GetType() const { 20 return SHADING; 21 } 22 Transform(const CFX_Matrix & matrix)23void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) { 24 if (m_ClipPath.HasRef()) 25 m_ClipPath.Transform(matrix); 26 27 m_Matrix.Concat(matrix); 28 if (m_ClipPath.HasRef()) { 29 CalcBoundingBox(); 30 return; 31 } 32 33 SetRect(matrix.TransformRect(GetRect())); 34 } 35 IsShading() const36bool CPDF_ShadingObject::IsShading() const { 37 return true; 38 } 39 AsShading()40CPDF_ShadingObject* CPDF_ShadingObject::AsShading() { 41 return this; 42 } 43 AsShading() const44const CPDF_ShadingObject* CPDF_ShadingObject::AsShading() const { 45 return this; 46 } 47 CalcBoundingBox()48void CPDF_ShadingObject::CalcBoundingBox() { 49 if (!m_ClipPath.HasRef()) 50 return; 51 SetRect(m_ClipPath.GetClipBox()); 52 } 53