fake_glx_screen.h revision b8e80941
11.80Sad/* 21.2Sad * Copyright © 2011 Intel Corporation 31.2Sad * 41.75Sad * Permission is hereby granted, free of charge, to any person obtaining a 51.75Sad * copy of this software and associated documentation files (the "Software"), 61.2Sad * to deal in the Software without restriction, including without limitation 71.2Sad * the rights to use, copy, modify, merge, publish, distribute, sublicense, 81.2Sad * and/or sell copies of the Software, and to permit persons to whom the 91.2Sad * Software is furnished to do so, subject to the following conditions: 101.2Sad * 111.2Sad * The above copyright notice and this permission notice (including the next 121.2Sad * paragraph) shall be included in all copies or substantial portions of the 131.2Sad * Software. 141.2Sad * 151.2Sad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 161.2Sad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 171.2Sad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 181.2Sad * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 191.2Sad * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 201.2Sad * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 211.2Sad * DEALINGS IN THE SOFTWARE. 221.2Sad */ 231.2Sad#include "glxclient.h" 241.2Sad 251.2Sadclass fake_glx_screen : public glx_screen { 261.2Sadpublic: 271.2Sad fake_glx_screen(struct glx_display *glx_dpy, int num, const char *ext) 281.2Sad { 291.2Sad this->vtable = &fake_glx_screen::vt; 301.2Sad this->serverGLXexts = 0; 311.2Sad this->effectiveGLXexts = 0; 321.2Sad this->display = 0; 331.2Sad this->dpy = 0; 341.2Sad this->scr = num; 351.2Sad this->visuals = 0; 361.2Sad this->configs = 0; 371.2Sad 381.2Sad this->display = glx_dpy; 391.80Sad this->dpy = (glx_dpy != NULL) ? glx_dpy->dpy : NULL; 401.2Sad 411.2Sad this->serverGLXexts = new char[strlen(ext) + 1]; 421.2Sad strcpy((char *) this->serverGLXexts, ext); 431.9Syamt } 441.47Smatt 451.2Sad ~fake_glx_screen() 461.2Sad { 471.2Sad delete [] this->serverGLXexts; 481.2Sad } 491.2Sad 501.2Sadprivate: 511.2Sad static struct glx_screen_vtable vt; 521.2Sad}; 531.47Smatt 541.47Smattclass fake_glx_screen_direct : public fake_glx_screen { 551.47Smattpublic: 561.47Smatt fake_glx_screen_direct(struct glx_display *glx_dpy, int num, 571.47Smatt const char *ext) 581.47Smatt : fake_glx_screen(glx_dpy, num, ext) 591.47Smatt { 601.47Smatt this->vtable = &fake_glx_screen_direct::vt; 611.47Smatt } 621.47Smatt 631.47Smattprivate: 641.47Smatt static struct glx_screen_vtable vt; 651.47Smatt}; 661.39Srmind 671.2Sadclass fake_glx_context : public glx_context { 681.45Srmindpublic: 691.52Sad fake_glx_context(struct glx_screen *psc, struct glx_config *mode) 701.55Sad { 711.2Sad contexts_allocated++; 721.2Sad 731.2Sad this->vtable = &fake_glx_context::vt; 741.2Sad this->majorOpcode = 123; 751.2Sad this->screen = psc->scr; 761.2Sad this->psc = psc; 771.2Sad this->config = mode; 781.2Sad this->isDirect = false; 791.2Sad this->currentContextTag = -1; 801.56Sad 811.2Sad this->client_state_private = (struct __GLXattributeRec *) 0xcafebabe; 821.2Sad } 831.2Sad 841.56Sad ~fake_glx_context() 851.56Sad { 861.56Sad contexts_allocated--; 871.56Sad } 881.52Sad 891.2Sad /** Number of context that are allocated (and not freed). */ 901.56Sad static int contexts_allocated; 911.2Sad 921.2Sadprivate: 931.2Sad static const struct glx_context_vtable vt; 941.2Sad 951.2Sad static void destroy(struct glx_context *gc) 961.2Sad { 971.2Sad delete gc; 981.2Sad } 991.30Sad}; 1001.2Sad 1011.2Sadclass fake_glx_context_direct : public fake_glx_context { 1021.63Sadpublic: 1031.2Sad fake_glx_context_direct(struct glx_screen *psc, struct glx_config *mode) 1041.2Sad : fake_glx_context(psc, mode) 1051.2Sad { 1061.2Sad this->isDirect = True; 1071.2Sad } 1081.37Srmind 1091.2Sad static glx_context *create(struct glx_screen *psc, struct glx_config *mode, 1101.37Srmind struct glx_context *shareList, int renderType) 1111.8Sad { 1121.2Sad (void) shareList; 1131.9Syamt (void) renderType; 1141.2Sad 1151.2Sad return new fake_glx_context_direct(psc, mode); 1161.30Sad } 1171.2Sad 1181.59Sad static glx_context *create_attribs(struct glx_screen *psc, 1191.59Sad struct glx_config *mode, 1201.63Sad struct glx_context *shareList, 1211.59Sad unsigned num_attribs, 1221.59Sad const uint32_t *attribs, 1231.59Sad unsigned *error) 1241.59Sad { 1251.2Sad (void) shareList; 1261.2Sad (void) num_attribs; 1271.2Sad (void) attribs; 1281.5Spavel 1291.2Sad *error = 0; 1301.9Syamt return new fake_glx_context_direct(psc, mode); 1311.9Syamt } 1321.9Syamt}; 1331.2Sad