1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2011 Intel Corporation
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci#include "fake_glx_screen.h"
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_cistruct glx_screen_vtable fake_glx_screen::vt = {
26bf215546Sopenharmony_ci   indirect_create_context,
27bf215546Sopenharmony_ci   indirect_create_context_attribs,
28bf215546Sopenharmony_ci   NULL,
29bf215546Sopenharmony_ci   NULL,
30bf215546Sopenharmony_ci};
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_cistruct glx_screen_vtable fake_glx_screen_direct::vt = {
33bf215546Sopenharmony_ci   fake_glx_context_direct::create,
34bf215546Sopenharmony_ci   fake_glx_context_direct::create_attribs,
35bf215546Sopenharmony_ci   NULL,
36bf215546Sopenharmony_ci   NULL,
37bf215546Sopenharmony_ci};
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_ciconst struct glx_context_vtable fake_glx_context::vt = {
40bf215546Sopenharmony_ci   fake_glx_context::destroy,
41bf215546Sopenharmony_ci   NULL,
42bf215546Sopenharmony_ci   NULL,
43bf215546Sopenharmony_ci   NULL,
44bf215546Sopenharmony_ci   NULL,
45bf215546Sopenharmony_ci   NULL,
46bf215546Sopenharmony_ci   NULL,
47bf215546Sopenharmony_ci};
48bf215546Sopenharmony_ci
49bf215546Sopenharmony_ciint fake_glx_context::contexts_allocated = 0;
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_ciextern "C" struct glx_context *
52bf215546Sopenharmony_ciindirect_create_context(struct glx_screen *psc, struct glx_config *mode,
53bf215546Sopenharmony_ci			struct glx_context *shareList, int renderType)
54bf215546Sopenharmony_ci{
55bf215546Sopenharmony_ci   (void) shareList;
56bf215546Sopenharmony_ci   (void) renderType;
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ci   return new fake_glx_context(psc, mode);
59bf215546Sopenharmony_ci}
60bf215546Sopenharmony_ci
61bf215546Sopenharmony_ciextern "C" struct glx_context *
62bf215546Sopenharmony_ciindirect_create_context_attribs(struct glx_screen *base,
63bf215546Sopenharmony_ci				struct glx_config *config_base,
64bf215546Sopenharmony_ci				struct glx_context *shareList,
65bf215546Sopenharmony_ci				unsigned num_attribs,
66bf215546Sopenharmony_ci				const uint32_t *attribs,
67bf215546Sopenharmony_ci				unsigned *error)
68bf215546Sopenharmony_ci{
69bf215546Sopenharmony_ci   (void) num_attribs;
70bf215546Sopenharmony_ci   (void) attribs;
71bf215546Sopenharmony_ci   (void) error;
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_ci   return indirect_create_context(base, config_base, shareList, 0);
74bf215546Sopenharmony_ci}
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_ci#ifdef GLX_USE_APPLEGL
77bf215546Sopenharmony_ci#warning Indirect GLX tests are not built
78bf215546Sopenharmony_ciextern "C" struct glx_context *
79bf215546Sopenharmony_ciapplegl_create_context(struct glx_screen *base,
80bf215546Sopenharmony_ci		       struct glx_config *config_base,
81bf215546Sopenharmony_ci		       struct glx_context *shareList,
82bf215546Sopenharmony_ci		       int renderType)
83bf215546Sopenharmony_ci{
84bf215546Sopenharmony_ci   return indirect_create_context(base, config_base, shareList, renderType);
85bf215546Sopenharmony_ci}
86bf215546Sopenharmony_ci#endif
87bf215546Sopenharmony_ci
88bf215546Sopenharmony_ci/* This is necessary so that we don't have to link with glxcurrent.c
89bf215546Sopenharmony_ci * which would require us to link with X libraries and what not.
90bf215546Sopenharmony_ci */
91bf215546Sopenharmony_ciGLubyte dummyBuffer[__GLX_BUFFER_LIMIT_SIZE];
92bf215546Sopenharmony_cistruct glx_context_vtable dummyVtable;
93bf215546Sopenharmony_cistruct glx_context dummyContext = {
94bf215546Sopenharmony_ci   &dummyBuffer[0],
95bf215546Sopenharmony_ci   &dummyBuffer[0],
96bf215546Sopenharmony_ci   &dummyBuffer[0],
97bf215546Sopenharmony_ci   &dummyBuffer[__GLX_BUFFER_LIMIT_SIZE],
98bf215546Sopenharmony_ci   sizeof(dummyBuffer),
99bf215546Sopenharmony_ci   &dummyVtable
100bf215546Sopenharmony_ci};
101bf215546Sopenharmony_ci__THREAD_INITIAL_EXEC void *__glX_tls_Context = &dummyContext;
102