Home | History | Annotate | Download | only in skc
      1 /*
      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 //
     13 //
     14 //
     15 
     16 #include "skc_err.h"
     17 #include "skc_types.h"
     18 #include "skc_styling.h"
     19 
     20 //
     21 // CONTEXT
     22 //
     23 
     24 skc_err
     25 skc_context_retain(skc_context_t context);
     26 
     27 skc_err
     28 skc_context_release(skc_context_t context);
     29 
     30 skc_err
     31 skc_context_reset(skc_context_t context);
     32 
     33 //
     34 // PATH BUILDER
     35 //
     36 
     37 skc_err
     38 skc_path_builder_create(skc_context_t context, skc_path_builder_t * path_builder);
     39 
     40 skc_err
     41 skc_path_builder_retain(skc_path_builder_t path_builder);
     42 
     43 skc_err
     44 skc_path_builder_release(skc_path_builder_t path_builder);
     45 
     46 //
     47 // PATH OPS
     48 //
     49 
     50 skc_err
     51 skc_path_begin(skc_path_builder_t path_builder);
     52 
     53 skc_err
     54 skc_path_end(skc_path_builder_t path_builder, skc_path_t * path);
     55 
     56 skc_err
     57 skc_path_retain(skc_context_t context, skc_path_t const * paths, uint32_t count);
     58 
     59 skc_err
     60 skc_path_release(skc_context_t context, skc_path_t const * paths, uint32_t count);
     61 
     62 skc_err
     63 skc_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 
     73 skc_err
     74 skc_path_move_to(skc_path_builder_t path_builder,
     75                  float x0, float y0);
     76 
     77 skc_err
     78 skc_path_close(skc_path_builder_t path_builder);
     79 
     80 skc_err
     81 skc_path_line_to(skc_path_builder_t path_builder,
     82                  float x1, float y1);
     83 
     84 skc_err
     85 skc_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 
     90 skc_err
     91 skc_path_cubic_smooth_to(skc_path_builder_t path_builder,
     92                          float x2, float y2,
     93                          float x3, float y3);
     94 
     95 skc_err
     96 skc_path_quad_to(skc_path_builder_t path_builder,
     97                  float x1, float y1,
     98                  float x2, float y2);
     99 
    100 skc_err
    101 skc_path_quad_smooth_to(skc_path_builder_t path_builder,
    102                         float x2, float y2);
    103 
    104 skc_err
    105 skc_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 
    113 skc_err
    114 skc_raster_builder_create(skc_context_t context, skc_raster_builder_t * raster_builder);
    115 
    116 skc_err
    117 skc_raster_builder_retain(skc_raster_builder_t raster_builder);
    118 
    119 skc_err
    120 skc_raster_builder_release(skc_raster_builder_t raster_builder);
    121 
    122 //
    123 // RASTER OPS
    124 //
    125 
    126 skc_err
    127 skc_raster_begin(skc_raster_builder_t raster_builder);
    128 
    129 skc_err
    130 skc_raster_end(skc_raster_builder_t raster_builder, skc_raster_t * raster);
    131 
    132 skc_err
    133 skc_raster_retain(skc_context_t context, skc_raster_t const * rasters, uint32_t count);
    134 
    135 skc_err
    136 skc_raster_release(skc_context_t context, skc_raster_t const * rasters, uint32_t count);
    137 
    138 skc_err
    139 skc_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 
    149 skc_err
    150 skc_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 
    161 skc_err
    162 skc_composition_create(skc_context_t context, skc_composition_t * composition);
    163 
    164 skc_err
    165 skc_composition_retain(skc_composition_t composition);
    166 
    167 skc_err
    168 skc_composition_release(skc_composition_t composition);
    169 
    170 skc_err
    171 skc_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 
    178 skc_err
    179 skc_composition_seal(skc_composition_t composition);
    180 
    181 skc_err
    182 skc_composition_unseal(skc_composition_t composition, bool reset);
    183 
    184 skc_err
    185 skc_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
    189 skc_err
    190 skc_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 
    211 skc_err
    212 skc_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 
    218 skc_err
    219 skc_styling_retain(skc_styling_t styling);
    220 
    221 skc_err
    222 skc_styling_release(skc_styling_t styling);
    223 
    224 skc_err
    225 skc_styling_seal(skc_styling_t styling);
    226 
    227 skc_err
    228 skc_styling_unseal(skc_styling_t styling); // FIXME
    229 
    230 skc_err
    231 skc_styling_reset(skc_styling_t styling); // FIXME -- make unseal reset
    232 
    233 //
    234 // STYLING GROUPS AND LAYERS
    235 //
    236 
    237 skc_err
    238 skc_styling_group_alloc(skc_styling_t  styling,
    239                         skc_group_id * group_id);
    240 
    241 skc_err
    242 skc_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 
    247 skc_err
    248 skc_styling_group_leave(skc_styling_t             styling,
    249                         skc_group_id              group_id,
    250                         uint32_t                  n,
    251                         skc_styling_cmd_t const * cmds);
    252 
    253 //
    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 //
    265 skc_err
    266 skc_styling_group_parents(skc_styling_t        styling,
    267                           skc_group_id         group_id,
    268                           uint32_t             n,
    269                           skc_group_id const * parents);
    270 
    271 skc_err
    272 skc_styling_group_range_lo(skc_styling_t styling,
    273                            skc_group_id  group_id,
    274                            skc_layer_id  layer_lo);
    275 
    276 skc_err
    277 skc_styling_group_range_hi(skc_styling_t styling,
    278                            skc_group_id  group_id,
    279                            skc_layer_id  layer_hi);
    280 
    281 skc_err
    282 skc_styling_group_layer(skc_styling_t             styling,
    283                         skc_group_id              group_id,
    284                         skc_layer_id              layer_id,
    285                         uint32_t                  n,
    286                         skc_styling_cmd_t const * cmds);
    287 
    288 //
    289 // STYLING ENCODERS -- FIXME -- WILL EVENTUALLY BE OPAQUE
    290 //
    291 
    292 void
    293 skc_styling_layer_fill_rgba_encoder(skc_styling_cmd_t * cmds, float const rgba[4]);
    294 
    295 void
    296 skc_styling_background_over_encoder(skc_styling_cmd_t * cmds, float const rgba[4]);
    297 
    298 void
    299 skc_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 
    313 skc_err
    314 skc_surface_create(skc_context_t context, skc_surface_t * surface);
    315 
    316 skc_err
    317 skc_surface_retain(skc_surface_t surface);
    318 
    319 skc_err
    320 skc_surface_release(skc_surface_t surface);
    321 
    322 //
    323 // SURFACE RENDER
    324 //
    325 
    326 typedef 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 
    332 skc_err
    333 skc_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],
    338                    int32_t             const txty[2],
    339                    skc_surface_render_notify notify,
    340                    void                    * data);
    341 
    342 //
    343 // 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 
    361 bool
    362 skc_context_yield(skc_context_t context);
    363 
    364 void
    365 skc_context_wait(skc_context_t context);
    366 
    367 //
    368 //
    369 //
    370 
    371 #endif
    372 
    373 //
    374 //
    375 //
    376