2 * Copyright © 2011 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #include "glxclient.h"
27 class fake_glx_screen
: public glx_screen
{
29 fake_glx_screen(struct glx_display
*glx_dpy
, int num
, const char *ext
)
31 this->vtable
= &fake_glx_screen::vt
;
32 this->serverGLXexts
= 0;
33 this->effectiveGLXexts
= 0;
40 this->display
= glx_dpy
;
41 this->dpy
= (glx_dpy
!= NULL
) ? glx_dpy
->dpy
: NULL
;
43 this->serverGLXexts
= new char[strlen(ext
) + 1];
44 strcpy((char *) this->serverGLXexts
, ext
);
49 delete [] this->serverGLXexts
;
53 static struct glx_screen_vtable vt
;
56 class fake_glx_screen_direct
: public fake_glx_screen
{
58 fake_glx_screen_direct(struct glx_display
*glx_dpy
, int num
,
60 : fake_glx_screen(glx_dpy
, num
, ext
)
62 this->vtable
= &fake_glx_screen_direct::vt
;
66 static struct glx_screen_vtable vt
;
69 class fake_glx_context
: public glx_context
{
71 fake_glx_context(struct glx_screen
*psc
, struct glx_config
*mode
)
75 this->vtable
= &fake_glx_context::vt
;
76 this->majorOpcode
= 123;
77 this->screen
= psc
->scr
;
80 this->isDirect
= false;
81 this->currentContextTag
= -1;
83 this->client_state_private
= (struct __GLXattributeRec
*) 0xcafebabe;
91 /** Number of context that are allocated (and not freed). */
92 static int contexts_allocated
;
95 static const struct glx_context_vtable vt
;
97 static void destroy(struct glx_context
*gc
)
103 class fake_glx_context_direct
: public fake_glx_context
{
105 fake_glx_context_direct(struct glx_screen
*psc
, struct glx_config
*mode
)
106 : fake_glx_context(psc
, mode
)
108 this->isDirect
= True
;
111 static glx_context
*create(struct glx_screen
*psc
, struct glx_config
*mode
,
112 struct glx_context
*shareList
, int renderType
)
117 return new fake_glx_context_direct(psc
, mode
);
120 static glx_context
*create_attribs(struct glx_screen
*psc
,
121 struct glx_config
*mode
,
122 struct glx_context
*shareList
,
123 unsigned num_attribs
,
124 const uint32_t *attribs
,
132 return new fake_glx_context_direct(psc
, mode
);