| 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/src/fpdfapi/fpdf_page/pageint.h" | 7 #include "core/src/fpdfapi/fpdf_page/pageint.h" |
| 8 | 8 |
| 9 #include <limits.h> | 9 #include <limits.h> |
| 10 | 10 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 std::vector<std::unique_ptr<CPDF_PSOP>> m_Operators; | 113 std::vector<std::unique_ptr<CPDF_PSOP>> m_Operators; |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 const size_t PSENGINE_STACKSIZE = 100; | 116 const size_t PSENGINE_STACKSIZE = 100; |
| 117 | 117 |
| 118 class CPDF_PSEngine { | 118 class CPDF_PSEngine { |
| 119 public: | 119 public: |
| 120 CPDF_PSEngine(); | 120 CPDF_PSEngine(); |
| 121 ~CPDF_PSEngine(); | 121 ~CPDF_PSEngine(); |
| 122 | 122 |
| 123 FX_BOOL Parse(const FX_CHAR* string, int size); | 123 FX_BOOL Parse(const FX_CHAR* str, int size); |
| 124 FX_BOOL Execute() { return m_MainProc.Execute(this); } | 124 FX_BOOL Execute() { return m_MainProc.Execute(this); } |
| 125 FX_BOOL DoOperator(PDF_PSOP op); | 125 FX_BOOL DoOperator(PDF_PSOP op); |
| 126 void Reset() { m_StackCount = 0; } | 126 void Reset() { m_StackCount = 0; } |
| 127 void Push(FX_FLOAT value); | 127 void Push(FX_FLOAT value); |
| 128 void Push(int value) { Push((FX_FLOAT)value); } | 128 void Push(int value) { Push((FX_FLOAT)value); } |
| 129 FX_FLOAT Pop(); | 129 FX_FLOAT Pop(); |
| 130 int GetStackSize() const { return m_StackCount; } | 130 int GetStackSize() const { return m_StackCount; } |
| 131 | 131 |
| 132 private: | 132 private: |
| 133 FX_FLOAT m_Stack[PSENGINE_STACKSIZE]; | 133 FX_FLOAT m_Stack[PSENGINE_STACKSIZE]; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 {"ge", PSOP_GE}, {"lt", PSOP_LT}, | 200 {"ge", PSOP_GE}, {"lt", PSOP_LT}, |
| 201 {"le", PSOP_LE}, {"and", PSOP_AND}, | 201 {"le", PSOP_LE}, {"and", PSOP_AND}, |
| 202 {"or", PSOP_OR}, {"xor", PSOP_XOR}, | 202 {"or", PSOP_OR}, {"xor", PSOP_XOR}, |
| 203 {"not", PSOP_NOT}, {"bitshift", PSOP_BITSHIFT}, | 203 {"not", PSOP_NOT}, {"bitshift", PSOP_BITSHIFT}, |
| 204 {"true", PSOP_TRUE}, {"false", PSOP_FALSE}, | 204 {"true", PSOP_TRUE}, {"false", PSOP_FALSE}, |
| 205 {"if", PSOP_IF}, {"ifelse", PSOP_IFELSE}, | 205 {"if", PSOP_IF}, {"ifelse", PSOP_IFELSE}, |
| 206 {"pop", PSOP_POP}, {"exch", PSOP_EXCH}, | 206 {"pop", PSOP_POP}, {"exch", PSOP_EXCH}, |
| 207 {"dup", PSOP_DUP}, {"copy", PSOP_COPY}, | 207 {"dup", PSOP_DUP}, {"copy", PSOP_COPY}, |
| 208 {"index", PSOP_INDEX}, {"roll", PSOP_ROLL}}; | 208 {"index", PSOP_INDEX}, {"roll", PSOP_ROLL}}; |
| 209 | 209 |
| 210 FX_BOOL CPDF_PSEngine::Parse(const FX_CHAR* string, int size) { | 210 FX_BOOL CPDF_PSEngine::Parse(const FX_CHAR* str, int size) { |
| 211 CPDF_SimpleParser parser((uint8_t*)string, size); | 211 CPDF_SimpleParser parser((uint8_t*)str, size); |
| 212 CFX_ByteStringC word = parser.GetWord(); | 212 CFX_ByteStringC word = parser.GetWord(); |
| 213 if (word != "{") { | 213 if (word != "{") { |
| 214 return FALSE; | 214 return FALSE; |
| 215 } | 215 } |
| 216 return m_MainProc.Parse(&parser); | 216 return m_MainProc.Parse(&parser); |
| 217 } | 217 } |
| 218 FX_BOOL CPDF_PSProc::Parse(CPDF_SimpleParser* parser) { | 218 FX_BOOL CPDF_PSProc::Parse(CPDF_SimpleParser* parser) { |
| 219 while (1) { | 219 while (1) { |
| 220 CFX_ByteStringC word = parser->GetWord(); | 220 CFX_ByteStringC word = parser->GetWord(); |
| 221 if (word.IsEmpty()) { | 221 if (word.IsEmpty()) { |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 for (int i = 0; i < m_nOutputs; i++) { | 954 for (int i = 0; i < m_nOutputs; i++) { |
| 955 if (results[i] < m_pRanges[i * 2]) { | 955 if (results[i] < m_pRanges[i * 2]) { |
| 956 results[i] = m_pRanges[i * 2]; | 956 results[i] = m_pRanges[i * 2]; |
| 957 } else if (results[i] > m_pRanges[i * 2 + 1]) { | 957 } else if (results[i] > m_pRanges[i * 2 + 1]) { |
| 958 results[i] = m_pRanges[i * 2 + 1]; | 958 results[i] = m_pRanges[i * 2 + 1]; |
| 959 } | 959 } |
| 960 } | 960 } |
| 961 } | 961 } |
| 962 return TRUE; | 962 return TRUE; |
| 963 } | 963 } |
| OLD | NEW |