summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qpdf/xpdf/Function.h
Unidiff
Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/Function.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/qpdf/xpdf/Function.h181
1 files changed, 181 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/xpdf/Function.h b/noncore/unsupported/qpdf/xpdf/Function.h
new file mode 100644
index 0000000..a223359
--- a/dev/null
+++ b/noncore/unsupported/qpdf/xpdf/Function.h
@@ -0,0 +1,181 @@
1//========================================================================
2//
3// Function.h
4//
5// Copyright 2001 Derek B. Noonburg
6//
7//========================================================================
8
9#ifndef FUNCTION_H
10#define FUNCTION_H
11
12#ifdef __GNUC__
13#pragma interface
14#endif
15
16#include "gtypes.h"
17#include "Object.h"
18
19class Dict;
20class Stream;
21struct PSObject;
22class PSStack;
23
24//------------------------------------------------------------------------
25// Function
26//------------------------------------------------------------------------
27
28#define funcMaxInputs 8
29#define funcMaxOutputs 8
30
31class Function {
32public:
33
34 Function();
35
36 virtual ~Function();
37
38 // Construct a function. Returns NULL if unsuccessful.
39 static Function *parse(Object *funcObj);
40
41 // Initialize the entries common to all function types.
42 GBool init(Dict *dict);
43
44 virtual Function *copy() = 0;
45
46 // Return size of input and output tuples.
47 int getInputSize() { return m; }
48 int getOutputSize() { return n; }
49
50 // Transform an input tuple into an output tuple.
51 virtual void transform(fouble *in, fouble *out) = 0;
52
53 virtual GBool isOk() = 0;
54
55protected:
56
57 int m, n; // size of input and output tuples
58 fouble // min and max values for function domain
59 domain[funcMaxInputs][2];
60 fouble // min and max values for function range
61 range[funcMaxOutputs][2];
62 GBool hasRange; // set if range is defined
63};
64
65//------------------------------------------------------------------------
66// IdentityFunction
67//------------------------------------------------------------------------
68
69class IdentityFunction: public Function {
70public:
71
72 IdentityFunction();
73 virtual ~IdentityFunction();
74 virtual Function *copy() { return new IdentityFunction(); }
75 virtual void transform(fouble *in, fouble *out);
76 virtual GBool isOk() { return gTrue; }
77
78private:
79};
80
81//------------------------------------------------------------------------
82// SampledFunction
83//------------------------------------------------------------------------
84
85class SampledFunction: public Function {
86public:
87
88 SampledFunction(Object *funcObj, Dict *dict);
89 virtual ~SampledFunction();
90 virtual Function *copy() { return new SampledFunction(this); }
91 virtual void transform(fouble *in, fouble *out);
92 virtual GBool isOk() { return ok; }
93
94private:
95
96 SampledFunction(SampledFunction *func);
97
98 int // number of samples for each domain element
99 sampleSize[funcMaxInputs];
100 fouble // min and max values for domain encoder
101 encode[funcMaxInputs][2];
102 fouble // min and max values for range decoder
103 decode[funcMaxOutputs][2];
104 fouble *samples; // the samples
105 GBool ok;
106};
107
108//------------------------------------------------------------------------
109// ExponentialFunction
110//------------------------------------------------------------------------
111
112class ExponentialFunction: public Function {
113public:
114
115 ExponentialFunction(Object *funcObj, Dict *dict);
116 virtual ~ExponentialFunction();
117 virtual Function *copy() { return new ExponentialFunction(this); }
118 virtual void transform(fouble *in, fouble *out);
119 virtual GBool isOk() { return ok; }
120
121private:
122
123 ExponentialFunction(ExponentialFunction *func);
124
125 fouble c0[funcMaxOutputs];
126 fouble c1[funcMaxOutputs];
127 fouble e;
128 GBool ok;
129};
130
131//------------------------------------------------------------------------
132// StitchingFunction
133//------------------------------------------------------------------------
134
135class StitchingFunction: public Function {
136public:
137
138 StitchingFunction(Object *funcObj, Dict *dict);
139 virtual ~StitchingFunction();
140 virtual Function *copy() { return new StitchingFunction(this); }
141 virtual void transform(fouble *in, fouble *out);
142 virtual GBool isOk() { return ok; }
143
144private:
145
146 StitchingFunction(StitchingFunction *func);
147
148 int k;
149 Function **funcs;
150 fouble *bounds;
151 fouble *encode;
152 GBool ok;
153};
154
155//------------------------------------------------------------------------
156// PostScriptFunction
157//------------------------------------------------------------------------
158
159class PostScriptFunction: public Function {
160public:
161
162 PostScriptFunction(Object *funcObj, Dict *dict);
163 virtual ~PostScriptFunction();
164 virtual Function *copy() { return new PostScriptFunction(this); }
165 virtual void transform(fouble *in, fouble *out);
166 virtual GBool isOk() { return ok; }
167
168private:
169
170 PostScriptFunction(PostScriptFunction *func);
171 GBool parseCode(Stream *str, int *codePtr);
172 GString *getToken(Stream *str);
173 void resizeCode(int newSize);
174 void exec(PSStack *stack, int codePtr);
175
176 PSObject *code;
177 int codeSize;
178 GBool ok;
179};
180
181#endif