OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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/pageint.h" | 7 #include "core/fpdfapi/fpdf_page/pageint.h" |
8 | 8 |
9 #include <limits.h> | 9 #include <limits.h> |
10 | 10 |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 break; | 785 break; |
786 } | 786 } |
787 input = PDF_Interpolate(input, m_pBounds[i], m_pBounds[i + 1], | 787 input = PDF_Interpolate(input, m_pBounds[i], m_pBounds[i + 1], |
788 m_pEncode[i * 2], m_pEncode[i * 2 + 1]); | 788 m_pEncode[i * 2], m_pEncode[i * 2 + 1]); |
789 int nresults; | 789 int nresults; |
790 m_pSubFunctions[i]->Call(&input, kRequiredNumInputs, outputs, nresults); | 790 m_pSubFunctions[i]->Call(&input, kRequiredNumInputs, outputs, nresults); |
791 return TRUE; | 791 return TRUE; |
792 } | 792 } |
793 | 793 |
794 // static | 794 // static |
795 CPDF_Function* CPDF_Function::Load(CPDF_Object* pFuncObj) { | 795 std::unique_ptr<CPDF_Function> CPDF_Function::Load(CPDF_Object* pFuncObj) { |
| 796 std::unique_ptr<CPDF_Function> pFunc; |
796 if (!pFuncObj) | 797 if (!pFuncObj) |
797 return nullptr; | 798 return pFunc; |
798 | 799 |
799 int iType = -1; | 800 int iType = -1; |
800 if (CPDF_Stream* pStream = pFuncObj->AsStream()) | 801 if (CPDF_Stream* pStream = pFuncObj->AsStream()) |
801 iType = pStream->GetDict()->GetIntegerBy("FunctionType"); | 802 iType = pStream->GetDict()->GetIntegerBy("FunctionType"); |
802 else if (CPDF_Dictionary* pDict = pFuncObj->AsDictionary()) | 803 else if (CPDF_Dictionary* pDict = pFuncObj->AsDictionary()) |
803 iType = pDict->GetIntegerBy("FunctionType"); | 804 iType = pDict->GetIntegerBy("FunctionType"); |
804 | 805 |
805 Type type = IntegerToFunctionType(iType); | 806 Type type = IntegerToFunctionType(iType); |
806 std::unique_ptr<CPDF_Function> pFunc; | |
807 if (type == Type::kType0Sampled) | 807 if (type == Type::kType0Sampled) |
808 pFunc.reset(new CPDF_SampledFunc()); | 808 pFunc.reset(new CPDF_SampledFunc()); |
809 else if (type == Type::kType2ExpotentialInterpolation) | 809 else if (type == Type::kType2ExpotentialInterpolation) |
810 pFunc.reset(new CPDF_ExpIntFunc()); | 810 pFunc.reset(new CPDF_ExpIntFunc()); |
811 else if (type == Type::kType3Stitching) | 811 else if (type == Type::kType3Stitching) |
812 pFunc.reset(new CPDF_StitchFunc()); | 812 pFunc.reset(new CPDF_StitchFunc()); |
813 else if (type == Type::kType4PostScript) | 813 else if (type == Type::kType4PostScript) |
814 pFunc.reset(new CPDF_PSFunc()); | 814 pFunc.reset(new CPDF_PSFunc()); |
815 | 815 |
816 if (!pFunc || !pFunc->Init(pFuncObj)) | 816 if (!pFunc || !pFunc->Init(pFuncObj)) |
817 return nullptr; | 817 return std::unique_ptr<CPDF_Function>(); |
818 return pFunc.release(); | 818 return pFunc; |
819 } | 819 } |
820 | 820 |
821 // static | 821 // static |
822 CPDF_Function::Type CPDF_Function::IntegerToFunctionType(int iType) { | 822 CPDF_Function::Type CPDF_Function::IntegerToFunctionType(int iType) { |
823 switch (iType) { | 823 switch (iType) { |
824 case 0: | 824 case 0: |
825 case 2: | 825 case 2: |
826 case 3: | 826 case 3: |
827 case 4: | 827 case 4: |
828 return static_cast<Type>(iType); | 828 return static_cast<Type>(iType); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 return m_Type == Type::kType2ExpotentialInterpolation | 912 return m_Type == Type::kType2ExpotentialInterpolation |
913 ? static_cast<const CPDF_ExpIntFunc*>(this) | 913 ? static_cast<const CPDF_ExpIntFunc*>(this) |
914 : nullptr; | 914 : nullptr; |
915 } | 915 } |
916 | 916 |
917 const CPDF_StitchFunc* CPDF_Function::ToStitchFunc() const { | 917 const CPDF_StitchFunc* CPDF_Function::ToStitchFunc() const { |
918 return m_Type == Type::kType3Stitching | 918 return m_Type == Type::kType3Stitching |
919 ? static_cast<const CPDF_StitchFunc*>(this) | 919 ? static_cast<const CPDF_StitchFunc*>(this) |
920 : nullptr; | 920 : nullptr; |
921 } | 921 } |
OLD | NEW |