Select one of the symbols to view example projects that use it.
 
Outline
#define TEXTUREMAPTYPES_HPP
#include <touchgfx/hal/Types.hpp>
touchgfx
Files
loading...
CodeScopeSTM32 Libraries and SamplesTouchGFXtouchgfx/framework/include/touchgfx/TextureMapTypes.hpp
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * This file is part of the TouchGFX 4.10.0 distribution. * * <h2><center>&copy; Copyright (c) 2018 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under Ultimate Liberty license * SLA0044, the "License"; You may not use this file except in compliance with * the License. You may obtain a copy of the License at: * www.st.com/SLA0044 * ****************************************************************************** *//* ... */ #ifndef TEXTUREMAPTYPES_HPP #define TEXTUREMAPTYPES_HPP #include <touchgfx/hal/Types.hpp> namespace touchgfx { /** * @struct Gradients TextureMapTypes.hpp touchgfx/TextureMapTypes.hpp * * @brief Gradients contains all the data to interpolate u,v texture coordinates and z coordinates * across a planar surface. *//* ... */ struct Gradients { /** * @fn Gradients(const Point3D* vertices); * * @brief Constructor. Construct the gradients using 3 3D vertices. * * @param vertices The vertices. * * @see Point3D *//* ... */ Gradients(const Point3D* vertices); float oneOverZ[3]; ///< 1/z for each vertex float UOverZ[3]; ///< u/z for each vertex float VOverZ[3]; ///< v/z for each vertex float dOneOverZdX; ///< d(1/z)/dX float dOneOverZdY; ///< d(1/z)/dY float dUOverZdX; ///< d(u/z)/dX float dUOverZdY; ///< d(u/z)/dY float dVOverZdX; ///< d(v/z)/dX float dVOverZdY; ///< d(v/z)/dY fixed16_16 dUdXModifier; ///< The dUdX x coordinate modifier fixed16_16 dVdXModifier; ///< The dVdX x coordinate modifier ...}; /** * @struct Edge TextureMapTypes.hpp touchgfx/TextureMapTypes.hpp * * @brief An edge contains information about one edge, between two points, of a triangle, as well * as information about how to interpolate values when moving in the vertical direction. *//* ... */ struct Edge { /** * @fn Edge(const Gradients& gradients, const Point3D* vertices, int top, int bottom); * * @brief Constructor. * * Construct the edge between two vertices and using the gradients for calculating * the interpolation values. * * @param gradients The gradients for the triangle. * @param vertices The vertices for the triangle. * @param top The index in the vertices array of the top vertex of this edge. * @param bottom The index in the vertices array of the bottom vertex of this edge. *//* ... */ Edge(const Gradients& gradients, const Point3D* vertices, int top, int bottom); /** * @fn inline int step() * * @brief Perform a step along the edge. * * Perform a step along the edge. * * @return the Height. *//* ... */ inline int step() { X += XStep; Y++; height--; UOverZ += UOverZStep; VOverZ += VOverZStep; oneOverZ += oneOverZStep; errorTerm += numerator; if (errorTerm >= denominator) { X++; errorTerm -= denominator; oneOverZ += oneOverZStepExtra; UOverZ += UOverZStepExtra; VOverZ += VOverZStepExtra; }if (errorTerm >= denominator) { ... } return height; }{ ... } /** * @fn inline int step(int steps) * * @brief Performs a number of steps along the edge. * * Performs a number of steps along the edge. * * @param steps The number of steps the perform. * * @return height. *//* ... */ inline int step(int steps) { for (int i = 0; i < steps; i++) { step(); }for (int i = 0; i < steps; i++) { ... } return height; }{ ... } int32_t X; ///< The X coordinate int32_t XStep; ///< Amount to increment x int32_t numerator; ///< The numerator int32_t denominator; ///< The denominator int32_t errorTerm; ///< The error term int Y; ///< The Y coordinate int height; ///< The height float oneOverZ; ///< The one over z coordinate float oneOverZStep; ///< The one over z coordinate step float oneOverZStepExtra; ///< The one over z coordinate step extra float UOverZ; ///< The over z coordinate float UOverZStep; ///< The over z coordinate step float UOverZStepExtra; ///< The over z coordinate step extra float VOverZ; ///< The over z coordinate float VOverZStep; ///< The over z coordinate step float VOverZStepExtra; ///< The over z coordinate step extra ...}; /** * @fn inline float fixed28_4ToFloat(fixed28_4 value) * * @brief Fixed 28 4 to float. * * @param value The value. * * @return The value as float. *//* ... */ inline float fixed28_4ToFloat(fixed28_4 value) { return value / 16.0f; }{ ... } /** * @fn inline fixed28_4 floatToFixed28_4(float value) * * @brief Float to fixed 28 4. * * @param value The value. * * @return The value as fixed28_4. *//* ... */ inline fixed28_4 floatToFixed28_4(float value) { return (fixed28_4)(value * 16); }{ ... } /** * @fn inline fixed16_16 floatToFixed16_16(float value) * * @brief Float to fixed 16. * * @param value The value. * * @return The value as fixed16_16. *//* ... */ inline fixed16_16 floatToFixed16_16(float value) { return (fixed16_16)(value * 65536); }{ ... } /** * @fn inline fixed28_4 fixed28_4Mul(fixed28_4 a, fixed28_4 b) * * @brief Fixed 28 4 mul. * * @param a The fixed28_4 to process. * @param b The fixed28_4 to process. * * @return the result. *//* ... */ inline fixed28_4 fixed28_4Mul(fixed28_4 a, fixed28_4 b) { if (a == 0 || b == 0) { return 0; }if (a == 0 || b == 0) { ... } if ((a * b) / b == a) { return (a * b) / 16; }if ((a * b) / b == a) { ... } // Rewrite "b = max_b * num_max_b + rem_b" so that a * max_b does not overflow. int sign = 1; if (b < 0) { sign = -sign; b = -b; }if (b < 0) { ... } if (a < 0) { sign = -sign; a = -a; }if (a < 0) { ... } if (a < b) { fixed28_4 tmp = a; a = b; b = tmp; }if (a < b) { ... } int32_t max_b = 0x7FFFFFFF / a; // Max b value that can be multiplied with a without overflow int32_t num_max_b = b / max_b; // How many times do we have to multiply with "max_b" to get to "b" int32_t rem_b = b - max_b * num_max_b; // plus some remainder. int32_t max_prod = a * max_b; int32_t result = sign * (num_max_b * (max_prod / 16) + (num_max_b * (max_prod % 16) + rem_b * a) / 16); return result; }{ ... } /** * @fn inline int32_t ceil28_4(fixed28_4 value) * * @brief Ceiling 28 4. * * @param value The value. * * @return The ceil result. *//* ... */ inline int32_t ceil28_4(fixed28_4 value) { int32_t returnValue; int32_t numerator = value - 1 + 16; if (numerator >= 0) { returnValue = numerator / 16; }if (numerator >= 0) { ... } else { // deal with negative numerators correctly returnValue = -((-numerator) / 16); returnValue -= ((-numerator) % 16) ? 1 : 0; }else { ... } return returnValue; }{ ... } /** * @fn inline void floorDivMod(int32_t numerator, int32_t denominator, int32_t& floor, int32_t& mod) * * @brief Floor div modifier. * * @param numerator The numerator. * @param denominator The denominator. * @param [in,out] floor The floor. * @param [in,out] mod The modifier. *//* ... */ inline void floorDivMod(int32_t numerator, int32_t denominator, int32_t& floor, int32_t& mod) { assert(denominator > 0); // we assume it's positive if (numerator >= 0) { // positive case, C is okay floor = numerator / denominator; mod = numerator % denominator; }if (numerator >= 0) { ... } else { // Numerator is negative, do the right thing floor = -((-numerator) / denominator); mod = (-numerator) % denominator; if (mod) { // there is a remainder floor--; mod = denominator - mod; }if (mod) { ... } }else { ... } }{ ... } }... //namespace touchgfx /* ... */ #endif // TEXTUREMAPTYPES_HPP