blob: 6a50ee785d53bb46b123d3caa9d15ebbff037193 [file] [log] [blame]
Allan MacKinnon4359d522018-06-19 13:57:04 -07001/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can
5 * be found in the LICENSE file.
6 *
7 */
8
9#ifndef SKC_ONCE_SKC
10#define SKC_ONCE_SKC
11
12//
Allan MacKinnon4359d522018-06-19 13:57:04 -070013//
14//
Allan MacKinnon4359d522018-06-19 13:57:04 -070015
Allan MacKinnonc110e792018-06-21 09:09:56 -070016#include "skc_err.h"
17#include "skc_types.h"
18#include "skc_styling.h"
Allan MacKinnon4359d522018-06-19 13:57:04 -070019
20//
21// CONTEXT
22//
23
24skc_err
Allan MacKinnon4359d522018-06-19 13:57:04 -070025skc_context_retain(skc_context_t context);
26
27skc_err
28skc_context_release(skc_context_t context);
29
30skc_err
31skc_context_reset(skc_context_t context);
32
33//
Allan MacKinnon4359d522018-06-19 13:57:04 -070034// PATH BUILDER
35//
36
37skc_err
38skc_path_builder_create(skc_context_t context, skc_path_builder_t * path_builder);
39
40skc_err
41skc_path_builder_retain(skc_path_builder_t path_builder);
42
43skc_err
44skc_path_builder_release(skc_path_builder_t path_builder);
45
46//
47// PATH OPS
48//
49
50skc_err
51skc_path_begin(skc_path_builder_t path_builder);
52
53skc_err
54skc_path_end(skc_path_builder_t path_builder, skc_path_t * path);
55
56skc_err
57skc_path_retain(skc_context_t context, skc_path_t const * paths, uint32_t count);
58
59skc_err
60skc_path_release(skc_context_t context, skc_path_t const * paths, uint32_t count);
61
62skc_err
63skc_path_flush(skc_context_t context, skc_path_t const * paths, uint32_t count);
64
65//
66// PATH SEGMENT OPS
67//
68
69//
70// FIXME -- we need a bulk/vectorized path segment operation
71//
72
73skc_err
74skc_path_move_to(skc_path_builder_t path_builder,
75 float x0, float y0);
76
77skc_err
78skc_path_close(skc_path_builder_t path_builder);
79
80skc_err
81skc_path_line_to(skc_path_builder_t path_builder,
82 float x1, float y1);
83
84skc_err
85skc_path_cubic_to(skc_path_builder_t path_builder,
86 float x1, float y1,
87 float x2, float y2,
88 float x3, float y3);
89
90skc_err
91skc_path_cubic_smooth_to(skc_path_builder_t path_builder,
92 float x2, float y2,
93 float x3, float y3);
94
95skc_err
96skc_path_quad_to(skc_path_builder_t path_builder,
97 float x1, float y1,
98 float x2, float y2);
99
100skc_err
101skc_path_quad_smooth_to(skc_path_builder_t path_builder,
102 float x2, float y2);
103
104skc_err
105skc_path_ellipse(skc_path_builder_t path_builder,
106 float cx, float cy,
107 float rx, float ry);
108
109//
110// RASTER BUILDER
111//
112
113skc_err
114skc_raster_builder_create(skc_context_t context, skc_raster_builder_t * raster_builder);
115
116skc_err
117skc_raster_builder_retain(skc_raster_builder_t raster_builder);
118
119skc_err
120skc_raster_builder_release(skc_raster_builder_t raster_builder);
121
122//
123// RASTER OPS
124//
125
126skc_err
127skc_raster_begin(skc_raster_builder_t raster_builder);
128
129skc_err
130skc_raster_end(skc_raster_builder_t raster_builder, skc_raster_t * raster);
131
132skc_err
133skc_raster_retain(skc_context_t context, skc_raster_t const * rasters, uint32_t count);
134
135skc_err
136skc_raster_release(skc_context_t context, skc_raster_t const * rasters, uint32_t count);
137
138skc_err
139skc_raster_flush(skc_context_t context, skc_raster_t const * rasters, uint32_t count);
140
141//
142// PATH-TO-RASTER OPS
143//
144
145//
146// FIXME -- do we need a bulk/vectorized "add filled" function?
147//
148
149skc_err
150skc_raster_add_filled(skc_raster_builder_t raster_builder,
151 skc_path_t path,
152 skc_transform_weakref_t * transform_weakref,
153 float const * transform,
154 skc_raster_clip_weakref_t * raster_clip_weakref,
155 float const * raster_clip);
156
157//
158// COMPOSITION STATE
159//
160
161skc_err
162skc_composition_create(skc_context_t context, skc_composition_t * composition);
163
164skc_err
165skc_composition_retain(skc_composition_t composition);
166
167skc_err
168skc_composition_release(skc_composition_t composition);
169
170skc_err
171skc_composition_place(skc_composition_t composition,
172 skc_raster_t const * rasters,
173 skc_layer_id const * layer_ids,
174 float const * txs,
175 float const * tys,
176 uint32_t count); // NOTE: A PER-PLACE CLIP IS POSSIBLE
177
178skc_err
179skc_composition_seal(skc_composition_t composition);
180
181skc_err
182skc_composition_unseal(skc_composition_t composition, bool reset);
183
184skc_err
185skc_composition_get_bounds(skc_composition_t composition, int32_t bounds[4]);
186
187#if 0
188// let's switch to a per place bounds using weakrefs -- clip 0 will be largest clip
189skc_err
190skc_composition_set_clip(skc_composition_t composition, int32_t const clip[4]);
191#endif
192
193//
194// TODO: COMPOSITION "SET ALGEBRA" OPERATIONS
195//
196// Produce a new composition from the union or intersection of two
197// existing compositions
198//
199
200//
201// TODO: COMPOSITION "HIT DETECTION"
202//
203// Report which layers and tiles are intersected by one or more
204// device-space (x,y) points
205//
206
207//
208// STYLING STATE
209//
210
211skc_err
212skc_styling_create(skc_context_t context,
213 skc_styling_t * styling,
214 uint32_t layers_count,
215 uint32_t groups_count,
216 uint32_t extras_count);
217
218skc_err
219skc_styling_retain(skc_styling_t styling);
220
221skc_err
222skc_styling_release(skc_styling_t styling);
223
224skc_err
225skc_styling_seal(skc_styling_t styling);
226
227skc_err
228skc_styling_unseal(skc_styling_t styling); // FIXME
229
230skc_err
231skc_styling_reset(skc_styling_t styling); // FIXME -- make unseal reset
232
233//
234// STYLING GROUPS AND LAYERS
235//
236
237skc_err
238skc_styling_group_alloc(skc_styling_t styling,
239 skc_group_id * group_id);
240
241skc_err
242skc_styling_group_enter(skc_styling_t styling,
243 skc_group_id group_id,
244 uint32_t n,
245 skc_styling_cmd_t const * cmds);
246
247skc_err
248skc_styling_group_leave(skc_styling_t styling,
249 skc_group_id group_id,
250 uint32_t n,
Allan MacKinnonebf160f2018-06-24 08:31:14 -0700251 skc_styling_cmd_t const * cmds);
Allan MacKinnon4359d522018-06-19 13:57:04 -0700252
Allan MacKinnon6ddc9592018-10-01 09:16:33 -0700253//
254// n:
255//
256// The number of parent groups above this group. The top of the
257// hierarchy must start with a single enclosing group which has 0
258// parents.
259//
260// parents:
261//
262// The sequence of parent group ids leading from the top of
263// hierarchy to the parent of 'group_id'.
264//
Allan MacKinnon4359d522018-06-19 13:57:04 -0700265skc_err
266skc_styling_group_parents(skc_styling_t styling,
267 skc_group_id group_id,
Allan MacKinnon6ddc9592018-10-01 09:16:33 -0700268 uint32_t n,
Allan MacKinnon4359d522018-06-19 13:57:04 -0700269 skc_group_id const * parents);
270
271skc_err
272skc_styling_group_range_lo(skc_styling_t styling,
273 skc_group_id group_id,
274 skc_layer_id layer_lo);
275
276skc_err
277skc_styling_group_range_hi(skc_styling_t styling,
278 skc_group_id group_id,
279 skc_layer_id layer_hi);
280
281skc_err
282skc_styling_group_layer(skc_styling_t styling,
283 skc_group_id group_id,
284 skc_layer_id layer_id,
285 uint32_t n,
Allan MacKinnonebf160f2018-06-24 08:31:14 -0700286 skc_styling_cmd_t const * cmds);
Allan MacKinnon4359d522018-06-19 13:57:04 -0700287
288//
289// STYLING ENCODERS -- FIXME -- WILL EVENTUALLY BE OPAQUE
290//
291
292void
293skc_styling_layer_fill_rgba_encoder(skc_styling_cmd_t * cmds, float const rgba[4]);
294
295void
296skc_styling_background_over_encoder(skc_styling_cmd_t * cmds, float const rgba[4]);
297
298void
299skc_styling_layer_fill_gradient_encoder(skc_styling_cmd_t * cmds,
300 float x0,
301 float y0,
302 float x1,
303 float y1,
304 skc_styling_gradient_type_e type,
305 uint32_t n,
306 float const stops[],
307 float const colors[]);
308
309//
310// SURFACE
311//
312
Allan MacKinnon4359d522018-06-19 13:57:04 -0700313skc_err
314skc_surface_create(skc_context_t context, skc_surface_t * surface);
315
316skc_err
317skc_surface_retain(skc_surface_t surface);
318
319skc_err
320skc_surface_release(skc_surface_t surface);
321
Allan MacKinnon4359d522018-06-19 13:57:04 -0700322//
323// SURFACE RENDER
324//
325
Allan MacKinnonebf160f2018-06-24 08:31:14 -0700326typedef void (*skc_surface_render_notify)(skc_surface_t surface,
327 skc_styling_t styling,
328 skc_composition_t composition,
329 skc_framebuffer_t fb,
330 void * data);
331
Allan MacKinnon4359d522018-06-19 13:57:04 -0700332skc_err
Allan MacKinnonebf160f2018-06-24 08:31:14 -0700333skc_surface_render(skc_surface_t surface,
334 skc_styling_t styling,
335 skc_composition_t composition,
336 skc_framebuffer_t fb,
337 uint32_t const clip[4],
Allan MacKinnon9e0d7e42018-07-16 15:57:05 -0700338 int32_t const txty[2],
Allan MacKinnonebf160f2018-06-24 08:31:14 -0700339 skc_surface_render_notify notify,
340 void * data);
Allan MacKinnon4359d522018-06-19 13:57:04 -0700341
342//
Allan MacKinnonc110e792018-06-21 09:09:56 -0700343// COORDINATED EXTERNAL OPERATIONS
344//
345// Examples include:
346//
347// - Transforming an intermediate layer with a blur, sharpen, rotation or scaling kernel.
348// - Subpixel antialiasing using neighboring pixel color and coverage data.
349// - Performing a blit from one region to another region on a surface.
350// - Blitting from one surface to another.
351// - Loading and processing from one region and storing to another region.
352// - Rendezvousing with an external pipeline.
353//
354
355// FORTHCOMING...
356
357//
358// SCHEDULER
359//
360
361bool
362skc_context_yield(skc_context_t context);
363
364void
365skc_context_wait(skc_context_t context);
366
367//
Allan MacKinnon4359d522018-06-19 13:57:04 -0700368//
369//
370
371#endif
372
373//
374//
375//