gitlab-ci: enable sanitizers for the meson builds
[mesa-waffle.git] / src / waffle / api / waffle_context.c
bloba4f50c24dbddd4e2e014ae999092aba91bf08717
1 // SPDX-FileCopyrightText: Copyright 2012 Intel Corporation
2 // SPDX-License-Identifier: BSD-2-Clause
4 #include "api_priv.h"
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];
20 int len = 0;
22 obj_list[len++] = wc_config ? &wc_config->api : NULL;
23 if (wc_shared_ctx)
24 obj_list[len++] = &wc_shared_ctx->api;
26 if (!api_check_entry(obj_list, len))
27 return NULL;
29 wc_self = api_platform->vtbl->context.create(api_platform,
30 wc_config,
31 wc_shared_ctx);
32 if (!wc_self)
33 return NULL;
35 return waffle_context(wc_self);
38 WAFFLE_API bool
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))
48 return false;
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))
63 return NULL;
65 if (api_platform->vtbl->context.get_native) {
66 return api_platform->vtbl->context.get_native(wc_self);
68 else {
69 wcore_error(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
70 return NULL;