| 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/page/cpdf_shadingpattern.h" | 7 #include "core/fpdfapi/page/cpdf_shadingpattern.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/page/cpdf_docpagedata.h" | 9 #include "core/fpdfapi/page/cpdf_docpagedata.h" |
| 10 #include "core/fpdfapi/page/pageint.h" | 10 #include "core/fpdfapi/page/pageint.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 CPDF_TilingPattern* CPDF_ShadingPattern::AsTilingPattern() { | 55 CPDF_TilingPattern* CPDF_ShadingPattern::AsTilingPattern() { |
| 56 return nullptr; | 56 return nullptr; |
| 57 } | 57 } |
| 58 | 58 |
| 59 CPDF_ShadingPattern* CPDF_ShadingPattern::AsShadingPattern() { | 59 CPDF_ShadingPattern* CPDF_ShadingPattern::AsShadingPattern() { |
| 60 return this; | 60 return this; |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool CPDF_ShadingPattern::Load() { | 63 bool CPDF_ShadingPattern::Load() { |
| 64 if (m_ShadingType != kInvalidShading) | 64 if (m_ShadingType != kInvalidShading) |
| 65 return TRUE; | 65 return true; |
| 66 | 66 |
| 67 CPDF_Dictionary* pShadingDict = | 67 CPDF_Dictionary* pShadingDict = |
| 68 m_pShadingObj ? m_pShadingObj->GetDict() : nullptr; | 68 m_pShadingObj ? m_pShadingObj->GetDict() : nullptr; |
| 69 if (!pShadingDict) | 69 if (!pShadingDict) |
| 70 return FALSE; | 70 return false; |
| 71 | 71 |
| 72 m_pFunctions.clear(); | 72 m_pFunctions.clear(); |
| 73 CPDF_Object* pFunc = pShadingDict->GetDirectObjectFor("Function"); | 73 CPDF_Object* pFunc = pShadingDict->GetDirectObjectFor("Function"); |
| 74 if (pFunc) { | 74 if (pFunc) { |
| 75 if (CPDF_Array* pArray = pFunc->AsArray()) { | 75 if (CPDF_Array* pArray = pFunc->AsArray()) { |
| 76 m_pFunctions.resize(std::min<size_t>(pArray->GetCount(), 4)); | 76 m_pFunctions.resize(std::min<size_t>(pArray->GetCount(), 4)); |
| 77 for (size_t i = 0; i < m_pFunctions.size(); ++i) | 77 for (size_t i = 0; i < m_pFunctions.size(); ++i) |
| 78 m_pFunctions[i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i)); | 78 m_pFunctions[i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i)); |
| 79 } else { | 79 } else { |
| 80 m_pFunctions.push_back(CPDF_Function::Load(pFunc)); | 80 m_pFunctions.push_back(CPDF_Function::Load(pFunc)); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 CPDF_Object* pCSObj = pShadingDict->GetDirectObjectFor("ColorSpace"); | 83 CPDF_Object* pCSObj = pShadingDict->GetDirectObjectFor("ColorSpace"); |
| 84 if (!pCSObj) | 84 if (!pCSObj) |
| 85 return FALSE; | 85 return false; |
| 86 | 86 |
| 87 CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData(); | 87 CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData(); |
| 88 m_pCS = pDocPageData->GetColorSpace(pCSObj, nullptr); | 88 m_pCS = pDocPageData->GetColorSpace(pCSObj, nullptr); |
| 89 if (m_pCS) | 89 if (m_pCS) |
| 90 m_pCountedCS = pDocPageData->FindColorSpacePtr(m_pCS->GetArray()); | 90 m_pCountedCS = pDocPageData->FindColorSpacePtr(m_pCS->GetArray()); |
| 91 | 91 |
| 92 m_ShadingType = ToShadingType(pShadingDict->GetIntegerFor("ShadingType")); | 92 m_ShadingType = ToShadingType(pShadingDict->GetIntegerFor("ShadingType")); |
| 93 | 93 |
| 94 // We expect to have a stream if our shading type is a mesh. | 94 // We expect to have a stream if our shading type is a mesh. |
| 95 if (IsMeshShading() && !ToStream(m_pShadingObj)) | 95 if (IsMeshShading() && !ToStream(m_pShadingObj)) |
| 96 return FALSE; | 96 return false; |
| 97 | 97 |
| 98 return TRUE; | 98 return true; |
| 99 } | 99 } |
| OLD | NEW |