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

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

Issue 1686153004: Add a class to better represent PS operations. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: FX_PI Created 4 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "pageint.h" 7 #include "core/src/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <utility>
12 #include <vector> 13 #include <vector>
13 14
14 #include "core/include/fpdfapi/fpdf_module.h" 15 #include "core/include/fpdfapi/fpdf_module.h"
15 #include "core/include/fpdfapi/fpdf_page.h" 16 #include "core/include/fpdfapi/fpdf_page.h"
16 #include "core/include/fxcrt/fx_safe_types.h" 17 #include "core/include/fxcrt/fx_safe_types.h"
17 #include "third_party/base/numerics/safe_conversions_impl.h" 18 #include "third_party/base/numerics/safe_conversions_impl.h"
18 19
19 class CPDF_PSEngine; 20 namespace {
20 typedef enum { 21
22 enum PDF_PSOP {
21 PSOP_ADD, 23 PSOP_ADD,
22 PSOP_SUB, 24 PSOP_SUB,
23 PSOP_MUL, 25 PSOP_MUL,
24 PSOP_DIV, 26 PSOP_DIV,
25 PSOP_IDIV, 27 PSOP_IDIV,
26 PSOP_MOD, 28 PSOP_MOD,
27 PSOP_NEG, 29 PSOP_NEG,
28 PSOP_ABS, 30 PSOP_ABS,
29 PSOP_CEILING, 31 PSOP_CEILING,
30 PSOP_FLOOR, 32 PSOP_FLOOR,
(...skipping 24 matching lines...) Expand all
55 PSOP_IF, 57 PSOP_IF,
56 PSOP_IFELSE, 58 PSOP_IFELSE,
57 PSOP_POP, 59 PSOP_POP,
58 PSOP_EXCH, 60 PSOP_EXCH,
59 PSOP_DUP, 61 PSOP_DUP,
60 PSOP_COPY, 62 PSOP_COPY,
61 PSOP_INDEX, 63 PSOP_INDEX,
62 PSOP_ROLL, 64 PSOP_ROLL,
63 PSOP_PROC, 65 PSOP_PROC,
64 PSOP_CONST 66 PSOP_CONST
65 } PDF_PSOP; 67 };
68
69 class CPDF_PSEngine;
70 class CPDF_PSProc;
71
72 class CPDF_PSOP {
73 public:
74 explicit CPDF_PSOP(PDF_PSOP op) : m_op(op), m_value(0) {
75 ASSERT(m_op != PSOP_CONST);
76 ASSERT(m_op != PSOP_PROC);
77 }
78 explicit CPDF_PSOP(FX_FLOAT value) : m_op(PSOP_CONST), m_value(value) {}
79 explicit CPDF_PSOP(std::unique_ptr<CPDF_PSProc> proc)
80 : m_op(PSOP_PROC), m_value(0), m_proc(std::move(proc)) {}
81
82 FX_FLOAT GetFloatValue() const {
83 if (m_op == PSOP_CONST)
84 return m_value;
85
86 ASSERT(false);
87 return 0;
88 }
89 CPDF_PSProc* GetProc() const {
90 if (m_op == PSOP_PROC)
91 return m_proc.get();
92 ASSERT(false);
93 return nullptr;
94 }
95
96 PDF_PSOP GetOp() const { return m_op; }
97
98 private:
99 const PDF_PSOP m_op;
100 const FX_FLOAT m_value;
101 std::unique_ptr<CPDF_PSProc> m_proc;
102 };
103
66 class CPDF_PSProc { 104 class CPDF_PSProc {
67 public: 105 public:
68 ~CPDF_PSProc(); 106 CPDF_PSProc() {}
69 FX_BOOL Parse(CPDF_SimpleParser& parser); 107 ~CPDF_PSProc() {}
108
109 FX_BOOL Parse(CPDF_SimpleParser* parser);
70 FX_BOOL Execute(CPDF_PSEngine* pEngine); 110 FX_BOOL Execute(CPDF_PSEngine* pEngine);
71 std::vector<void*> m_Operators; 111
112 private:
113 std::vector<std::unique_ptr<CPDF_PSOP>> m_Operators;
72 }; 114 };
73 #define PSENGINE_STACKSIZE 100 115
116 const size_t PSENGINE_STACKSIZE = 100;
117
74 class CPDF_PSEngine { 118 class CPDF_PSEngine {
75 public: 119 public:
76 CPDF_PSEngine(); 120 CPDF_PSEngine();
77 ~CPDF_PSEngine(); 121 ~CPDF_PSEngine();
122
78 FX_BOOL Parse(const FX_CHAR* string, int size); 123 FX_BOOL Parse(const FX_CHAR* string, int size);
79 FX_BOOL Execute() { return m_MainProc.Execute(this); } 124 FX_BOOL Execute() { return m_MainProc.Execute(this); }
80 FX_BOOL DoOperator(PDF_PSOP op); 125 FX_BOOL DoOperator(PDF_PSOP op);
81 void Reset() { m_StackCount = 0; } 126 void Reset() { m_StackCount = 0; }
82 void Push(FX_FLOAT value); 127 void Push(FX_FLOAT value);
83 void Push(int value) { Push((FX_FLOAT)value); } 128 void Push(int value) { Push((FX_FLOAT)value); }
84 FX_FLOAT Pop(); 129 FX_FLOAT Pop();
85 int GetStackSize() { return m_StackCount; } 130 int GetStackSize() const { return m_StackCount; }
86 131
87 private: 132 private:
88 FX_FLOAT m_Stack[PSENGINE_STACKSIZE]; 133 FX_FLOAT m_Stack[PSENGINE_STACKSIZE];
89 int m_StackCount; 134 int m_StackCount;
90 CPDF_PSProc m_MainProc; 135 CPDF_PSProc m_MainProc;
91 }; 136 };
92 CPDF_PSProc::~CPDF_PSProc() { 137
93 for (size_t i = 0; i < m_Operators.size(); i++) { 138 FX_BOOL CPDF_PSProc::Execute(CPDF_PSEngine* pEngine) {
94 if (m_Operators[i] == (void*)PSOP_PROC) { 139 for (size_t i = 0; i < m_Operators.size(); ++i) {
95 delete (CPDF_PSProc*)m_Operators[i + 1]; 140 const PDF_PSOP op = m_Operators[i]->GetOp();
96 i++; 141 if (op == PSOP_PROC)
97 } else if (m_Operators[i] == (void*)PSOP_CONST) { 142 continue;
98 FX_Free((FX_FLOAT*)m_Operators[i + 1]); 143
99 i++; 144 if (op == PSOP_CONST) {
145 pEngine->Push(m_Operators[i]->GetFloatValue());
146 continue;
100 } 147 }
101 } 148
102 } 149 if (op == PSOP_IF) {
103 FX_BOOL CPDF_PSProc::Execute(CPDF_PSEngine* pEngine) { 150 if (i == 0 || m_Operators[i - 1]->GetOp() != PSOP_PROC)
104 for (size_t i = 0; i < m_Operators.size(); i++) { 151 return FALSE;
105 PDF_PSOP op = (PDF_PSOP)(uintptr_t)m_Operators[i]; 152
106 if (op == PSOP_PROC) { 153 if (static_cast<int>(pEngine->Pop()))
107 i++; 154 m_Operators[i - 1]->GetProc()->Execute(pEngine);
108 } else if (op == PSOP_CONST) { 155 } else if (op == PSOP_IFELSE) {
109 pEngine->Push(*(FX_FLOAT*)m_Operators[i + 1]); 156 if (i < 2 || m_Operators[i - 1]->GetOp() != PSOP_PROC ||
110 i++; 157 m_Operators[i - 2]->GetOp() != PSOP_PROC) {
111 } else if (op == PSOP_IF) {
112 if (i < 2 || m_Operators[i - 2] != (void*)PSOP_PROC) {
113 return FALSE; 158 return FALSE;
114 } 159 }
115 if ((int)pEngine->Pop()) { 160 size_t offset = static_cast<int>(pEngine->Pop()) ? 2 : 1;
116 ((CPDF_PSProc*)m_Operators[i - 1])->Execute(pEngine); 161 m_Operators[i - offset]->GetProc()->Execute(pEngine);
117 }
118 } else if (op == PSOP_IFELSE) {
119 if (i < 4 || m_Operators[i - 2] != (void*)PSOP_PROC ||
120 m_Operators[i - 4] != (void*)PSOP_PROC) {
121 return FALSE;
122 }
123 if ((int)pEngine->Pop()) {
124 ((CPDF_PSProc*)m_Operators[i - 3])->Execute(pEngine);
125 } else {
126 ((CPDF_PSProc*)m_Operators[i - 1])->Execute(pEngine);
127 }
128 } else { 162 } else {
129 pEngine->DoOperator(op); 163 pEngine->DoOperator(op);
130 } 164 }
131 } 165 }
132 return TRUE; 166 return TRUE;
133 } 167 }
168
134 CPDF_PSEngine::CPDF_PSEngine() { 169 CPDF_PSEngine::CPDF_PSEngine() {
135 m_StackCount = 0; 170 m_StackCount = 0;
136 } 171 }
137 CPDF_PSEngine::~CPDF_PSEngine() {} 172 CPDF_PSEngine::~CPDF_PSEngine() {}
138 void CPDF_PSEngine::Push(FX_FLOAT v) { 173 void CPDF_PSEngine::Push(FX_FLOAT v) {
139 if (m_StackCount == 100) { 174 if (m_StackCount == PSENGINE_STACKSIZE) {
140 return; 175 return;
141 } 176 }
142 m_Stack[m_StackCount++] = v; 177 m_Stack[m_StackCount++] = v;
143 } 178 }
144 FX_FLOAT CPDF_PSEngine::Pop() { 179 FX_FLOAT CPDF_PSEngine::Pop() {
145 if (m_StackCount == 0) { 180 if (m_StackCount == 0) {
146 return 0; 181 return 0;
147 } 182 }
148 return m_Stack[--m_StackCount]; 183 return m_Stack[--m_StackCount];
149 } 184 }
150 const struct _PDF_PSOpName { 185 const struct PDF_PSOpName {
151 const FX_CHAR* name; 186 const FX_CHAR* name;
152 PDF_PSOP op; 187 PDF_PSOP op;
153 } _PDF_PSOpNames[] = {{"add", PSOP_ADD}, {"sub", PSOP_SUB}, 188 } PDF_PSOpNames[] = {{"add", PSOP_ADD}, {"sub", PSOP_SUB},
154 {"mul", PSOP_MUL}, {"div", PSOP_DIV}, 189 {"mul", PSOP_MUL}, {"div", PSOP_DIV},
155 {"idiv", PSOP_IDIV}, {"mod", PSOP_MOD}, 190 {"idiv", PSOP_IDIV}, {"mod", PSOP_MOD},
156 {"neg", PSOP_NEG}, {"abs", PSOP_ABS}, 191 {"neg", PSOP_NEG}, {"abs", PSOP_ABS},
157 {"ceiling", PSOP_CEILING}, {"floor", PSOP_FLOOR}, 192 {"ceiling", PSOP_CEILING}, {"floor", PSOP_FLOOR},
158 {"round", PSOP_ROUND}, {"truncate", PSOP_TRUNCATE}, 193 {"round", PSOP_ROUND}, {"truncate", PSOP_TRUNCATE},
159 {"sqrt", PSOP_SQRT}, {"sin", PSOP_SIN}, 194 {"sqrt", PSOP_SQRT}, {"sin", PSOP_SIN},
160 {"cos", PSOP_COS}, {"atan", PSOP_ATAN}, 195 {"cos", PSOP_COS}, {"atan", PSOP_ATAN},
161 {"exp", PSOP_EXP}, {"ln", PSOP_LN}, 196 {"exp", PSOP_EXP}, {"ln", PSOP_LN},
162 {"log", PSOP_LOG}, {"cvi", PSOP_CVI}, 197 {"log", PSOP_LOG}, {"cvi", PSOP_CVI},
163 {"cvr", PSOP_CVR}, {"eq", PSOP_EQ}, 198 {"cvr", PSOP_CVR}, {"eq", PSOP_EQ},
164 {"ne", PSOP_NE}, {"gt", PSOP_GT}, 199 {"ne", PSOP_NE}, {"gt", PSOP_GT},
165 {"ge", PSOP_GE}, {"lt", PSOP_LT}, 200 {"ge", PSOP_GE}, {"lt", PSOP_LT},
166 {"le", PSOP_LE}, {"and", PSOP_AND}, 201 {"le", PSOP_LE}, {"and", PSOP_AND},
167 {"or", PSOP_OR}, {"xor", PSOP_XOR}, 202 {"or", PSOP_OR}, {"xor", PSOP_XOR},
168 {"not", PSOP_NOT}, {"bitshift", PSOP_BITSHIFT}, 203 {"not", PSOP_NOT}, {"bitshift", PSOP_BITSHIFT},
169 {"true", PSOP_TRUE}, {"false", PSOP_FALSE}, 204 {"true", PSOP_TRUE}, {"false", PSOP_FALSE},
170 {"if", PSOP_IF}, {"ifelse", PSOP_IFELSE}, 205 {"if", PSOP_IF}, {"ifelse", PSOP_IFELSE},
171 {"pop", PSOP_POP}, {"exch", PSOP_EXCH}, 206 {"pop", PSOP_POP}, {"exch", PSOP_EXCH},
172 {"dup", PSOP_DUP}, {"copy", PSOP_COPY}, 207 {"dup", PSOP_DUP}, {"copy", PSOP_COPY},
173 {"index", PSOP_INDEX}, {"roll", PSOP_ROLL}, 208 {"index", PSOP_INDEX}, {"roll", PSOP_ROLL}};
174 {NULL, PSOP_PROC}}; 209
175 FX_BOOL CPDF_PSEngine::Parse(const FX_CHAR* string, int size) { 210 FX_BOOL CPDF_PSEngine::Parse(const FX_CHAR* string, int size) {
176 CPDF_SimpleParser parser((uint8_t*)string, size); 211 CPDF_SimpleParser parser((uint8_t*)string, size);
177 CFX_ByteStringC word = parser.GetWord(); 212 CFX_ByteStringC word = parser.GetWord();
178 if (word != "{") { 213 if (word != "{") {
179 return FALSE; 214 return FALSE;
180 } 215 }
181 return m_MainProc.Parse(parser); 216 return m_MainProc.Parse(&parser);
182 } 217 }
183 FX_BOOL CPDF_PSProc::Parse(CPDF_SimpleParser& parser) { 218 FX_BOOL CPDF_PSProc::Parse(CPDF_SimpleParser* parser) {
184 while (1) { 219 while (1) {
185 CFX_ByteStringC word = parser.GetWord(); 220 CFX_ByteStringC word = parser->GetWord();
186 if (word.IsEmpty()) { 221 if (word.IsEmpty()) {
187 return FALSE; 222 return FALSE;
188 } 223 }
189 if (word == "}") { 224 if (word == "}") {
190 return TRUE; 225 return TRUE;
191 } 226 }
192 if (word == "{") { 227 if (word == "{") {
193 CPDF_PSProc* pProc = new CPDF_PSProc; 228 std::unique_ptr<CPDF_PSProc> proc(new CPDF_PSProc);
194 m_Operators.push_back((void*)PSOP_PROC); 229 std::unique_ptr<CPDF_PSOP> op(new CPDF_PSOP(std::move(proc)));
195 m_Operators.push_back(pProc); 230 m_Operators.push_back(std::move(op));
196 if (!pProc->Parse(parser)) { 231 if (!m_Operators.back()->GetProc()->Parse(parser)) {
197 return FALSE; 232 return FALSE;
198 } 233 }
199 } else { 234 } else {
200 int i = 0; 235 bool found = false;
201 while (_PDF_PSOpNames[i].name) { 236 for (const PDF_PSOpName& op_name : PDF_PSOpNames) {
202 if (word == CFX_ByteStringC(_PDF_PSOpNames[i].name)) { 237 if (word == CFX_ByteStringC(op_name.name)) {
203 m_Operators.push_back((void*)_PDF_PSOpNames[i].op); 238 std::unique_ptr<CPDF_PSOP> op(new CPDF_PSOP(op_name.op));
239 m_Operators.push_back(std::move(op));
240 found = true;
204 break; 241 break;
205 } 242 }
206 i++;
207 } 243 }
208 if (!_PDF_PSOpNames[i].name) { 244 if (!found) {
209 FX_FLOAT* pd = FX_Alloc(FX_FLOAT, 1); 245 std::unique_ptr<CPDF_PSOP> op(new CPDF_PSOP(FX_atof(word)));
210 *pd = FX_atof(word); 246 m_Operators.push_back(std::move(op));
211 m_Operators.push_back((void*)PSOP_CONST);
212 m_Operators.push_back(pd);
213 } 247 }
214 } 248 }
215 } 249 }
216 } 250 }
217 #define PI 3.1415926535897932384626433832795f 251
218 FX_BOOL CPDF_PSEngine::DoOperator(PDF_PSOP op) { 252 FX_BOOL CPDF_PSEngine::DoOperator(PDF_PSOP op) {
219 int i1, i2; 253 int i1, i2;
220 FX_FLOAT d1, d2; 254 FX_FLOAT d1, d2;
221 switch (op) { 255 switch (op) {
222 case PSOP_ADD: 256 case PSOP_ADD:
223 d1 = Pop(); 257 d1 = Pop();
224 d2 = Pop(); 258 d2 = Pop();
225 Push(d1 + d2); 259 Push(d1 + d2);
226 break; 260 break;
227 case PSOP_SUB: 261 case PSOP_SUB:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 case PSOP_TRUNCATE: 306 case PSOP_TRUNCATE:
273 i1 = (int)Pop(); 307 i1 = (int)Pop();
274 Push(i1); 308 Push(i1);
275 break; 309 break;
276 case PSOP_SQRT: 310 case PSOP_SQRT:
277 d1 = Pop(); 311 d1 = Pop();
278 Push((FX_FLOAT)FXSYS_sqrt(d1)); 312 Push((FX_FLOAT)FXSYS_sqrt(d1));
279 break; 313 break;
280 case PSOP_SIN: 314 case PSOP_SIN:
281 d1 = Pop(); 315 d1 = Pop();
282 Push((FX_FLOAT)FXSYS_sin(d1 * PI / 180.0f)); 316 Push((FX_FLOAT)FXSYS_sin(d1 * FX_PI / 180.0f));
283 break; 317 break;
284 case PSOP_COS: 318 case PSOP_COS:
285 d1 = Pop(); 319 d1 = Pop();
286 Push((FX_FLOAT)FXSYS_cos(d1 * PI / 180.0f)); 320 Push((FX_FLOAT)FXSYS_cos(d1 * FX_PI / 180.0f));
287 break; 321 break;
288 case PSOP_ATAN: 322 case PSOP_ATAN:
289 d2 = Pop(); 323 d2 = Pop();
290 d1 = Pop(); 324 d1 = Pop();
291 d1 = (FX_FLOAT)(FXSYS_atan2(d1, d2) * 180.0 / PI); 325 d1 = (FX_FLOAT)(FXSYS_atan2(d1, d2) * 180.0 / FX_PI);
292 if (d1 < 0) { 326 if (d1 < 0) {
293 d1 += 360; 327 d1 += 360;
294 } 328 }
295 Push(d1); 329 Push(d1);
296 break; 330 break;
297 case PSOP_EXP: 331 case PSOP_EXP:
298 d2 = Pop(); 332 d2 = Pop();
299 d1 = Pop(); 333 d1 = Pop();
300 Push((FX_FLOAT)FXSYS_pow(d1, d2)); 334 Push((FX_FLOAT)FXSYS_pow(d1, d2));
301 break; 335 break;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 448 }
415 case PSOP_ROLL: { 449 case PSOP_ROLL: {
416 int j = (int)Pop(); 450 int j = (int)Pop();
417 int n = (int)Pop(); 451 int n = (int)Pop();
418 if (m_StackCount == 0) { 452 if (m_StackCount == 0) {
419 break; 453 break;
420 } 454 }
421 if (n < 0 || n > m_StackCount) { 455 if (n < 0 || n > m_StackCount) {
422 break; 456 break;
423 } 457 }
424 if (j < 0) 458 if (j < 0) {
425 for (int i = 0; i < -j; i++) { 459 for (int i = 0; i < -j; i++) {
426 FX_FLOAT first = m_Stack[m_StackCount - n]; 460 FX_FLOAT first = m_Stack[m_StackCount - n];
427 for (int ii = 0; ii < n - 1; ii++) { 461 for (int ii = 0; ii < n - 1; ii++) {
428 m_Stack[m_StackCount - n + ii] = m_Stack[m_StackCount - n + ii + 1]; 462 m_Stack[m_StackCount - n + ii] = m_Stack[m_StackCount - n + ii + 1];
429 } 463 }
430 m_Stack[m_StackCount - 1] = first; 464 m_Stack[m_StackCount - 1] = first;
431 } 465 }
432 else 466 } else {
433 for (int i = 0; i < j; i++) { 467 for (int i = 0; i < j; i++) {
434 FX_FLOAT last = m_Stack[m_StackCount - 1]; 468 FX_FLOAT last = m_Stack[m_StackCount - 1];
435 int ii; 469 int ii;
436 for (ii = 0; ii < n - 1; ii++) { 470 for (ii = 0; ii < n - 1; ii++) {
437 m_Stack[m_StackCount - ii - 1] = m_Stack[m_StackCount - ii - 2]; 471 m_Stack[m_StackCount - ii - 1] = m_Stack[m_StackCount - ii - 2];
438 } 472 }
439 m_Stack[m_StackCount - ii - 1] = last; 473 m_Stack[m_StackCount - ii - 1] = last;
440 } 474 }
475 }
441 break; 476 break;
442 } 477 }
443 default: 478 default:
444 break; 479 break;
445 } 480 }
446 return TRUE; 481 return TRUE;
447 } 482 }
448 static FX_FLOAT PDF_Interpolate(FX_FLOAT x, 483 static FX_FLOAT PDF_Interpolate(FX_FLOAT x,
449 FX_FLOAT xmin, 484 FX_FLOAT xmin,
450 FX_FLOAT xmax, 485 FX_FLOAT xmax,
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 } 848 }
814 if (!m_pSubFunctions[i]) { 849 if (!m_pSubFunctions[i]) {
815 return FALSE; 850 return FALSE;
816 } 851 }
817 input = PDF_Interpolate(input, m_pBounds[i], m_pBounds[i + 1], 852 input = PDF_Interpolate(input, m_pBounds[i], m_pBounds[i + 1],
818 m_pEncode[i * 2], m_pEncode[i * 2 + 1]); 853 m_pEncode[i * 2], m_pEncode[i * 2 + 1]);
819 int nresults; 854 int nresults;
820 m_pSubFunctions[i]->Call(&input, kRequiredNumInputs, outputs, nresults); 855 m_pSubFunctions[i]->Call(&input, kRequiredNumInputs, outputs, nresults);
821 return TRUE; 856 return TRUE;
822 } 857 }
858
859 } // namespace
860
823 CPDF_Function* CPDF_Function::Load(CPDF_Object* pFuncObj) { 861 CPDF_Function* CPDF_Function::Load(CPDF_Object* pFuncObj) {
824 if (!pFuncObj) { 862 if (!pFuncObj) {
825 return NULL; 863 return NULL;
826 } 864 }
827 CPDF_Function* pFunc = NULL; 865 CPDF_Function* pFunc = NULL;
828 int type; 866 int type;
829 if (CPDF_Stream* pStream = pFuncObj->AsStream()) { 867 if (CPDF_Stream* pStream = pFuncObj->AsStream()) {
830 type = pStream->GetDict()->GetIntegerBy("FunctionType"); 868 type = pStream->GetDict()->GetIntegerBy("FunctionType");
831 } else if (CPDF_Dictionary* pDict = pFuncObj->AsDictionary()) { 869 } else if (CPDF_Dictionary* pDict = pFuncObj->AsDictionary()) {
832 type = pDict->GetIntegerBy("FunctionType"); 870 type = pDict->GetIntegerBy("FunctionType");
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 for (int i = 0; i < m_nOutputs; i++) { 954 for (int i = 0; i < m_nOutputs; i++) {
917 if (results[i] < m_pRanges[i * 2]) { 955 if (results[i] < m_pRanges[i * 2]) {
918 results[i] = m_pRanges[i * 2]; 956 results[i] = m_pRanges[i * 2];
919 } else if (results[i] > m_pRanges[i * 2 + 1]) { 957 } else if (results[i] > m_pRanges[i * 2 + 1]) {
920 results[i] = m_pRanges[i * 2 + 1]; 958 results[i] = m_pRanges[i * 2 + 1];
921 } 959 }
922 } 960 }
923 } 961 }
924 return TRUE; 962 return TRUE;
925 } 963 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698