• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 //
10 //
11 //
12 
13 #include <stdlib.h>
14 #include <assert.h> // FIXME -- replace with an SKC assert for non-debug builds
15 
16 #include "skc.h"
17 #include "context.h"
18 
19 //
20 // FIXME -- THE RUNTIME AND DEVICE WILL DYNAMICALLY LOADED
21 //
22 
23 // temporarily
24 #include "runtime_cl_12.h"
25 
26 //
27 // CONTEXT
28 //
29 
30 skc_err
skc_context_create_cl(skc_context_t * context,cl_context context_cl,cl_device_id device_id_cl)31 skc_context_create_cl(skc_context_t * context,
32                       cl_context      context_cl,
33                       cl_device_id    device_id_cl)
34 {
35   (*context) = malloc(sizeof(**context));
36 
37   //
38   // FIXME -- we'll clean up context creation by platform later.  For
39   // now, just create a CL_12 context.
40   //
41   skc_err err;
42 
43   err = skc_runtime_cl_12_create(*context,context_cl,device_id_cl);
44 
45   return err;
46 }
47 
48 skc_err
skc_context_retain(skc_context_t context)49 skc_context_retain(skc_context_t context)
50 {
51   return SKC_ERR_SUCCESS;
52 }
53 
54 
55 skc_err
skc_context_release(skc_context_t context)56 skc_context_release(skc_context_t context)
57 {
58   skc_err err = skc_runtime_cl_12_dispose(context);
59 
60   free(context);
61 
62   return err;
63 }
64 
65 
66 skc_err
skc_context_reset(skc_context_t context)67 skc_context_reset(skc_context_t context)
68 {
69   return SKC_ERR_SUCCESS;
70 }
71 
72 //
73 //
74 //
75 
76 bool
skc_context_yield(skc_context_t context)77 skc_context_yield(skc_context_t context)
78 {
79   return context->yield(context->runtime);
80 }
81 
82 void
skc_context_wait(skc_context_t context)83 skc_context_wait(skc_context_t context)
84 {
85   context->wait(context->runtime);
86 }
87 
88 //
89 //
90 //
91 
92 skc_err
skc_path_builder_create(skc_context_t context,skc_path_builder_t * path_builder)93 skc_path_builder_create(skc_context_t context, skc_path_builder_t * path_builder)
94 {
95   return context->path_builder(context,path_builder);
96 }
97 
98 skc_err
skc_path_retain(skc_context_t context,skc_path_t const * paths,uint32_t count)99 skc_path_retain(skc_context_t context, skc_path_t const * paths, uint32_t count)
100 {
101   return context->path_retain(context->runtime,paths,count);
102 }
103 
104 skc_err
skc_path_release(skc_context_t context,skc_path_t const * paths,uint32_t count)105 skc_path_release(skc_context_t context, skc_path_t const * paths, uint32_t count)
106 {
107   return context->path_release(context->runtime,paths,count);
108 }
109 
110 skc_err
skc_path_flush(skc_context_t context,skc_path_t const * paths,uint32_t count)111 skc_path_flush(skc_context_t context, skc_path_t const * paths, uint32_t count)
112 {
113   return context->path_flush(context->runtime,paths,count);
114 }
115 
116 //
117 //
118 //
119 
120 skc_err
skc_raster_builder_create(skc_context_t context,skc_raster_builder_t * raster_builder)121 skc_raster_builder_create(skc_context_t context, skc_raster_builder_t * raster_builder)
122 {
123   return context->raster_builder(context,raster_builder);
124 }
125 
126 skc_err
skc_raster_retain(skc_context_t context,skc_raster_t const * rasters,uint32_t count)127 skc_raster_retain(skc_context_t context, skc_raster_t const * rasters, uint32_t count)
128 {
129   return context->raster_retain(context->runtime,rasters,count);
130 }
131 
132 skc_err
skc_raster_release(skc_context_t context,skc_raster_t const * rasters,uint32_t count)133 skc_raster_release(skc_context_t context, skc_raster_t const * rasters, uint32_t count)
134 {
135   return context->raster_release(context->runtime,rasters,count);
136 }
137 
138 skc_err
skc_raster_flush(skc_context_t context,skc_raster_t const * rasters,uint32_t count)139 skc_raster_flush(skc_context_t context, skc_raster_t const * rasters, uint32_t count)
140 {
141   return context->raster_flush(context->runtime,rasters,count);
142 }
143 
144 //
145 //
146 //
147 
148 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)149 skc_styling_create(skc_context_t   context,
150                    skc_styling_t * styling,
151                    uint32_t        layers_count,
152                    uint32_t        groups_count,
153                    uint32_t        extras_count)
154 {
155   return context->styling(context,
156                           styling,
157                           layers_count,
158                           groups_count,
159                           extras_count);
160 }
161 
162 skc_err
skc_composition_create(skc_context_t context,skc_composition_t * composition)163 skc_composition_create(skc_context_t context, skc_composition_t * composition)
164 {
165   return context->composition(context,composition);
166 }
167 
168 
169 skc_err
skc_surface_create(skc_context_t context,skc_surface_t * surface)170 skc_surface_create(skc_context_t context, skc_surface_t * surface)
171 {
172   return context->surface(context,surface);
173 }
174 
175 //
176 //
177 //
178