Changeset 65537 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Jan 31, 2017 11:18:37 AM (8 years ago)
- Location:
- trunk/src/VBox/Additions/common/crOpenGL
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/crOpenGL/glx.c
r65124 r65537 37 37 #include <X11/Xregion.h> 38 38 39 //#define VBOX_NO_NATIVEGL40 41 39 /* Force full pixmap update if there're more damaged regions than this number*/ 42 40 #define CR_MAX_DAMAGE_REGIONS_TRACKED 50 … … 74 72 }; 75 73 76 #ifndef VBOX_NO_NATIVEGL /* Old code */77 static struct VisualInfo *VisualInfoList = NULL;78 #endif79 80 74 static void stubXshmUpdateImageRect(Display *dpy, GLXDrawable draw, GLX_Pixmap_t *pGlxPixmap, XRectangle *pRect); 81 75 static void stubQueryXDamageExtension(Display *dpy, ContextInfo *pContext); 82 76 83 #ifndef VBOX_NO_NATIVEGL /* Old code */84 85 static void86 AddVisualInfo(Display *dpy, int screen, VisualID visualid, int visBits)87 {88 struct VisualInfo *v;89 for (v = VisualInfoList; v; v = v->next) {90 if (v->dpy == dpy && v->screen == screen && v->visualid == visualid) {91 v->visBits |= visBits;92 return;93 }94 }95 v = (struct VisualInfo *) crAlloc(sizeof(struct VisualInfo));96 v->dpy = dpy;97 v->screen = screen;98 v->visualid = visualid;99 v->visBits = visBits;100 v->next = VisualInfoList;101 VisualInfoList = v;102 }103 104 static struct VisualInfo *105 FindVisualInfo(Display *dpy, int screen, VisualID visualid)106 {107 struct VisualInfo *v;108 for (v = VisualInfoList; v; v = v->next) {109 if (v->dpy == dpy && v->screen == screen && v->visualid == visualid)110 return v;111 }112 return NULL;113 }114 115 /**116 * Return string for a GLX error code117 */118 static const char *glx_error_string(int err)119 {120 static const char *glxErrors[] = {121 "none",122 "GLX_BAD_SCREEN",123 "GLX_BAD_ATTRIBUTE",124 "GLX_NO_EXTENSION",125 "GLX_BAD_VISUAL",126 "GLX_BAD_CONTEXT",127 "GLX_BAD_VALUE",128 "GLX_BAD_ENUM"129 };130 if (err > 0 && err < 8) {131 return glxErrors[err];132 }133 else {134 static char tmp[100];135 sprintf(tmp, "0x%x", err);136 return tmp;137 }138 }139 140 /* Given an XVisualInfo structure, try to figure out what its141 * OpenGL capabilities are, if we have a native OpenGL.142 * Returns 0 if no information is available.143 */144 static struct {145 int gl_attrib;146 char *attrib_name;147 enum {TEST_TRUE, TEST_GREATER_0} test;148 int match_vis_bits;149 } attrib_map[] = {150 {GLX_RGBA, "GLX_RGBA", TEST_TRUE, CR_RGB_BIT},151 {GLX_DOUBLEBUFFER, "GLX_DOUBLEBUFFER", TEST_TRUE, CR_DOUBLE_BIT},152 {GLX_STEREO, "GLX_STEREO", TEST_TRUE, CR_STEREO_BIT},153 {GLX_LEVEL, "GLX_LEVEL", TEST_GREATER_0, CR_OVERLAY_BIT},154 {GLX_ALPHA_SIZE, "GLX_ALPHA_SIZE", TEST_GREATER_0, CR_ALPHA_BIT},155 {GLX_DEPTH_SIZE, "GLX_DEPTH_SIZE", TEST_GREATER_0, CR_DEPTH_BIT},156 {GLX_STENCIL_SIZE, "GLX_STENCIL_SIZE", TEST_GREATER_0, CR_STENCIL_BIT},157 {GLX_ACCUM_RED_SIZE, "GLX_ACCUM_RED_SIZE", TEST_GREATER_0, CR_ACCUM_BIT},158 {GLX_SAMPLE_BUFFERS_SGIS, "GLX_SAMPLE_BUFFERS_SGIS", TEST_GREATER_0, CR_MULTISAMPLE_BIT},159 };160 161 static int QueryVisBits(Display *dpy, XVisualInfo *vis)162 {163 int visBits = 0;164 int foo, bar, return_val, value;165 unsigned int i;166 167 /* We can only query the OpenGL capabilities if we actually168 * have a native OpenGL underneath us. Without it, we can't169 * get at all the actual OpenGL characteristics.170 */171 if (!stub.haveNativeOpenGL) return 0;172 173 if (!stub.wsInterface.glXQueryExtension(dpy, &foo, &bar)) return 0;174 175 /* If we don't have the GLX_USE_GL attribute, we've failed. */176 return_val = stub.wsInterface.glXGetConfig(dpy, vis, GLX_USE_GL, &value);177 if (return_val) {178 crDebug("native glXGetConfig returned %d (%s) at %s line %d",179 return_val, glx_error_string(return_val), __FILE__, __LINE__);180 return 0;181 }182 if (value == 0) {183 crDebug("visual ID 0x%x doesn't support OpenGL at %s line %d",184 (int) vis->visual->visualid, __FILE__, __LINE__);185 return 0;186 }187 188 for (i = 0; i < sizeof(attrib_map)/sizeof(attrib_map[0]); i++) {189 return_val = stub.wsInterface.glXGetConfig(dpy, vis, attrib_map[i].gl_attrib, &value);190 if (return_val) {191 crDebug("native glXGetConfig(%s) returned %d (%s) at %s line %d",192 attrib_map[i].attrib_name, return_val, glx_error_string(return_val), __FILE__, __LINE__);193 return 0;194 }195 196 switch(attrib_map[i].test) {197 case TEST_TRUE:198 if (value)199 visBits |= attrib_map[i].match_vis_bits;200 break;201 202 case TEST_GREATER_0:203 if (value > 0)204 visBits |= attrib_map[i].match_vis_bits;205 break;206 207 default:208 crWarning("illegal attribute map test for %s at %s line %d",209 attrib_map[i].attrib_name, __FILE__, __LINE__);210 return 0;211 }212 }213 214 return visBits;215 }216 217 #endif /* !VBOX_NO_NATIVEGL */218 219 220 221 #ifndef VBOX_NO_NATIVEGL /* Old code */222 77 DECLEXPORT(XVisualInfo *) 223 78 VBOXGLXTAG(glXChooseVisual)( Display *dpy, int screen, int *attribList ) 224 79 { 225 XVisualInfo *vis;80 bool useRGBA = false; 226 81 int *attrib; 227 int visBits = 0;228 82 XVisualInfo searchvis, *pret; 83 int nvisuals; 229 84 stubInit(); 230 85 … … 243 98 244 99 case GLX_LEVEL: 245 if (attrib[1] >0)246 visBits |= CR_OVERLAY_BIT;100 if (attrib[1] != 0) 101 goto err_exit; 247 102 attrib++; 248 103 break; 249 104 250 105 case GLX_RGBA: 251 visBits |= CR_RGB_BIT; 252 break; 253 254 case GLX_DOUBLEBUFFER: 255 visBits |= CR_DOUBLE_BIT; 106 useRGBA = true; 256 107 break; 257 108 258 109 case GLX_STEREO: 259 visBits |= CR_STEREO_BIT;110 goto err_exit; 260 111 /* 261 112 crWarning( "glXChooseVisual: stereo unsupported" ); … … 265 116 266 117 case GLX_AUX_BUFFERS: 267 { 268 int aux_buffers = attrib[1]; 269 if (aux_buffers != 0) 270 { 271 crWarning("glXChooseVisual: aux_buffers=%d unsupported", 272 aux_buffers); 273 return NULL; 274 } 275 } 118 if (attrib[1] != 0) 119 goto err_exit; 276 120 attrib++; 277 121 break; … … 280 124 case GLX_GREEN_SIZE: 281 125 case GLX_BLUE_SIZE: 282 if (attrib[1] > 0)283 visBits |= CR_RGB_BIT;126 if (attrib[1] > 8) 127 goto err_exit; 284 128 attrib++; 285 129 break; 286 130 287 131 case GLX_ALPHA_SIZE: 288 if (attrib[1] > 0)289 visBits |= CR_ALPHA_BIT;132 if (attrib[1] > 8) 133 goto err_exit; 290 134 attrib++; 291 135 break; 292 136 293 137 case GLX_DEPTH_SIZE: 294 if (attrib[1] > 0)295 visBits |= CR_DEPTH_BIT;138 if (attrib[1] > 24) 139 goto err_exit; 296 140 attrib++; 297 141 break; 298 142 299 143 case GLX_STENCIL_SIZE: 300 if (attrib[1] > 0)301 visBits |= CR_STENCIL_BIT;144 if (attrib[1] > 8) 145 goto err_exit; 302 146 attrib++; 303 147 break; … … 307 151 case GLX_ACCUM_BLUE_SIZE: 308 152 case GLX_ACCUM_ALPHA_SIZE: 309 if (attrib[1] > 0)310 visBits |= CR_ACCUM_BIT;153 if (attrib[1] > 16) 154 goto err_exit; 311 155 attrib++; 312 156 break; … … 314 158 case GLX_SAMPLE_BUFFERS_SGIS: /* aka GLX_SAMPLES_ARB */ 315 159 if (attrib[1] > 0) 316 visBits |= CR_MULTISAMPLE_BIT;160 goto err_exit; 317 161 attrib++; 318 162 break; 319 163 case GLX_SAMPLES_SGIS: /* aka GLX_SAMPLES_ARB */ 320 /* just ignore value for now, we'll try to get 4 samples/pixel */ 321 if (attrib[1] > 4) 322 return NULL; 323 visBits |= CR_MULTISAMPLE_BIT; 324 attrib++; 164 if (attrib[1] > 0) 165 goto err_exit; 166 attrib++; 167 break; 168 169 case GLX_DOUBLEBUFFER: /* @todo, check if we support it */ 325 170 break; 326 171 … … 340 185 341 186 default: 342 crWarning( "glXChooseVisual: bad attrib=0x%x", *attrib );343 return NULL;344 }345 }346 347 if ((visBits & CR_RGB_BIT) == 0 && (visBits & CR_OVERLAY_BIT) == 0)348 {349 /* normal layer, color index mode not supported */350 crWarning( "glXChooseVisual: didn't request RGB visual?" );351 return NULL;352 }353 354 vis = crChooseVisual(&stub.wsInterface, dpy, screen, GL_FALSE, visBits);355 if (!vis && (visBits & CR_STEREO_BIT)) {356 /* try non-stereo */357 visBits &= ~CR_STEREO_BIT;358 vis = crChooseVisual(&stub.wsInterface, dpy, screen, GL_FALSE, visBits);359 }360 361 if (vis) {362 AddVisualInfo(dpy, screen, vis->visual->visualid, visBits);363 }364 return vis;365 }366 #else /* not 0 */367 DECLEXPORT(XVisualInfo *)368 VBOXGLXTAG(glXChooseVisual)( Display *dpy, int screen, int *attribList )369 {370 bool useRGBA = false;371 int *attrib;372 XVisualInfo searchvis, *pret;373 int nvisuals;374 stubInit();375 376 for (attrib = attribList; *attrib != None; attrib++)377 {378 switch (*attrib)379 {380 case GLX_USE_GL:381 /* ignored, this is mandatory */382 break;383 384 case GLX_BUFFER_SIZE:385 /* this is for color-index visuals, which we don't support */386 attrib++;387 break;388 389 case GLX_LEVEL:390 if (attrib[1] != 0)391 goto err_exit;392 attrib++;393 break;394 395 case GLX_RGBA:396 useRGBA = true;397 break;398 399 case GLX_STEREO:400 goto err_exit;401 /*402 crWarning( "glXChooseVisual: stereo unsupported" );403 return NULL;404 */405 break;406 407 case GLX_AUX_BUFFERS:408 if (attrib[1] != 0)409 goto err_exit;410 attrib++;411 break;412 413 case GLX_RED_SIZE:414 case GLX_GREEN_SIZE:415 case GLX_BLUE_SIZE:416 if (attrib[1] > 8)417 goto err_exit;418 attrib++;419 break;420 421 case GLX_ALPHA_SIZE:422 if (attrib[1] > 8)423 goto err_exit;424 attrib++;425 break;426 427 case GLX_DEPTH_SIZE:428 if (attrib[1] > 24)429 goto err_exit;430 attrib++;431 break;432 433 case GLX_STENCIL_SIZE:434 if (attrib[1] > 8)435 goto err_exit;436 attrib++;437 break;438 439 case GLX_ACCUM_RED_SIZE:440 case GLX_ACCUM_GREEN_SIZE:441 case GLX_ACCUM_BLUE_SIZE:442 case GLX_ACCUM_ALPHA_SIZE:443 if (attrib[1] > 16)444 goto err_exit;445 attrib++;446 break;447 448 case GLX_SAMPLE_BUFFERS_SGIS: /* aka GLX_SAMPLES_ARB */449 if (attrib[1] > 0)450 goto err_exit;451 attrib++;452 break;453 case GLX_SAMPLES_SGIS: /* aka GLX_SAMPLES_ARB */454 if (attrib[1] > 0)455 goto err_exit;456 attrib++;457 break;458 459 case GLX_DOUBLEBUFFER: /* @todo, check if we support it */460 break;461 462 #ifdef GLX_VERSION_1_3463 case GLX_X_VISUAL_TYPE:464 case GLX_TRANSPARENT_TYPE_EXT:465 case GLX_TRANSPARENT_INDEX_VALUE_EXT:466 case GLX_TRANSPARENT_RED_VALUE_EXT:467 case GLX_TRANSPARENT_GREEN_VALUE_EXT:468 case GLX_TRANSPARENT_BLUE_VALUE_EXT:469 case GLX_TRANSPARENT_ALPHA_VALUE_EXT:470 /* ignore */471 crWarning("glXChooseVisual: ignoring attribute 0x%x", *attrib);472 attrib++;473 break;474 #endif475 476 default:477 187 crWarning( "glXChooseVisual: bad attrib=0x%x, ignoring", *attrib ); 478 188 attrib++; … … 498 208 return NULL; 499 209 } 500 #endif501 210 502 211 /** … … 538 247 const char *dpyName = DisplayString(dpy); 539 248 char host[1000]; 540 #ifndef VBOX_NO_NATIVEGL 541 if (dpyName[0] == ':') 542 { 543 crGetHostname(host, 1000); 544 } 545 else 546 #endif 547 { 548 host[0] = 0; 549 } 249 250 host[0] = 0; 550 251 if (crStrlen(host) + crStrlen(dpyName) >= maxResult - 1) 551 252 { … … 591 292 592 293 stubGetDisplayString(dpy, dpyName, MAX_DPY_NAME); 593 #ifndef VBOX_NO_NATIVEGL /* We only care about the host capabilities, not the guest. */594 if (stub.haveNativeOpenGL) {595 int foo, bar;596 if (stub.wsInterface.glXQueryExtension(dpy, &foo, &bar)) {597 /* If we have real GLX, compute the Chromium visual bitmask now.598 * otherwise, we'll use the default desiredVisual bitmask.599 */600 struct VisualInfo *v = FindVisualInfo(dpy, DefaultScreen(dpy),601 vis->visual->visualid);602 if (v) {603 visBits = v->visBits;604 /*crDebug("%s visBits=0x%x", __FUNCTION__, visBits);*/605 }606 else {607 /* For some reason, we haven't tested this visual608 * before. This could be because the visual was found609 * through a different display connection to the same610 * display (as happens in GeoProbe), or through a611 * connection to an external daemon that queries612 * visuals. If we can query it directly, we can still613 * find the proper visBits.614 */615 int newVisBits = QueryVisBits(dpy, vis);616 if (newVisBits > 0) {617 AddVisualInfo(dpy, DefaultScreen(dpy), vis->visual->visualid, newVisBits);618 crDebug("Application used unexpected but queryable visual id 0x%x", (int) vis->visual->visualid);619 visBits = newVisBits;620 }621 else {622 crWarning("Application used unexpected and unqueryable visual id 0x%x; using default visbits", (int) vis->visual->visualid);623 }624 }625 626 /*crDebug("ComputeVisBits(0x%x) = 0x%x", (int)vis->visual->visualid, visBits);*/627 if (stub.force_pbuffers) {628 crDebug("App faker: Forcing use of Pbuffers");629 visBits |= CR_PBUFFER_BIT;630 }631 632 if (!v) {633 AddVisualInfo(dpy, DefaultScreen(dpy),634 vis->visual->visualid, visBits);635 }636 637 }638 }639 else {640 crDebug("No native OpenGL; cannot compute visbits");641 }642 #endif643 294 644 295 context = stubNewContext(dpyName, visBits, UNDECIDED, (unsigned long) share); … … 758 409 } 759 410 760 #ifndef VBOX_NO_NATIVEGL /* old code */761 DECLEXPORT(int) VBOXGLXTAG(glXGetConfig)( Display *dpy, XVisualInfo *vis, int attrib, int *value )762 {763 struct VisualInfo *v;764 int visBits;765 766 if (!vis) {767 /* SGI OpenGL Performer hits this */768 crWarning("glXGetConfig called with NULL XVisualInfo");769 return GLX_BAD_VISUAL;770 }771 772 v = FindVisualInfo(dpy, DefaultScreen(dpy), vis->visual->visualid);773 if (v) {774 visBits = v->visBits;775 }776 else {777 visBits = 0;778 }779 780 stubInit();781 782 /* try to satisfy this request with the native glXGetConfig() */783 if (stub.haveNativeOpenGL)784 {785 int foo, bar;786 int return_val;787 788 if (stub.wsInterface.glXQueryExtension(dpy, &foo, &bar))789 {790 return_val = stub.wsInterface.glXGetConfig( dpy, vis, attrib, value );791 if (return_val)792 {793 crDebug("faker native glXGetConfig returned %s",794 glx_error_string(return_val));795 }796 return return_val;797 }798 }799 800 /*801 * If the GLX application chooses its visual via a bunch of calls to802 * glXGetConfig, instead of by calling glXChooseVisual, we need to keep803 * track of which attributes are queried to help satisfy context creation804 * later.805 */806 switch ( attrib ) {807 808 case GLX_USE_GL:809 *value = 1;810 break;811 812 case GLX_BUFFER_SIZE:813 *value = 32;814 break;815 816 case GLX_LEVEL:817 visBits |= CR_OVERLAY_BIT;818 *value = (visBits & CR_OVERLAY_BIT) ? 1 : 0;819 break;820 821 case GLX_RGBA:822 visBits |= CR_RGB_BIT;823 *value = 1;824 break;825 826 case GLX_DOUBLEBUFFER:827 *value = 1;828 break;829 830 case GLX_STEREO:831 *value = 1;832 break;833 834 case GLX_AUX_BUFFERS:835 *value = 0;836 break;837 838 case GLX_RED_SIZE:839 *value = 8;840 break;841 842 case GLX_GREEN_SIZE:843 *value = 8;844 break;845 846 case GLX_BLUE_SIZE:847 *value = 8;848 break;849 850 case GLX_ALPHA_SIZE:851 visBits |= CR_ALPHA_BIT;852 *value = (visBits & CR_ALPHA_BIT) ? 8 : 0;853 break;854 855 case GLX_DEPTH_SIZE:856 visBits |= CR_DEPTH_BIT;857 *value = 24;858 break;859 860 case GLX_STENCIL_SIZE:861 visBits |= CR_STENCIL_BIT;862 *value = 8;863 break;864 865 case GLX_ACCUM_RED_SIZE:866 visBits |= CR_ACCUM_BIT;867 *value = 16;868 break;869 870 case GLX_ACCUM_GREEN_SIZE:871 visBits |= CR_ACCUM_BIT;872 *value = 16;873 break;874 875 case GLX_ACCUM_BLUE_SIZE:876 visBits |= CR_ACCUM_BIT;877 *value = 16;878 break;879 880 case GLX_ACCUM_ALPHA_SIZE:881 visBits |= CR_ACCUM_BIT;882 *value = 16;883 break;884 885 case GLX_SAMPLE_BUFFERS_SGIS:886 visBits |= CR_MULTISAMPLE_BIT;887 *value = 0; /* fix someday */888 break;889 890 case GLX_SAMPLES_SGIS:891 visBits |= CR_MULTISAMPLE_BIT;892 *value = 0; /* fix someday */893 break;894 895 case GLX_VISUAL_CAVEAT_EXT:896 *value = GLX_NONE_EXT;897 break;898 #if defined(SunOS)899 /*900 I don't think this is even a valid attribute for glxGetConfig.901 No idea why this gets called under SunOS but we simply ignore it902 -- jw903 */904 case GLX_X_VISUAL_TYPE:905 crWarning ("Ignoring Unsupported GLX Call: glxGetConfig with attrib 0x%x", attrib);906 break;907 #endif908 909 case GLX_TRANSPARENT_TYPE:910 *value = GLX_NONE_EXT;911 break;912 case GLX_TRANSPARENT_INDEX_VALUE:913 *value = 0;914 break;915 case GLX_TRANSPARENT_RED_VALUE:916 *value = 0;917 break;918 case GLX_TRANSPARENT_GREEN_VALUE:919 *value = 0;920 break;921 case GLX_TRANSPARENT_BLUE_VALUE:922 *value = 0;923 break;924 case GLX_TRANSPARENT_ALPHA_VALUE:925 *value = 0;926 break;927 default:928 crWarning( "Unsupported GLX Call: glXGetConfig with attrib 0x%x", attrib );929 return GLX_BAD_ATTRIBUTE;930 }931 932 AddVisualInfo(dpy, DefaultScreen(dpy), vis->visual->visualid, visBits);933 934 return 0;935 }936 #else /* not 0 */937 411 DECLEXPORT(int) VBOXGLXTAG(glXGetConfig)( Display *dpy, XVisualInfo *vis, int attrib, int *value ) 938 412 { … … 1070 544 return 0; 1071 545 } 1072 #endif1073 546 1074 547 DECLEXPORT(GLXContext) VBOXGLXTAG(glXGetCurrentContext)( void ) … … 1115 588 } 1116 589 1117 #ifdef VBOX_TEST_MEGOO1118 static XErrorHandler oldErrorHandler;1119 static unsigned char lastXError = Success;1120 1121 static int1122 errorHandler (Display *dpy, XErrorEvent *e)1123 {1124 (void)dpy;1125 lastXError = e->error_code;1126 return 0;1127 }1128 #endif /* VBOX_TEST_MGEOO */1129 1130 590 DECLEXPORT(void) VBOXGLXTAG(glXSwapBuffers)( Display *dpy, GLXDrawable drawable ) 1131 591 { 1132 592 WindowInfo *window = stubGetWindowInfo(dpy, drawable); 1133 593 stubSwapBuffers( window, 0 ); 1134 1135 #ifdef VBOX_TEST_MEGOO 1136 if (!stub.bXExtensionsChecked) 1137 { 1138 stubCheckXExtensions(window); 1139 } 1140 1141 if (!stub.bHaveXComposite) 1142 { 1143 return; 1144 } 1145 1146 { 1147 Pixmap p; 1148 XWindowAttributes attr; 1149 1150 XLOCK(dpy); 1151 XGetWindowAttributes(dpy, window->drawable, &attr); 1152 if (attr.override_redirect) 1153 { 1154 XUNLOCK(dpy); 1155 return; 1156 } 1157 1158 crLockMutex(&stub.mutex); 1159 1160 XSync(dpy, false); 1161 oldErrorHandler = XSetErrorHandler(errorHandler); 1162 /*@todo this creates new pixmap for window every call*/ 1163 /*p = XCompositeNameWindowPixmap(dpy, window->drawable);*/ 1164 XSync(dpy, false); 1165 XSetErrorHandler(oldErrorHandler); 1166 XUNLOCK(dpy); 1167 1168 if (lastXError==Success) 1169 { 1170 char *data, *imgdata; 1171 GC gc; 1172 XImage *image; 1173 XVisualInfo searchvis, *pret; 1174 int nvisuals; 1175 XGCValues gcValues; 1176 int i, rowsize; 1177 1178 XLOCK(dpy); 1179 1180 searchvis.visualid = attr.visual->visualid; 1181 pret = XGetVisualInfo(dpy, VisualIDMask, &searchvis, &nvisuals); 1182 if (nvisuals!=1) crWarning("XGetVisualInfo returned %i visuals for %x", nvisuals, (unsigned int) searchvis.visualid); 1183 CRASSERT(pret); 1184 1185 gc = XCreateGC(dpy, window->drawable, 0, &gcValues); 1186 if (!gc) crWarning("Failed to create gc!"); 1187 1188 data = crCalloc(window->width * window->height * 4); 1189 imgdata = crCalloc(window->width * window->height * 4); 1190 CRASSERT(data && imgdata); 1191 stub.spu->dispatch_table.ReadPixels(0, 0, window->width, window->height, GL_RGBA, GL_UNSIGNED_BYTE, data); 1192 /*y-invert image*/ 1193 rowsize = 4*window->width; 1194 for (i=0; i<window->height; ++i) 1195 { 1196 crMemcpy(imgdata+rowsize*i, data+rowsize*(window->height-i-1), rowsize); 1197 } 1198 crFree(data); 1199 1200 XSync(dpy, false); 1201 image = XCreateImage(dpy, attr.visual, pret->depth, ZPixmap, 0, imgdata, window->width, window->height, 32, 0); 1202 XPutImage(dpy, window->drawable, gc, image, 0, 0, 0, 0, window->width, window->height); 1203 1204 XFree(pret); 1205 /*XFreePixmap(dpy, p);*/ 1206 XFreeGC(dpy, gc); 1207 XDestroyImage(image); 1208 XUNLOCK(dpy); 1209 } 1210 lastXError=Success; 1211 crUnlockMutex(&stub.mutex); 1212 } 1213 #endif 1214 } 1215 1216 #ifndef VBOX_NO_NATIVEGL 1217 DECLEXPORT(void) VBOXGLXTAG(glXUseXFont)( Font font, int first, int count, int listBase ) 1218 { 1219 ContextInfo *context = stubGetCurrentContext(); 1220 if (context->type == CHROMIUM) 1221 { 1222 Display *dpy = stub.wsInterface.glXGetCurrentDisplay(); 1223 if (dpy) { 1224 stubUseXFont( dpy, font, first, count, listBase ); 1225 } 1226 else { 1227 dpy = XOpenDisplay(NULL); 1228 if (!dpy) 1229 return; 1230 stubUseXFont( dpy, font, first, count, listBase ); 1231 XCloseDisplay(dpy); 1232 } 1233 } else 1234 stub.wsInterface.glXUseXFont( font, first, count, listBase ); 1235 } 1236 #else /* not 0 */ 594 } 595 1237 596 DECLEXPORT(void) VBOXGLXTAG(glXUseXFont)( Font font, int first, int count, int listBase ) 1238 597 { … … 1250 609 } 1251 610 } 1252 #endif1253 611 1254 612 DECLEXPORT(void) VBOXGLXTAG(glXWaitGL)( void ) -
trunk/src/VBox/Additions/common/crOpenGL/stub.c
r63204 r65537 500 500 if (!pWindow->pVisibleRegions && !cRects) 501 501 { 502 #ifdef VBOX_TEST_MEGOO503 XWindowAttributes attr;504 XLOCK(dpy);505 XSync(dpy, false);506 XGetWindowAttributes(dpy, pWindow->drawable, &attr);507 XUNLOCK(dpy);508 509 bNoUpdate = attr.override_redirect;510 #else511 502 bNoUpdate = true; 512 #endif513 503 } 514 504 -
trunk/src/VBox/Additions/common/crOpenGL/stub.h
r63204 r65537 59 59 # include <cr_threads.h> 60 60 #endif 61 /*#define VBOX_TEST_MEGOO*/62 61 63 62 #if 0 && defined(CR_NEWWINTRACK) && !defined(WINDOWS)
Note:
See TracChangeset
for help on using the changeset viewer.