Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp

Issue 1410343003: [Merge to XFA] Revert "Revert "Add type cast definitions for CPDF_Dictionary."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <limits.h> 7 #include <limits.h>
8 8
9 #include "../../../../third_party/base/numerics/safe_conversions_impl.h" 9 #include "../../../../third_party/base/numerics/safe_conversions_impl.h"
10 #include "../../../include/fpdfapi/fpdf_module.h" 10 #include "../../../include/fpdfapi/fpdf_module.h"
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 CPDF_Function* CPDF_Function::Load(CPDF_Object* pFuncObj) { 811 CPDF_Function* CPDF_Function::Load(CPDF_Object* pFuncObj) {
812 if (pFuncObj == NULL) { 812 if (pFuncObj == NULL) {
813 return NULL; 813 return NULL;
814 } 814 }
815 CPDF_Function* pFunc = NULL; 815 CPDF_Function* pFunc = NULL;
816 int type; 816 int type;
817 if (pFuncObj->GetType() == PDFOBJ_STREAM) { 817 if (pFuncObj->GetType() == PDFOBJ_STREAM) {
818 type = ((CPDF_Stream*)pFuncObj) 818 type = ((CPDF_Stream*)pFuncObj)
819 ->GetDict() 819 ->GetDict()
820 ->GetInteger(FX_BSTRC("FunctionType")); 820 ->GetInteger(FX_BSTRC("FunctionType"));
821 } else if (pFuncObj->GetType() == PDFOBJ_DICTIONARY) { 821 } else if (CPDF_Dictionary* pDict = pFuncObj->AsDictionary()) {
822 type = ((CPDF_Dictionary*)pFuncObj)->GetInteger(FX_BSTRC("FunctionType")); 822 type = pDict->GetInteger(FX_BSTRC("FunctionType"));
823 } else { 823 } else {
824 return NULL; 824 return NULL;
825 } 825 }
826 if (type == 0) { 826 if (type == 0) {
827 pFunc = new CPDF_SampledFunc; 827 pFunc = new CPDF_SampledFunc;
828 } else if (type == 2) { 828 } else if (type == 2) {
829 pFunc = new CPDF_ExpIntFunc; 829 pFunc = new CPDF_ExpIntFunc;
830 } else if (type == 3) { 830 } else if (type == 3) {
831 pFunc = new CPDF_StitchFunc; 831 pFunc = new CPDF_StitchFunc;
832 } else if (type == 4) { 832 } else if (type == 4) {
(...skipping 13 matching lines...) Expand all
846 } 846 }
847 CPDF_Function::~CPDF_Function() { 847 CPDF_Function::~CPDF_Function() {
848 FX_Free(m_pDomains); 848 FX_Free(m_pDomains);
849 FX_Free(m_pRanges); 849 FX_Free(m_pRanges);
850 } 850 }
851 FX_BOOL CPDF_Function::Init(CPDF_Object* pObj) { 851 FX_BOOL CPDF_Function::Init(CPDF_Object* pObj) {
852 CPDF_Dictionary* pDict; 852 CPDF_Dictionary* pDict;
853 if (pObj->GetType() == PDFOBJ_STREAM) { 853 if (pObj->GetType() == PDFOBJ_STREAM) {
854 pDict = ((CPDF_Stream*)pObj)->GetDict(); 854 pDict = ((CPDF_Stream*)pObj)->GetDict();
855 } else { 855 } else {
856 pDict = (CPDF_Dictionary*)pObj; 856 pDict = pObj->AsDictionary();
857 } 857 }
858 CPDF_Array* pDomains = pDict->GetArray(FX_BSTRC("Domain")); 858 CPDF_Array* pDomains = pDict->GetArray(FX_BSTRC("Domain"));
859 if (pDomains == NULL) { 859 if (pDomains == NULL) {
860 return FALSE; 860 return FALSE;
861 } 861 }
862 m_nInputs = pDomains->GetCount() / 2; 862 m_nInputs = pDomains->GetCount() / 2;
863 if (m_nInputs == 0) { 863 if (m_nInputs == 0) {
864 return FALSE; 864 return FALSE;
865 } 865 }
866 m_pDomains = FX_Alloc2D(FX_FLOAT, m_nInputs, 2); 866 m_pDomains = FX_Alloc2D(FX_FLOAT, m_nInputs, 2);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 for (int i = 0; i < m_nOutputs; i++) { 909 for (int i = 0; i < m_nOutputs; i++) {
910 if (results[i] < m_pRanges[i * 2]) { 910 if (results[i] < m_pRanges[i * 2]) {
911 results[i] = m_pRanges[i * 2]; 911 results[i] = m_pRanges[i * 2];
912 } else if (results[i] > m_pRanges[i * 2 + 1]) { 912 } else if (results[i] > m_pRanges[i * 2 + 1]) {
913 results[i] = m_pRanges[i * 2 + 1]; 913 results[i] = m_pRanges[i * 2 + 1];
914 } 914 }
915 } 915 }
916 } 916 }
917 return TRUE; 917 return TRUE;
918 } 918 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698