Clone of mesa.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

fake_glx_screen.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright © 2011 Intel Corporation
  3. *
  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:
  10. *
  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
  13. * Software.
  14. *
  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.
  22. */
  23. extern "C" {
  24. #include "glxclient.h"
  25. };
  26. class fake_glx_screen : public glx_screen {
  27. public:
  28. fake_glx_screen(struct glx_display *glx_dpy, int num, const char *ext)
  29. {
  30. this->vtable = &fake_glx_screen::vt;
  31. this->serverGLXexts = 0;
  32. this->effectiveGLXexts = 0;
  33. this->display = 0;
  34. this->dpy = 0;
  35. this->scr = num;
  36. this->visuals = 0;
  37. this->configs = 0;
  38. this->display = glx_dpy;
  39. this->dpy = (glx_dpy != NULL) ? glx_dpy->dpy : NULL;
  40. this->serverGLXexts = new char[strlen(ext)];
  41. strcpy((char *) this->serverGLXexts, ext);
  42. }
  43. ~fake_glx_screen()
  44. {
  45. delete [] this->serverGLXexts;
  46. }
  47. private:
  48. static struct glx_screen_vtable vt;
  49. };
  50. class fake_glx_screen_direct : public fake_glx_screen {
  51. public:
  52. fake_glx_screen_direct(struct glx_display *glx_dpy, int num,
  53. const char *ext)
  54. : fake_glx_screen(glx_dpy, num, ext)
  55. {
  56. this->vtable = &fake_glx_screen_direct::vt;
  57. }
  58. private:
  59. static struct glx_screen_vtable vt;
  60. };
  61. class fake_glx_context : public glx_context {
  62. public:
  63. fake_glx_context(struct glx_screen *psc, struct glx_config *mode)
  64. {
  65. contexts_allocated++;
  66. this->vtable = &fake_glx_context::vt;
  67. this->majorOpcode = 123;
  68. this->screen = psc->scr;
  69. this->psc = psc;
  70. this->config = mode;
  71. this->isDirect = false;
  72. this->currentContextTag = -1;
  73. this->client_state_private = (struct __GLXattributeRec *) 0xcafebabe;
  74. }
  75. ~fake_glx_context()
  76. {
  77. contexts_allocated--;
  78. }
  79. static glx_context *create_attribs(struct glx_screen *psc,
  80. struct glx_config *mode,
  81. struct glx_context *shareList,
  82. unsigned num_attribs,
  83. const uint32_t *attribs,
  84. unsigned *error)
  85. {
  86. (void) shareList;
  87. (void) num_attribs;
  88. (void) attribs;
  89. *error = 0;
  90. return new fake_glx_context(psc, mode);
  91. }
  92. /** Number of context that are allocated (and not freed). */
  93. static int contexts_allocated;
  94. private:
  95. static const struct glx_context_vtable vt;
  96. static void destroy(struct glx_context *gc)
  97. {
  98. delete gc;
  99. }
  100. };
  101. class fake_glx_context_direct : public fake_glx_context {
  102. public:
  103. fake_glx_context_direct(struct glx_screen *psc, struct glx_config *mode)
  104. : fake_glx_context(psc, mode)
  105. {
  106. this->isDirect = True;
  107. }
  108. static glx_context *create(struct glx_screen *psc, struct glx_config *mode,
  109. struct glx_context *shareList, int renderType)
  110. {
  111. (void) shareList;
  112. (void) renderType;
  113. return new fake_glx_context_direct(psc, mode);
  114. }
  115. static glx_context *create_attribs(struct glx_screen *psc,
  116. struct glx_config *mode,
  117. struct glx_context *shareList,
  118. unsigned num_attribs,
  119. const uint32_t *attribs,
  120. unsigned *error)
  121. {
  122. (void) shareList;
  123. (void) num_attribs;
  124. (void) attribs;
  125. *error = 0;
  126. return new fake_glx_context_direct(psc, mode);
  127. }
  128. };