1af69d88dSmrg/* 2af69d88dSmrg * Copyright © 2011 Intel Corporation 3af69d88dSmrg * 4af69d88dSmrg * Permission is hereby granted, free of charge, to any person obtaining a 5af69d88dSmrg * copy of this software and associated documentation files (the "Software"), 6af69d88dSmrg * to deal in the Software without restriction, including without limitation 7af69d88dSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8af69d88dSmrg * and/or sell copies of the Software, and to permit persons to whom the 9af69d88dSmrg * Software is furnished to do so, subject to the following conditions: 10af69d88dSmrg * 11af69d88dSmrg * The above copyright notice and this permission notice (including the next 12af69d88dSmrg * paragraph) shall be included in all copies or substantial portions of the 13af69d88dSmrg * Software. 14af69d88dSmrg * 15af69d88dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16af69d88dSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17af69d88dSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19af69d88dSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20af69d88dSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21af69d88dSmrg * DEALINGS IN THE SOFTWARE. 22af69d88dSmrg */ 23af69d88dSmrg#include "glxclient.h" 24af69d88dSmrg 25af69d88dSmrgclass fake_glx_screen : public glx_screen { 26af69d88dSmrgpublic: 27af69d88dSmrg fake_glx_screen(struct glx_display *glx_dpy, int num, const char *ext) 28af69d88dSmrg { 29af69d88dSmrg this->vtable = &fake_glx_screen::vt; 30af69d88dSmrg this->serverGLXexts = 0; 31af69d88dSmrg this->effectiveGLXexts = 0; 32af69d88dSmrg this->display = 0; 33af69d88dSmrg this->dpy = 0; 34af69d88dSmrg this->scr = num; 35af69d88dSmrg this->visuals = 0; 36af69d88dSmrg this->configs = 0; 37af69d88dSmrg 38af69d88dSmrg this->display = glx_dpy; 39af69d88dSmrg this->dpy = (glx_dpy != NULL) ? glx_dpy->dpy : NULL; 40af69d88dSmrg 41af69d88dSmrg this->serverGLXexts = new char[strlen(ext) + 1]; 42af69d88dSmrg strcpy((char *) this->serverGLXexts, ext); 43af69d88dSmrg } 44af69d88dSmrg 45af69d88dSmrg ~fake_glx_screen() 46af69d88dSmrg { 47af69d88dSmrg delete [] this->serverGLXexts; 48af69d88dSmrg } 49af69d88dSmrg 50af69d88dSmrgprivate: 51af69d88dSmrg static struct glx_screen_vtable vt; 52af69d88dSmrg}; 53af69d88dSmrg 54af69d88dSmrgclass fake_glx_screen_direct : public fake_glx_screen { 55af69d88dSmrgpublic: 56af69d88dSmrg fake_glx_screen_direct(struct glx_display *glx_dpy, int num, 57af69d88dSmrg const char *ext) 58af69d88dSmrg : fake_glx_screen(glx_dpy, num, ext) 59af69d88dSmrg { 60af69d88dSmrg this->vtable = &fake_glx_screen_direct::vt; 61af69d88dSmrg } 62af69d88dSmrg 63af69d88dSmrgprivate: 64af69d88dSmrg static struct glx_screen_vtable vt; 65af69d88dSmrg}; 66af69d88dSmrg 67af69d88dSmrgclass fake_glx_context : public glx_context { 68af69d88dSmrgpublic: 69af69d88dSmrg fake_glx_context(struct glx_screen *psc, struct glx_config *mode) 70af69d88dSmrg { 71af69d88dSmrg contexts_allocated++; 72af69d88dSmrg 73af69d88dSmrg this->vtable = &fake_glx_context::vt; 74af69d88dSmrg this->majorOpcode = 123; 75af69d88dSmrg this->screen = psc->scr; 76af69d88dSmrg this->psc = psc; 77af69d88dSmrg this->config = mode; 78af69d88dSmrg this->isDirect = false; 79af69d88dSmrg this->currentContextTag = -1; 80af69d88dSmrg 81af69d88dSmrg this->client_state_private = (struct __GLXattributeRec *) 0xcafebabe; 82af69d88dSmrg } 83af69d88dSmrg 84af69d88dSmrg ~fake_glx_context() 85af69d88dSmrg { 86af69d88dSmrg contexts_allocated--; 87af69d88dSmrg } 88af69d88dSmrg 89af69d88dSmrg /** Number of context that are allocated (and not freed). */ 90af69d88dSmrg static int contexts_allocated; 91af69d88dSmrg 92af69d88dSmrgprivate: 93af69d88dSmrg static const struct glx_context_vtable vt; 94af69d88dSmrg 95af69d88dSmrg static void destroy(struct glx_context *gc) 96af69d88dSmrg { 97af69d88dSmrg delete gc; 98af69d88dSmrg } 99af69d88dSmrg}; 100af69d88dSmrg 101af69d88dSmrgclass fake_glx_context_direct : public fake_glx_context { 102af69d88dSmrgpublic: 103af69d88dSmrg fake_glx_context_direct(struct glx_screen *psc, struct glx_config *mode) 104af69d88dSmrg : fake_glx_context(psc, mode) 105af69d88dSmrg { 106af69d88dSmrg this->isDirect = True; 107af69d88dSmrg } 108af69d88dSmrg 109af69d88dSmrg static glx_context *create(struct glx_screen *psc, struct glx_config *mode, 110af69d88dSmrg struct glx_context *shareList, int renderType) 111af69d88dSmrg { 112af69d88dSmrg (void) shareList; 113af69d88dSmrg (void) renderType; 114af69d88dSmrg 115af69d88dSmrg return new fake_glx_context_direct(psc, mode); 116af69d88dSmrg } 117af69d88dSmrg 118af69d88dSmrg static glx_context *create_attribs(struct glx_screen *psc, 119af69d88dSmrg struct glx_config *mode, 120af69d88dSmrg struct glx_context *shareList, 121af69d88dSmrg unsigned num_attribs, 122af69d88dSmrg const uint32_t *attribs, 123af69d88dSmrg unsigned *error) 124af69d88dSmrg { 125af69d88dSmrg (void) shareList; 126af69d88dSmrg (void) num_attribs; 127af69d88dSmrg (void) attribs; 128af69d88dSmrg 129af69d88dSmrg *error = 0; 130af69d88dSmrg return new fake_glx_context_direct(psc, mode); 131af69d88dSmrg } 132af69d88dSmrg}; 133