Newer
Older
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
//
//
#pragma once
//
//
//
#include <stdint.h>
//
//
//
Allan MacKinnon
committed
#ifdef __cplusplus
extern "C" {
#endif
//
//
//
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
struct ts_transform_stack;
//
//
//
#if 1
typedef float ts_transform_float_t;
#define TS_TRANSFORM_FLOAT_SUFFIX f
#else
typedef double ts_transform_float_t;
#define TS_TRANSFORM_FLOAT_SUFFIX
#endif
//
//
//
typedef uint64_t ts_transform_weakref_t;
#define TS_TRANSFORM_WEAKREF_INVALID UINT64_MAX;
//
//
//
typedef enum ts_transform_type
{
TS_TRANSFORM_TYPE_INVALID,
TS_TRANSFORM_TYPE_AFFINE,
TS_TRANSFORM_TYPE_PROJECTIVE
} ts_transform_type_e;
//
//
//
struct ts_transform_stack *
ts_transform_stack_create(const uint32_t size);
void
ts_transform_stack_release(struct ts_transform_stack * const ts);
//
//
//
uint32_t
ts_transform_stack_save(struct ts_transform_stack * const ts);
void
ts_transform_stack_restore(struct ts_transform_stack * const ts, uint32_t const restore);
//
//
//
ts_transform_float_t *
ts_transform_stack_top_transform(struct ts_transform_stack * const ts);
ts_transform_weakref_t *
ts_transform_stack_top_weakref(struct ts_transform_stack * const ts);
//
//
//
void
ts_transform_stack_dup(struct ts_transform_stack * const ts);
void
ts_transform_stack_drop(struct ts_transform_stack * const ts);
//
//
//
void
ts_transform_stack_transform_xy(struct ts_transform_stack * const ts,
ts_transform_float_t const x,
ts_transform_float_t const y,
ts_transform_float_t * const xp,
ts_transform_float_t * const yp);
//
//
//
void
ts_transform_stack_push_matrix(struct ts_transform_stack * const ts,
ts_transform_float_t const sx,
ts_transform_float_t const shx,
ts_transform_float_t const tx,
ts_transform_float_t const shy,
ts_transform_float_t const sy,
ts_transform_float_t const ty,
ts_transform_float_t const w0,
ts_transform_float_t const w1,
ts_transform_float_t const w2);
void
ts_transform_stack_push_identity(struct ts_transform_stack * const ts);
void
ts_transform_stack_push_affine(struct ts_transform_stack * const ts,
ts_transform_float_t const sx,
ts_transform_float_t const shx,
ts_transform_float_t const tx,
ts_transform_float_t const shy,
ts_transform_float_t const sy,
ts_transform_float_t const ty);
void
ts_transform_stack_push_translate(struct ts_transform_stack * const ts,
ts_transform_float_t const tx,
ts_transform_float_t const ty);
void
ts_transform_stack_push_scale(struct ts_transform_stack * const ts,
ts_transform_float_t const sx,
ts_transform_float_t const sy);
void
ts_transform_stack_push_shear(struct ts_transform_stack * const ts,
ts_transform_float_t const shx,
ts_transform_float_t const shy);
void
ts_transform_stack_push_skew_x(struct ts_transform_stack * const ts,
ts_transform_float_t const theta);
void
ts_transform_stack_push_skew_y(struct ts_transform_stack * const ts,
ts_transform_float_t const theta);
void
ts_transform_stack_push_rotate(struct ts_transform_stack * const ts,
ts_transform_float_t const theta);
void
ts_transform_stack_push_rotate_xy2(struct ts_transform_stack * const ts,
ts_transform_float_t const theta,
ts_transform_float_t const cx,
ts_transform_float_t const cy,
ts_transform_float_t const tx,
ts_transform_float_t const ty);
void
ts_transform_stack_push_rotate_xy(struct ts_transform_stack * const ts,
ts_transform_float_t const theta,
ts_transform_float_t const cx,
ts_transform_float_t const cy);
void
ts_transform_stack_push_rotate_scale_xy(struct ts_transform_stack * const ts,
ts_transform_float_t const theta,
ts_transform_float_t const sx,
ts_transform_float_t const sy,
ts_transform_float_t const cx,
ts_transform_float_t const cy);
//
// Quadrilateral coordinates are ts_transform_float_t2 structs:
//
// float2[4] = { xy0, xy1, xy2, xy3 }
//
// -or-
//
// float[8] = { x0, y0, x1, y1, x2, y2, x3, y3 };
//
ts_transform_type_e
ts_transform_stack_push_quad_to_unit(struct ts_transform_stack * const ts,
ts_transform_float_t const quad[8]);
ts_transform_type_e
ts_transform_stack_push_unit_to_quad(struct ts_transform_stack * const ts,
ts_transform_float_t const quad[8]);
ts_transform_type_e
ts_transform_stack_push_quad_to_quad(struct ts_transform_stack * const ts,
ts_transform_float_t const quad_src[8],
ts_transform_float_t const quad_dst[8]);
ts_transform_type_e
ts_transform_stack_push_rect_to_quad(struct ts_transform_stack * const ts,
ts_transform_float_t const x0,
ts_transform_float_t const y0,
ts_transform_float_t const x1,
ts_transform_float_t const y1,
ts_transform_float_t const quad_dst[8]);
//
// The second matrix on the stack (TOS[-1]) is post-multiplied by the
// top matrix on the stack (TOS[0]).
//
// The result replaces TOS[0] and TOS[-1] is unmodified.
//
// The stack effect of concat is:
//
// | B | | A*B |
// | A | | A |
// | . | => | . |
// | . | | . |
// | . | | . |
//
void
ts_transform_stack_concat(struct ts_transform_stack * const ts);
//
// The second matrix on the stack (TOS[-1]) is post-multiplied by the
// top matrix on the stack (TOS[0]).
//
// The result replaces both matrices.
//
// The stack effect of multiply is:
//
// | B | | A*B |
// | A | | . |
// | . | => | . |
// | . | | . |
// | . | | . |
//
void
ts_transform_stack_multiply(struct ts_transform_stack * const ts);
//
//
//
Allan MacKinnon
committed
#ifdef __cplusplus
}
#endif
//
//
//