Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_psengine.h
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef CORE_FPDFAPI_PAGE_CPDF_PSENGINE_H_
8#define CORE_FPDFAPI_PAGE_CPDF_PSENGINE_H_
9
10#include <stddef.h>
11#include <stdint.h>
12
13#include <memory>
14#include <vector>
15
16#include "core/fxcrt/bytestring.h"
17#include "third_party/base/containers/span.h"
18
19class CPDF_PSEngine;
20class CPDF_PSProc;
22
69
70class CPDF_PSOP {
71 public:
72 CPDF_PSOP();
73 explicit CPDF_PSOP(PDF_PSOP op);
74 explicit CPDF_PSOP(float value);
76
77 bool Parse(CPDF_SimpleParser* parser, int depth);
78 void Execute(CPDF_PSEngine* pEngine);
79 float GetFloatValue() const;
80 PDF_PSOP GetOp() const { return m_op; }
81
82 private:
83 const PDF_PSOP m_op;
84 const float m_value;
85 std::unique_ptr<CPDF_PSProc> m_proc;
86};
87
89 public:
92
93 bool Parse(CPDF_SimpleParser* parser, int depth);
94 bool Execute(CPDF_PSEngine* pEngine);
95
96 // These methods are exposed for testing.
97 void AddOperatorForTesting(ByteStringView word);
98 size_t num_operators() const { return m_Operators.size(); }
100 return m_Operators.back();
101 }
102
103 private:
104 static constexpr int kMaxDepth = 128;
105
106 void AddOperator(ByteStringView word);
107
108 std::vector<std::unique_ptr<CPDF_PSOP>> m_Operators;
109};
110
112 public:
115
116 bool Parse(pdfium::span<const uint8_t> input);
117 bool Execute();
118 bool DoOperator(PDF_PSOP op);
119 void Reset() { m_StackCount = 0; }
120 void Push(float value);
121 float Pop();
122 int PopInt();
123 uint32_t GetStackSize() const { return m_StackCount; }
124
125 private:
126 static constexpr uint32_t kPSEngineStackSize = 100;
127
128 uint32_t m_StackCount = 0;
129 CPDF_PSProc m_MainProc;
130 float m_Stack[kPSEngineStackSize] = {};
131};
132
133#endif // CORE_FPDFAPI_PAGE_CPDF_PSENGINE_H_
int GetIntegerFor(const ByteString &key) const
uint32_t m_nOutputs
uint32_t m_nInputs
virtual ~CPDF_Function()
bool Init(const CPDF_Object *pObj, VisitedSet *pVisited)
CPDF_Function(Type type)
const Type m_Type
absl::optional< uint32_t > Call(pdfium::span< const float > inputs, pdfium::span< float > results) const
float Interpolate(float x, float xmin, float xmax, float ymin, float ymax) const
RetainPtr< const CPDF_Dictionary > GetDict() const
const CPDF_Stream * AsStream() const
bool DoOperator(PDF_PSOP op)
bool Parse(pdfium::span< const uint8_t > input)
uint32_t GetStackSize() const
void Push(float value)
bool v_Init(const CPDF_Object *pObj, VisitedSet *pVisited) override
~CPDF_PSFunc() override
bool v_Call(pdfium::span< const float > inputs, pdfium::span< float > results) const override
void Execute(CPDF_PSEngine *pEngine)
PDF_PSOP GetOp() const
float GetFloatValue() const
bool Parse(CPDF_SimpleParser *parser, int depth)
CPDF_PSOP(float value)
CPDF_PSOP(PDF_PSOP op)
bool Execute(CPDF_PSEngine *pEngine)
size_t num_operators() const
const std::unique_ptr< CPDF_PSOP > & last_operator()
bool Parse(CPDF_SimpleParser *parser, int depth)
void AddOperatorForTesting(ByteStringView word)
PDF_PSOP
@ PSOP_COS
@ PSOP_FLOOR
@ PSOP_LT
@ PSOP_LOG
@ PSOP_DIV
@ PSOP_DUP
@ PSOP_GE
@ PSOP_NEG
@ PSOP_LN
@ PSOP_OR
@ PSOP_EQ
@ PSOP_MOD
@ PSOP_IDIV
@ PSOP_ATAN
@ PSOP_CVR
@ PSOP_SUB
@ PSOP_EXP
@ PSOP_ADD
@ PSOP_ROUND
@ PSOP_CONST
@ PSOP_IF
@ PSOP_NE
@ PSOP_PROC
@ PSOP_FALSE
@ PSOP_TRUE
@ PSOP_MUL
@ PSOP_ROLL
@ PSOP_AND
@ PSOP_GT
@ PSOP_CEILING
@ PSOP_POP
@ PSOP_EXCH
@ PSOP_BITSHIFT
@ PSOP_SQRT
@ PSOP_COPY
@ PSOP_IFELSE
@ PSOP_NOT
@ PSOP_ABS
@ PSOP_CVI
@ PSOP_SIN
@ PSOP_TRUNCATE
@ PSOP_XOR
@ PSOP_LE
@ PSOP_INDEX