aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compute/skc/skc.h
blob: a5e81fb2ff23864272a2950fcb878fbbf4fe0860 (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
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can
 * be found in the LICENSE file.
 *
 */

#ifndef SKC_ONCE_SKC
#define SKC_ONCE_SKC

//
//
//

#include "skc_err.h"
#include "skc_types.h"
#include "skc_styling.h"

//
// CONTEXT
//

skc_err
skc_context_retain(skc_context_t context);

skc_err
skc_context_release(skc_context_t context);

skc_err
skc_context_reset(skc_context_t context);

//
// PATH BUILDER
//

skc_err
skc_path_builder_create(skc_context_t context, skc_path_builder_t * path_builder);

skc_err
skc_path_builder_retain(skc_path_builder_t path_builder);

skc_err
skc_path_builder_release(skc_path_builder_t path_builder);

//
// PATH OPS
//

skc_err
skc_path_begin(skc_path_builder_t path_builder);

skc_err
skc_path_end(skc_path_builder_t path_builder, skc_path_t * path);

skc_err
skc_path_retain(skc_context_t context, skc_path_t const * paths, uint32_t count);

skc_err
skc_path_release(skc_context_t context, skc_path_t const * paths, uint32_t count);

skc_err
skc_path_flush(skc_context_t context, skc_path_t const * paths, uint32_t count);

//
// PATH SEGMENT OPS
//

//
// FIXME -- we need a bulk/vectorized path segment operation
//

skc_err
skc_path_move_to(skc_path_builder_t path_builder,
                 float x0, float y0);

skc_err
skc_path_close(skc_path_builder_t path_builder);

skc_err
skc_path_line_to(skc_path_builder_t path_builder,
                 float x1, float y1);

skc_err
skc_path_cubic_to(skc_path_builder_t path_builder,
                  float x1, float y1,
                  float x2, float y2,
                  float x3, float y3);

skc_err
skc_path_cubic_smooth_to(skc_path_builder_t path_builder,
                         float x2, float y2,
                         float x3, float y3);

skc_err
skc_path_quad_to(skc_path_builder_t path_builder,
                 float x1, float y1,
                 float x2, float y2);

skc_err
skc_path_quad_smooth_to(skc_path_builder_t path_builder,
                        float x2, float y2);

skc_err
skc_path_ellipse(skc_path_builder_t path_builder,
                 float cx, float cy,
                 float rx, float ry);

//
// RASTER BUILDER
//

skc_err
skc_raster_builder_create(skc_context_t context, skc_raster_builder_t * raster_builder);

skc_err
skc_raster_builder_retain(skc_raster_builder_t raster_builder);

skc_err
skc_raster_builder_release(skc_raster_builder_t raster_builder);

//
// RASTER OPS
//

skc_err
skc_raster_begin(skc_raster_builder_t raster_builder);

skc_err
skc_raster_end(skc_raster_builder_t raster_builder, skc_raster_t * raster);

skc_err
skc_raster_retain(skc_context_t context, skc_raster_t const * rasters, uint32_t count);

skc_err
skc_raster_release(skc_context_t context, skc_raster_t const * rasters, uint32_t count);

skc_err
skc_raster_flush(skc_context_t context, skc_raster_t const * rasters, uint32_t count);

//
// PATH-TO-RASTER OPS
//

//
// FIXME -- do we need a bulk/vectorized "add filled" function?
//

skc_err
skc_raster_add_filled(skc_raster_builder_t        raster_builder,
                      skc_path_t                  path,
                      skc_transform_weakref_t   * transform_weakref,
                      float               const * transform,
                      skc_raster_clip_weakref_t * raster_clip_weakref,
                      float               const * raster_clip);

//
// COMPOSITION STATE
//

skc_err
skc_composition_create(skc_context_t context, skc_composition_t * composition);

skc_err
skc_composition_retain(skc_composition_t composition);

skc_err
skc_composition_release(skc_composition_t composition);

skc_err
skc_composition_place(skc_composition_t    composition,
                      skc_raster_t const * rasters,
                      skc_layer_id const * layer_ids,
                      float        const * txs,
                      float        const * tys,
                      uint32_t             count); // NOTE: A PER-PLACE CLIP IS POSSIBLE

skc_err
skc_composition_seal(skc_composition_t composition);

skc_err
skc_composition_unseal(skc_composition_t composition, bool reset);

skc_err
skc_composition_get_bounds(skc_composition_t composition, int32_t bounds[4]);

#if 0
// let's switch to a per place bounds using weakrefs -- clip 0 will be largest clip
skc_err
skc_composition_set_clip(skc_composition_t composition, int32_t const clip[4]);
#endif

//
// TODO: COMPOSITION "SET ALGEBRA" OPERATIONS
//
// Produce a new composition from the union or intersection of two
// existing compositions
//

//
// TODO: COMPOSITION "HIT DETECTION"
//
// Report which layers and tiles are intersected by one or more
// device-space (x,y) points
//

//
// STYLING STATE
//

skc_err
skc_styling_create(skc_context_t   context,
                   skc_styling_t * styling,
                   uint32_t        layers_count,
                   uint32_t        groups_count,
                   uint32_t        extras_count);

skc_err
skc_styling_retain(skc_styling_t styling);

skc_err
skc_styling_release(skc_styling_t styling);

skc_err
skc_styling_seal(skc_styling_t styling);

skc_err
skc_styling_unseal(skc_styling_t styling); // FIXME

skc_err
skc_styling_reset(skc_styling_t styling); // FIXME -- make unseal reset

//
// STYLING GROUPS AND LAYERS
//

skc_err
skc_styling_group_alloc(skc_styling_t  styling,
                        skc_group_id * group_id);

skc_err
skc_styling_group_enter(skc_styling_t             styling,
                        skc_group_id              group_id,
                        uint32_t                  n,
                        skc_styling_cmd_t const * cmds);

skc_err
skc_styling_group_leave(skc_styling_t             styling,
                        skc_group_id              group_id,
                        uint32_t                  n,
                        skc_styling_cmd_t const * cmds);

skc_err
skc_styling_group_parents(skc_styling_t        styling,
                          skc_group_id         group_id,
                          uint32_t             depth,
                          skc_group_id const * parents);

skc_err
skc_styling_group_range_lo(skc_styling_t styling,
                           skc_group_id  group_id,
                           skc_layer_id  layer_lo);

skc_err
skc_styling_group_range_hi(skc_styling_t styling,
                           skc_group_id  group_id,
                           skc_layer_id  layer_hi);

skc_err
skc_styling_group_layer(skc_styling_t             styling,
                        skc_group_id              group_id,
                        skc_layer_id              layer_id,
                        uint32_t                  n,
                        skc_styling_cmd_t const * cmds);

//
// STYLING ENCODERS -- FIXME -- WILL EVENTUALLY BE OPAQUE
//

void
skc_styling_layer_fill_rgba_encoder(skc_styling_cmd_t * cmds, float const rgba[4]);

void
skc_styling_background_over_encoder(skc_styling_cmd_t * cmds, float const rgba[4]);

void
skc_styling_layer_fill_gradient_encoder(skc_styling_cmd_t         * cmds,
                                        float                       x0,
                                        float                       y0,
                                        float                       x1,
                                        float                       y1,
                                        skc_styling_gradient_type_e type,
                                        uint32_t                    n,
                                        float                 const stops[],
                                        float                 const colors[]);

//
// SURFACE
//

skc_err
skc_surface_create(skc_context_t context, skc_surface_t * surface);

skc_err
skc_surface_retain(skc_surface_t surface);

skc_err
skc_surface_release(skc_surface_t surface);

//
// SURFACE RENDER
//

typedef void (*skc_surface_render_notify)(skc_surface_t     surface,
                                          skc_styling_t     styling,
                                          skc_composition_t composition,
                                          skc_framebuffer_t fb,
                                          void            * data);

skc_err
skc_surface_render(skc_surface_t             surface,
                   skc_styling_t             styling,
                   skc_composition_t         composition,
                   skc_framebuffer_t         fb,
                   uint32_t            const clip[4],
                   skc_surface_render_notify notify,
                   void                    * data);

//
// COORDINATED EXTERNAL OPERATIONS
//
//  Examples include:
//
//  - Transforming an intermediate layer with a blur, sharpen, rotation or scaling kernel.
//  - Subpixel antialiasing using neighboring pixel color and coverage data.
//  - Performing a blit from one region to another region on a surface.
//  - Blitting from one surface to another.
//  - Loading and processing from one region and storing to another region.
//  - Rendezvousing with an external pipeline.
//

// FORTHCOMING...

//
// SCHEDULER
//

bool
skc_context_yield(skc_context_t context);

void
skc_context_wait(skc_context_t context);

//
//
//

#endif

//
//
//