Allan MacKinnon | 4359d52 | 2018-06-19 13:57:04 -0700 | [diff] [blame] | 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 |
Allan MacKinnon | c110e79 | 2018-06-21 09:09:56 -0700 | [diff] [blame^] | 31 | skc_context_create_cl(skc_context_t * context, |
| 32 | cl_context context_cl, |
| 33 | cl_device_id device_id_cl) |
Allan MacKinnon | 4359d52 | 2018-06-19 13:57:04 -0700 | [diff] [blame] | 34 | { |
| 35 | (*context) = malloc(sizeof(**context)); |
| 36 | |
| 37 | // |
Allan MacKinnon | c110e79 | 2018-06-21 09:09:56 -0700 | [diff] [blame^] | 38 | // FIXME -- we'll clean up context creation by platform later. For |
| 39 | // now, just create a CL_12 context. |
Allan MacKinnon | 4359d52 | 2018-06-19 13:57:04 -0700 | [diff] [blame] | 40 | // |
| 41 | skc_err err; |
| 42 | |
Allan MacKinnon | c110e79 | 2018-06-21 09:09:56 -0700 | [diff] [blame^] | 43 | err = skc_runtime_cl_12_create(*context,context_cl,device_id_cl); |
| 44 | |
Allan MacKinnon | 4359d52 | 2018-06-19 13:57:04 -0700 | [diff] [blame] | 45 | return err; |
| 46 | } |
| 47 | |
| 48 | skc_err |
| 49 | skc_context_retain(skc_context_t context) |
| 50 | { |
| 51 | return SKC_ERR_SUCCESS; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | skc_err |
| 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 |
| 67 | skc_context_reset(skc_context_t context) |
| 68 | { |
| 69 | return SKC_ERR_SUCCESS; |
| 70 | } |
| 71 | |
| 72 | // |
| 73 | // |
| 74 | // |
| 75 | |
| 76 | bool |
| 77 | skc_context_yield(skc_context_t context) |
| 78 | { |
| 79 | return context->yield(context->runtime); |
| 80 | } |
| 81 | |
| 82 | void |
| 83 | skc_context_wait(skc_context_t context) |
| 84 | { |
| 85 | context->wait(context->runtime); |
| 86 | } |
| 87 | |
| 88 | // |
| 89 | // |
| 90 | // |
| 91 | |
| 92 | skc_err |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 170 | skc_surface_create(skc_context_t context, skc_surface_t * surface) |
| 171 | { |
| 172 | return context->surface(context,surface); |
| 173 | } |
| 174 | |
| 175 | // |
| 176 | // |
| 177 | // |