gbm: factor out gbm_window_{init,teardown}
[mesa-waffle.git] / src / waffle / core / wcore_platform.h
blob4396a188dcc69a7a4513ee776588b07f2c57d689
1 // Copyright 2012 Intel Corporation
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // - Redistributions of source code must retain the above copyright notice, this
9 // list of conditions and the following disclaimer.
11 // - Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #pragma once
28 #include <assert.h>
29 #include <stdbool.h>
30 #include <stdint.h>
31 #include "c99_compat.h"
33 struct wcore_config;
34 struct wcore_config_attrs;
35 struct wcore_context;
36 struct wcore_display;
37 struct wcore_platform;
38 struct wcore_window;
40 struct wcore_platform_vtbl {
41 bool
42 (*destroy)(struct wcore_platform *self);
44 bool
45 (*make_current)(
46 struct wcore_platform *self,
47 struct wcore_display *dpy,
48 struct wcore_window *window,
49 struct wcore_context *ctx);
51 void*
52 (*get_proc_address)(
53 struct wcore_platform *self,
54 const char *proc);
56 bool
57 (*dl_can_open)(
58 struct wcore_platform *self,
59 int32_t waffle_dl);
61 void*
62 (*dl_sym)(
63 struct wcore_platform *self,
64 int32_t waffle_dl,
65 const char *symbol);
67 struct wcore_display_vtbl {
68 struct wcore_display*
69 (*connect)(struct wcore_platform *platform,
70 const char *name);
72 bool
73 (*destroy)(struct wcore_display *self);
75 bool
76 (*supports_context_api)(
77 struct wcore_display *display,
78 int32_t context_api);
80 /// May be null.
81 union waffle_native_display*
82 (*get_native)(struct wcore_display *display);
83 } display;
85 struct wcore_config_vtbl {
86 struct wcore_config*
87 (*choose)(struct wcore_platform *platform,
88 struct wcore_display *display,
89 const struct wcore_config_attrs *attrs);
91 bool
92 (*destroy)(struct wcore_config *config);
94 /// May be null.
95 union waffle_native_config*
96 (*get_native)(struct wcore_config *config);
97 } config;
99 struct wcore_context_vtbl {
100 struct wcore_context*
101 (*create)(struct wcore_platform *platform,
102 struct wcore_config *config,
103 struct wcore_context *share_ctx);
105 bool
106 (*destroy)(struct wcore_context *ctx);
108 /// May be null.
109 union waffle_native_context*
110 (*get_native)(struct wcore_context *ctx);
111 } context;
113 struct wcore_window_vtbl {
114 struct wcore_window*
115 (*create)(struct wcore_platform *platform,
116 struct wcore_config *config,
117 int32_t width,
118 int32_t height,
119 const intptr_t attrib_list[]);
120 bool
121 (*destroy)(struct wcore_window *window);
123 bool
124 (*show)(struct wcore_window *window);
126 bool
127 (*swap_buffers)(struct wcore_window *window);
129 bool
130 (*resize)(struct wcore_window *window,
131 int32_t height,
132 int32_t width);
134 /// May be null.
135 union waffle_native_window*
136 (*get_native)(struct wcore_window *window);
137 } window;
140 struct wcore_platform {
141 const struct wcore_platform_vtbl *vtbl;
142 enum waffle_enum waffle_platform; // WAFFLE_PLATFORM_*
145 static inline bool
146 wcore_platform_init(struct wcore_platform *self)
148 (void) self;
149 assert(self);
150 return true;
153 static inline bool
154 wcore_platform_teardown(struct wcore_platform *self)
156 (void) self;
157 assert(self);
158 return true;