aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compute/ts/transform_stack.h
blob: 275f529db55c04b2d282d1dc784ed15ab22e7a68 (plain)
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
/*
 * Copyright 2018 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can
 * be found in the LICENSE file.
 *
 */

//
//
//

#pragma once

//
//
//

#include <skc/skc.h>

//
//
//

#if 1
typedef float  skc_transform_float_t;
#define SKC_TRANSFORM_FLOAT_SUFFIX f
#else
typedef double skc_transform_float_t;
#define SKC_TRANSFORM_FLOAT_SUFFIX
#endif

//
//
//

struct skc_transform_stack;

//
//
//

struct skc_transform_stack *
skc_transform_stack_create(const uint32_t size);

void
skc_transform_stack_release(struct skc_transform_stack * const ts);

//
//
//

uint32_t
skc_transform_stack_save(struct skc_transform_stack * const ts);

void
skc_transform_stack_restore(struct skc_transform_stack * const ts, uint32_t const restore);

//
//
//

skc_transform_float_t *
skc_transform_stack_top_transform(struct skc_transform_stack * const ts);

skc_transform_weakref_t *
skc_transform_stack_top_weakref(struct skc_transform_stack * const ts);

//
//
//

void 
skc_transform_stack_drop(struct skc_transform_stack * const ts);

void 
skc_transform_stack_dup(struct skc_transform_stack * const ts);

//
//
//

void 
skc_transform_stack_transform_affine(struct skc_transform_stack * const ts,
                                     skc_transform_float_t        const x_pre,  
                                     skc_transform_float_t        const y_pre,
                                     skc_transform_float_t      * const x_post, 
                                     skc_transform_float_t      * const y_post);

//
//
//

void
skc_transform_stack_push_matrix(struct skc_transform_stack * const ts,
                                skc_transform_float_t        const sx, 
                                skc_transform_float_t        const shx,
                                skc_transform_float_t        const tx,
                                skc_transform_float_t        const shy,
                                skc_transform_float_t        const sy, 
                                skc_transform_float_t        const ty,
                                skc_transform_float_t        const w0, 
                                skc_transform_float_t        const w1, 
                                skc_transform_float_t        const w2);

void
skc_transform_stack_push_identity(struct skc_transform_stack * const ts);

void
skc_transform_stack_push_affine(struct skc_transform_stack * const ts,
                                skc_transform_float_t        const sx,  
                                skc_transform_float_t        const shx,
                                skc_transform_float_t        const tx,
                                skc_transform_float_t        const shy, 
                                skc_transform_float_t        const sy,
                                skc_transform_float_t        const ty);

void
skc_transform_stack_push_translate(struct skc_transform_stack * const ts,
                                   skc_transform_float_t        const tx, 
                                   skc_transform_float_t        const ty);

void
skc_transform_stack_push_scale(struct skc_transform_stack * const ts,
                               skc_transform_float_t        const sx, 
                               skc_transform_float_t        const sy);

void
skc_transform_stack_push_shear(struct skc_transform_stack * const ts,
                               skc_transform_float_t        const shx, 
                               skc_transform_float_t        const shy);


void
skc_transform_stack_push_skew_x(struct skc_transform_stack * const ts,
                                skc_transform_float_t        const theta);

void
skc_transform_stack_push_skew_y(struct skc_transform_stack * const ts,
                                skc_transform_float_t        const theta);

void
skc_transform_stack_push_rotate(struct skc_transform_stack * const ts,
                                skc_transform_float_t        const theta);

void
skc_transform_stack_push_rotate_xy2(struct skc_transform_stack * const ts,
                                    skc_transform_float_t        const theta,
                                    skc_transform_float_t        const cx,
                                    skc_transform_float_t        const cy,
                                    skc_transform_float_t        const tx, 
                                    skc_transform_float_t        const ty);

void
skc_transform_stack_push_rotate_xy(struct skc_transform_stack * const ts,
                                   skc_transform_float_t        const theta,
                                   skc_transform_float_t        const cx,
                                   skc_transform_float_t        const cy);

void
skc_transform_stack_push_rotate_scale_xy(struct skc_transform_stack * const ts,
                                         skc_transform_float_t        const theta,
                                         skc_transform_float_t        const sx,
                                         skc_transform_float_t        const sy,
                                         skc_transform_float_t        const cx,
                                         skc_transform_float_t        const cy);
//
// Quadrilateral coordinates are skc_transform_float_t2 structs:
//
//   float2[4] = { xy0, xy1, xy2, xy3 }
//
// -or-
//
//   float[8]  = { x0, y0, x1, y1, x2, y2, x3, y3 };
//

bool
skc_transform_stack_push_quad_to_unit(struct skc_transform_stack * const ts,
                                      float const quad_src[8]);

bool
skc_transform_stack_push_unit_to_quad(struct skc_transform_stack * const ts,
                                      float const quad_dst[8]);

bool
skc_transform_stack_push_rect_to_quad(struct skc_transform_stack * const ts,
                                      float const x0,
                                      float const y0,
                                      float const x1,
                                      float const y1,
                                      float const quad_dst[8]);

bool
skc_transform_stack_push_quad_to_quad(struct skc_transform_stack * const ts,
                                      float const quad_src[8],
                                      float const quad_dst[8]);

//
//
//

void
skc_transform_stack_concat(struct skc_transform_stack * const ts);

//
//
//