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

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: 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 #include <math.h>
10 11
11 #include <memory> 12 #include <memory>
13 #include <utility>
12 #include <vector> 14 #include <vector>
13 15
14 #include "core/include/fpdfapi/fpdf_module.h" 16 #include "core/include/fpdfapi/fpdf_module.h"
15 #include "core/include/fpdfapi/fpdf_page.h" 17 #include "core/include/fpdfapi/fpdf_page.h"
16 #include "core/include/fxcrt/fx_safe_types.h" 18 #include "core/include/fxcrt/fx_safe_types.h"
17 #include "third_party/base/numerics/safe_conversions_impl.h" 19 #include "third_party/base/numerics/safe_conversions_impl.h"
18 20
19 class CPDF_PSEngine; 21 enum PDF_PSOP {
20 typedef enum {
21 PSOP_ADD, 22 PSOP_ADD,
22 PSOP_SUB, 23 PSOP_SUB,
23 PSOP_MUL, 24 PSOP_MUL,
24 PSOP_DIV, 25 PSOP_DIV,
25 PSOP_IDIV, 26 PSOP_IDIV,
26 PSOP_MOD, 27 PSOP_MOD,
27 PSOP_NEG, 28 PSOP_NEG,
28 PSOP_ABS, 29 PSOP_ABS,
29 PSOP_CEILING, 30 PSOP_CEILING,
30 PSOP_FLOOR, 31 PSOP_FLOOR,
(...skipping 24 matching lines...) Expand all
55 PSOP_IF, 56 PSOP_IF,
56 PSOP_IFELSE, 57 PSOP_IFELSE,
57 PSOP_POP, 58 PSOP_POP,
58 PSOP_EXCH, 59 PSOP_EXCH,
59 PSOP_DUP, 60 PSOP_DUP,
60 PSOP_COPY, 61 PSOP_COPY,
61 PSOP_INDEX, 62 PSOP_INDEX,
62 PSOP_ROLL, 63 PSOP_ROLL,
63 PSOP_PROC, 64 PSOP_PROC,
64 PSOP_CONST 65 PSOP_CONST
65 } PDF_PSOP; 66 };
67
68 class CPDF_PSEngine;
69 class CPDF_PSProc;
70
71 class CPDF_PSOP {
72 public:
73 enum Type { TYPE_GENERIC, TYPE_CONST, TYPE_PROC };
74
75 explicit CPDF_PSOP(PDF_PSOP op) : m_op(op) {}
76 virtual ~CPDF_PSOP() {}
77
78 virtual Type GetType() const { return TYPE_GENERIC; }
79 virtual FX_FLOAT GetFloatValue() const {
80 ASSERT(false);
81 return 0;
82 }
83 virtual CPDF_PSProc* GetProc() const {
84 ASSERT(false);
85 return nullptr;
86 }
87
88 PDF_PSOP GetOp() const { return m_op; }
89
90 private:
91 const PDF_PSOP m_op;
92 };
93
94 class CPDF_PSOP_Const : public CPDF_PSOP {
95 public:
96 explicit CPDF_PSOP_Const(FX_FLOAT value)
97 : CPDF_PSOP(PSOP_CONST), m_value(value) {}
98 ~CPDF_PSOP_Const() override {}
99
100 Type GetType() const override { return TYPE_CONST; }
101 FX_FLOAT GetFloatValue() const override { return m_value; }
102
103 private:
104 const FX_FLOAT m_value;
105 };
106
107 class CPDF_PSOP_Proc : public CPDF_PSOP {
108 public:
109 explicit CPDF_PSOP_Proc(std::unique_ptr<CPDF_PSProc> proc)
110 : CPDF_PSOP(PSOP_PROC), m_proc(std::move(proc)) {}
111 ~CPDF_PSOP_Proc() override {}
112
113 Type GetType() const override { return TYPE_PROC; }
114 CPDF_PSProc* GetProc() const override { return m_proc.get(); }
115
116 private:
117 std::unique_ptr<CPDF_PSProc> m_proc;
118 };
119
66 class CPDF_PSProc { 120 class CPDF_PSProc {
67 public: 121 public:
68 ~CPDF_PSProc(); 122 CPDF_PSProc() {}
69 FX_BOOL Parse(CPDF_SimpleParser& parser); 123 ~CPDF_PSProc() {}
124
125 FX_BOOL Parse(CPDF_SimpleParser* parser);
70 FX_BOOL Execute(CPDF_PSEngine* pEngine); 126 FX_BOOL Execute(CPDF_PSEngine* pEngine);
71 std::vector<void*> m_Operators; 127
128 private:
129 std::vector<std::unique_ptr<CPDF_PSOP>> m_Operators;
72 }; 130 };
73 #define PSENGINE_STACKSIZE 100 131
132 const size_t PSENGINE_STACKSIZE = 100;
133
74 class CPDF_PSEngine { 134 class CPDF_PSEngine {
75 public: 135 public:
76 CPDF_PSEngine(); 136 CPDF_PSEngine();
77 ~CPDF_PSEngine(); 137 ~CPDF_PSEngine();
138
78 FX_BOOL Parse(const FX_CHAR* string, int size); 139 FX_BOOL Parse(const FX_CHAR* string, int size);
79 FX_BOOL Execute() { return m_MainProc.Execute(this); } 140 FX_BOOL Execute() { return m_MainProc.Execute(this); }
80 FX_BOOL DoOperator(PDF_PSOP op); 141 FX_BOOL DoOperator(PDF_PSOP op);
81 void Reset() { m_StackCount = 0; } 142 void Reset() { m_StackCount = 0; }
82 void Push(FX_FLOAT value); 143 void Push(FX_FLOAT value);
83 void Push(int value) { Push((FX_FLOAT)value); } 144 void Push(int value) { Push((FX_FLOAT)value); }
84 FX_FLOAT Pop(); 145 FX_FLOAT Pop();
85 int GetStackSize() { return m_StackCount; } 146 int GetStackSize() const { return m_StackCount; }
86 147
87 private: 148 private:
88 FX_FLOAT m_Stack[PSENGINE_STACKSIZE]; 149 FX_FLOAT m_Stack[PSENGINE_STACKSIZE];
89 int m_StackCount; 150 int m_StackCount;
90 CPDF_PSProc m_MainProc; 151 CPDF_PSProc m_MainProc;
91 }; 152 };
92 CPDF_PSProc::~CPDF_PSProc() { 153
93 for (size_t i = 0; i < m_Operators.size(); i++) { 154 FX_BOOL CPDF_PSProc::Execute(CPDF_PSEngine* pEngine) {
94 if (m_Operators[i] == (void*)PSOP_PROC) { 155 for (size_t i = 0; i < m_Operators.size(); ++i) {
95 delete (CPDF_PSProc*)m_Operators[i + 1]; 156 const CPDF_PSOP::Type type = m_Operators[i]->GetType();
96 i++; 157 if (type == CPDF_PSOP::TYPE_PROC)
97 } else if (m_Operators[i] == (void*)PSOP_CONST) { 158 continue;
98 FX_Free((FX_FLOAT*)m_Operators[i + 1]); 159
99 i++; 160 if (type == CPDF_PSOP::TYPE_CONST) {
161 pEngine->Push(m_Operators[i]->GetFloatValue());
162 continue;
100 } 163 }
101 } 164
102 } 165 const PDF_PSOP op = m_Operators[i]->GetOp();
103 FX_BOOL CPDF_PSProc::Execute(CPDF_PSEngine* pEngine) { 166 if (op == PSOP_IF) {
104 for (size_t i = 0; i < m_Operators.size(); i++) { 167 if (i == 0 || m_Operators[i - 1]->GetType() != CPDF_PSOP::TYPE_PROC)
105 PDF_PSOP op = (PDF_PSOP)(uintptr_t)m_Operators[i]; 168 return FALSE;
106 if (op == PSOP_PROC) { 169
107 i++; 170 if (static_cast<int>(pEngine->Pop()))
Tom Sepez 2016/02/11 01:44:55 Ok, just curious, so 0.9 is false ...
Lei Zhang 2016/02/11 02:22:52 PSOP_TRUE pushes in 1, and PSOP_FALSE pushes in 0.
108 } else if (op == PSOP_CONST) { 171 m_Operators[i - 1]->GetProc()->Execute(pEngine);
109 pEngine->Push(*(FX_FLOAT*)m_Operators[i + 1]); 172 } else if (op == PSOP_IFELSE) {
110 i++; 173 if (i < 2 || m_Operators[i - 1]->GetType() != CPDF_PSOP::TYPE_PROC ||
111 } else if (op == PSOP_IF) { 174 m_Operators[i - 2]->GetType() != CPDF_PSOP::TYPE_PROC) {
112 if (i < 2 || m_Operators[i - 2] != (void*)PSOP_PROC) {
113 return FALSE; 175 return FALSE;
114 } 176 }
115 if ((int)pEngine->Pop()) { 177 size_t offset = static_cast<int>(pEngine->Pop()) ? 2 : 1;
116 ((CPDF_PSProc*)m_Operators[i - 1])->Execute(pEngine); 178 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 { 179 } else {
129 pEngine->DoOperator(op); 180 pEngine->DoOperator(op);
130 } 181 }
131 } 182 }
132 return TRUE; 183 return TRUE;
133 } 184 }
185
134 CPDF_PSEngine::CPDF_PSEngine() { 186 CPDF_PSEngine::CPDF_PSEngine() {
135 m_StackCount = 0; 187 m_StackCount = 0;
136 } 188 }
137 CPDF_PSEngine::~CPDF_PSEngine() {} 189 CPDF_PSEngine::~CPDF_PSEngine() {}
138 void CPDF_PSEngine::Push(FX_FLOAT v) { 190 void CPDF_PSEngine::Push(FX_FLOAT v) {
139 if (m_StackCount == 100) { 191 if (m_StackCount == PSENGINE_STACKSIZE) {
140 return; 192 return;
141 } 193 }
142 m_Stack[m_StackCount++] = v; 194 m_Stack[m_StackCount++] = v;
143 } 195 }
144 FX_FLOAT CPDF_PSEngine::Pop() { 196 FX_FLOAT CPDF_PSEngine::Pop() {
145 if (m_StackCount == 0) { 197 if (m_StackCount == 0) {
146 return 0; 198 return 0;
147 } 199 }
148 return m_Stack[--m_StackCount]; 200 return m_Stack[--m_StackCount];
149 } 201 }
150 const struct _PDF_PSOpName { 202 const struct PDF_PSOpName {
Tom Sepez 2016/02/11 01:44:54 nit: put this up top in namespace { ???
Lei Zhang 2016/02/11 02:22:52 There is no anonymous namespace. I added one.
151 const FX_CHAR* name; 203 const FX_CHAR* name;
152 PDF_PSOP op; 204 PDF_PSOP op;
153 } _PDF_PSOpNames[] = {{"add", PSOP_ADD}, {"sub", PSOP_SUB}, 205 } PDF_PSOpNames[] = {{"add", PSOP_ADD}, {"sub", PSOP_SUB},
Tom Sepez 2016/02/11 01:44:54 This should be a std::map<char*, PSOP>. How to ma
Tom Sepez 2016/02/11 01:54:39 Actually, it probably ought to be a map from CFX_B
Lei Zhang 2016/02/11 02:22:52 Initialize one on first use? Or put them in order
154 {"mul", PSOP_MUL}, {"div", PSOP_DIV}, 206 {"mul", PSOP_MUL}, {"div", PSOP_DIV},
155 {"idiv", PSOP_IDIV}, {"mod", PSOP_MOD}, 207 {"idiv", PSOP_IDIV}, {"mod", PSOP_MOD},
156 {"neg", PSOP_NEG}, {"abs", PSOP_ABS}, 208 {"neg", PSOP_NEG}, {"abs", PSOP_ABS},
157 {"ceiling", PSOP_CEILING}, {"floor", PSOP_FLOOR}, 209 {"ceiling", PSOP_CEILING}, {"floor", PSOP_FLOOR},
158 {"round", PSOP_ROUND}, {"truncate", PSOP_TRUNCATE}, 210 {"round", PSOP_ROUND}, {"truncate", PSOP_TRUNCATE},
159 {"sqrt", PSOP_SQRT}, {"sin", PSOP_SIN}, 211 {"sqrt", PSOP_SQRT}, {"sin", PSOP_SIN},
160 {"cos", PSOP_COS}, {"atan", PSOP_ATAN}, 212 {"cos", PSOP_COS}, {"atan", PSOP_ATAN},
161 {"exp", PSOP_EXP}, {"ln", PSOP_LN}, 213 {"exp", PSOP_EXP}, {"ln", PSOP_LN},
162 {"log", PSOP_LOG}, {"cvi", PSOP_CVI}, 214 {"log", PSOP_LOG}, {"cvi", PSOP_CVI},
163 {"cvr", PSOP_CVR}, {"eq", PSOP_EQ}, 215 {"cvr", PSOP_CVR}, {"eq", PSOP_EQ},
164 {"ne", PSOP_NE}, {"gt", PSOP_GT}, 216 {"ne", PSOP_NE}, {"gt", PSOP_GT},
165 {"ge", PSOP_GE}, {"lt", PSOP_LT}, 217 {"ge", PSOP_GE}, {"lt", PSOP_LT},
166 {"le", PSOP_LE}, {"and", PSOP_AND}, 218 {"le", PSOP_LE}, {"and", PSOP_AND},
167 {"or", PSOP_OR}, {"xor", PSOP_XOR}, 219 {"or", PSOP_OR}, {"xor", PSOP_XOR},
168 {"not", PSOP_NOT}, {"bitshift", PSOP_BITSHIFT}, 220 {"not", PSOP_NOT}, {"bitshift", PSOP_BITSHIFT},
169 {"true", PSOP_TRUE}, {"false", PSOP_FALSE}, 221 {"true", PSOP_TRUE}, {"false", PSOP_FALSE},
170 {"if", PSOP_IF}, {"ifelse", PSOP_IFELSE}, 222 {"if", PSOP_IF}, {"ifelse", PSOP_IFELSE},
171 {"pop", PSOP_POP}, {"exch", PSOP_EXCH}, 223 {"pop", PSOP_POP}, {"exch", PSOP_EXCH},
172 {"dup", PSOP_DUP}, {"copy", PSOP_COPY}, 224 {"dup", PSOP_DUP}, {"copy", PSOP_COPY},
173 {"index", PSOP_INDEX}, {"roll", PSOP_ROLL}, 225 {"index", PSOP_INDEX}, {"roll", PSOP_ROLL}};
174 {NULL, PSOP_PROC}}; 226
175 FX_BOOL CPDF_PSEngine::Parse(const FX_CHAR* string, int size) { 227 FX_BOOL CPDF_PSEngine::Parse(const FX_CHAR* string, int size) {
176 CPDF_SimpleParser parser((uint8_t*)string, size); 228 CPDF_SimpleParser parser((uint8_t*)string, size);
177 CFX_ByteStringC word = parser.GetWord(); 229 CFX_ByteStringC word = parser.GetWord();
178 if (word != "{") { 230 if (word != "{") {
179 return FALSE; 231 return FALSE;
180 } 232 }
181 return m_MainProc.Parse(parser); 233 return m_MainProc.Parse(&parser);
182 } 234 }
183 FX_BOOL CPDF_PSProc::Parse(CPDF_SimpleParser& parser) { 235 FX_BOOL CPDF_PSProc::Parse(CPDF_SimpleParser* parser) {
184 while (1) { 236 while (1) {
185 CFX_ByteStringC word = parser.GetWord(); 237 CFX_ByteStringC word = parser->GetWord();
186 if (word.IsEmpty()) { 238 if (word.IsEmpty()) {
187 return FALSE; 239 return FALSE;
188 } 240 }
189 if (word == "}") { 241 if (word == "}") {
190 return TRUE; 242 return TRUE;
191 } 243 }
192 if (word == "{") { 244 if (word == "{") {
193 CPDF_PSProc* pProc = new CPDF_PSProc; 245 CPDF_PSProc* pProc = new CPDF_PSProc;
Tom Sepez 2016/02/11 01:44:54 nit: if pProc is the unique ptr itself, we can jus
Lei Zhang 2016/02/11 02:22:52 Done.
194 m_Operators.push_back((void*)PSOP_PROC); 246 m_Operators.push_back(std::unique_ptr<CPDF_PSOP>(
195 m_Operators.push_back(pProc); 247 new CPDF_PSOP_Proc(std::unique_ptr<CPDF_PSProc>(pProc))));
196 if (!pProc->Parse(parser)) { 248 if (!pProc->Parse(parser)) {
197 return FALSE; 249 return FALSE;
198 } 250 }
199 } else { 251 } else {
200 int i = 0; 252 bool found = false;
201 while (_PDF_PSOpNames[i].name) { 253 for (size_t i = 0; i < FX_ArraySize(PDF_PSOpNames); ++i) {
Tom Sepez 2016/02/11 01:44:54 Do range-based for loops work for POD arrays? f
Lei Zhang 2016/02/11 02:22:52 It works.
202 if (word == CFX_ByteStringC(_PDF_PSOpNames[i].name)) { 254 if (word == CFX_ByteStringC(PDF_PSOpNames[i].name)) {
203 m_Operators.push_back((void*)_PDF_PSOpNames[i].op); 255 m_Operators.push_back(
256 std::unique_ptr<CPDF_PSOP>(new CPDF_PSOP(PDF_PSOpNames[i].op)));
257 found = true;
204 break; 258 break;
205 } 259 }
206 i++;
207 } 260 }
208 if (!_PDF_PSOpNames[i].name) { 261 if (!found) {
209 FX_FLOAT* pd = FX_Alloc(FX_FLOAT, 1); 262 FX_FLOAT pd = FX_atof(word);
Tom Sepez 2016/02/11 01:44:54 nit: local not needed, maybe looks better if we ha
Lei Zhang 2016/02/11 02:22:52 Done.
210 *pd = FX_atof(word); 263 m_Operators.push_back(
211 m_Operators.push_back((void*)PSOP_CONST); 264 std::unique_ptr<CPDF_PSOP>(new CPDF_PSOP_Const(pd)));
212 m_Operators.push_back(pd);
213 } 265 }
214 } 266 }
215 } 267 }
216 } 268 }
217 #define PI 3.1415926535897932384626433832795f 269
218 FX_BOOL CPDF_PSEngine::DoOperator(PDF_PSOP op) { 270 FX_BOOL CPDF_PSEngine::DoOperator(PDF_PSOP op) {
219 int i1, i2; 271 int i1, i2;
220 FX_FLOAT d1, d2; 272 FX_FLOAT d1, d2;
221 switch (op) { 273 switch (op) {
222 case PSOP_ADD: 274 case PSOP_ADD:
223 d1 = Pop(); 275 d1 = Pop();
224 d2 = Pop(); 276 d2 = Pop();
225 Push(d1 + d2); 277 Push(d1 + d2);
226 break; 278 break;
227 case PSOP_SUB: 279 case PSOP_SUB:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 case PSOP_TRUNCATE: 324 case PSOP_TRUNCATE:
273 i1 = (int)Pop(); 325 i1 = (int)Pop();
274 Push(i1); 326 Push(i1);
275 break; 327 break;
276 case PSOP_SQRT: 328 case PSOP_SQRT:
277 d1 = Pop(); 329 d1 = Pop();
278 Push((FX_FLOAT)FXSYS_sqrt(d1)); 330 Push((FX_FLOAT)FXSYS_sqrt(d1));
279 break; 331 break;
280 case PSOP_SIN: 332 case PSOP_SIN:
281 d1 = Pop(); 333 d1 = Pop();
282 Push((FX_FLOAT)FXSYS_sin(d1 * PI / 180.0f)); 334 Push((FX_FLOAT)FXSYS_sin(d1 * M_PI / 180.0f));
283 break; 335 break;
284 case PSOP_COS: 336 case PSOP_COS:
285 d1 = Pop(); 337 d1 = Pop();
286 Push((FX_FLOAT)FXSYS_cos(d1 * PI / 180.0f)); 338 Push((FX_FLOAT)FXSYS_cos(d1 * M_PI / 180.0f));
287 break; 339 break;
288 case PSOP_ATAN: 340 case PSOP_ATAN:
289 d2 = Pop(); 341 d2 = Pop();
290 d1 = Pop(); 342 d1 = Pop();
291 d1 = (FX_FLOAT)(FXSYS_atan2(d1, d2) * 180.0 / PI); 343 d1 = (FX_FLOAT)(FXSYS_atan2(d1, d2) * 180.0 / M_PI);
292 if (d1 < 0) { 344 if (d1 < 0) {
293 d1 += 360; 345 d1 += 360;
294 } 346 }
295 Push(d1); 347 Push(d1);
296 break; 348 break;
297 case PSOP_EXP: 349 case PSOP_EXP:
298 d2 = Pop(); 350 d2 = Pop();
299 d1 = Pop(); 351 d1 = Pop();
300 Push((FX_FLOAT)FXSYS_pow(d1, d2)); 352 Push((FX_FLOAT)FXSYS_pow(d1, d2));
301 break; 353 break;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 466 }
415 case PSOP_ROLL: { 467 case PSOP_ROLL: {
416 int j = (int)Pop(); 468 int j = (int)Pop();
417 int n = (int)Pop(); 469 int n = (int)Pop();
418 if (m_StackCount == 0) { 470 if (m_StackCount == 0) {
419 break; 471 break;
420 } 472 }
421 if (n < 0 || n > m_StackCount) { 473 if (n < 0 || n > m_StackCount) {
422 break; 474 break;
423 } 475 }
424 if (j < 0) 476 if (j < 0) {
425 for (int i = 0; i < -j; i++) { 477 for (int i = 0; i < -j; i++) {
426 FX_FLOAT first = m_Stack[m_StackCount - n]; 478 FX_FLOAT first = m_Stack[m_StackCount - n];
427 for (int ii = 0; ii < n - 1; ii++) { 479 for (int ii = 0; ii < n - 1; ii++) {
428 m_Stack[m_StackCount - n + ii] = m_Stack[m_StackCount - n + ii + 1]; 480 m_Stack[m_StackCount - n + ii] = m_Stack[m_StackCount - n + ii + 1];
429 } 481 }
430 m_Stack[m_StackCount - 1] = first; 482 m_Stack[m_StackCount - 1] = first;
431 } 483 }
432 else 484 } else {
433 for (int i = 0; i < j; i++) { 485 for (int i = 0; i < j; i++) {
434 FX_FLOAT last = m_Stack[m_StackCount - 1]; 486 FX_FLOAT last = m_Stack[m_StackCount - 1];
435 int ii; 487 int ii;
436 for (ii = 0; ii < n - 1; ii++) { 488 for (ii = 0; ii < n - 1; ii++) {
437 m_Stack[m_StackCount - ii - 1] = m_Stack[m_StackCount - ii - 2]; 489 m_Stack[m_StackCount - ii - 1] = m_Stack[m_StackCount - ii - 2];
438 } 490 }
439 m_Stack[m_StackCount - ii - 1] = last; 491 m_Stack[m_StackCount - ii - 1] = last;
440 } 492 }
493 }
441 break; 494 break;
442 } 495 }
443 default: 496 default:
444 break; 497 break;
445 } 498 }
446 return TRUE; 499 return TRUE;
447 } 500 }
448 static FX_FLOAT PDF_Interpolate(FX_FLOAT x, 501 static FX_FLOAT PDF_Interpolate(FX_FLOAT x,
449 FX_FLOAT xmin, 502 FX_FLOAT xmin,
450 FX_FLOAT xmax, 503 FX_FLOAT xmax,
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 for (int i = 0; i < m_nOutputs; i++) { 969 for (int i = 0; i < m_nOutputs; i++) {
917 if (results[i] < m_pRanges[i * 2]) { 970 if (results[i] < m_pRanges[i * 2]) {
918 results[i] = m_pRanges[i * 2]; 971 results[i] = m_pRanges[i * 2];
919 } else if (results[i] > m_pRanges[i * 2 + 1]) { 972 } else if (results[i] > m_pRanges[i * 2 + 1]) {
920 results[i] = m_pRanges[i * 2 + 1]; 973 results[i] = m_pRanges[i * 2 + 1];
921 } 974 }
922 } 975 }
923 } 976 }
924 return TRUE; 977 return TRUE;
925 } 978 }
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