1 // SPDX-FileCopyrightText: Copyright 2012 Intel Corporation
2 // SPDX-License-Identifier: BSD-2-Clause
6 #include "wcore_context.h"
7 #include "wcore_error.h"
8 #include "wcore_platform.h"
10 WAFFLE_API
struct waffle_context
*
11 waffle_context_create(
12 struct waffle_config
*config
,
13 struct waffle_context
*shared_ctx
)
15 struct wcore_context
*wc_self
;
16 struct wcore_config
*wc_config
= wcore_config(config
);
17 struct wcore_context
*wc_shared_ctx
= wcore_context(shared_ctx
);
19 const struct api_object
*obj_list
[2];
22 obj_list
[len
++] = wc_config
? &wc_config
->api
: NULL
;
24 obj_list
[len
++] = &wc_shared_ctx
->api
;
26 if (!api_check_entry(obj_list
, len
))
29 wc_self
= api_platform
->vtbl
->context
.create(api_platform
,
35 return waffle_context(wc_self
);
39 waffle_context_destroy(struct waffle_context
*self
)
41 struct wcore_context
*wc_self
= wcore_context(self
);
43 const struct api_object
*obj_list
[] = {
44 wc_self
? &wc_self
->api
: NULL
,
47 if (!api_check_entry(obj_list
, 1))
50 return api_platform
->vtbl
->context
.destroy(wc_self
);
53 WAFFLE_API
union waffle_native_context
*
54 waffle_context_get_native(struct waffle_context
*self
)
56 struct wcore_context
*wc_self
= wcore_context(self
);
58 const struct api_object
*obj_list
[] = {
59 wc_self
? &wc_self
->api
: NULL
,
62 if (!api_check_entry(obj_list
, 1))
65 if (api_platform
->vtbl
->context
.get_native
) {
66 return api_platform
->vtbl
->context
.get_native(wc_self
);
69 wcore_error(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM
);