MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / visTest

Function visTest

server/eglxfakerut.cpp:481–548  ·  view source on GitHub ↗

This tests the faker's client/server visual matching heuristics

Source from the content-addressed store, hash-verified

479
480// This tests the faker's client/server visual matching heuristics
481int visTest(void)
482{
483 Display *dpy = NULL;
484 EGLDisplay edpy = 0;
485 EGLConfig *configs = NULL;
486 EGLint nc = 0;
487 int retval = 1;
488
489 printf("Visual matching heuristics test\n\n");
490
491 try
492 {
493 if(!(dpy = XOpenDisplay(0))) THROW("Could not open display");
494
495 if((edpy = eglGetDisplay(dpy)) == EGL_NO_DISPLAY)
496 THROW_EGL("eglGetDisplay()");
497 if(!eglInitialize(edpy, NULL, NULL))
498 THROW_EGL("eglInitialize()");
499
500 if(!(eglGetConfigs(edpy, NULL, 1, &nc)))
501 THROW_EGL("eglGetConfigs()");
502 configs = new EGLConfig[nc];
503 if(!(eglGetConfigs(edpy, configs, nc, &nc)))
504 THROW_EGL("eglGetConfigs()");
505
506 for(EGLint i = 0; i < nc; i++)
507 {
508 EGLint surfaceType, transparentType, nativeRenderable, visualID,
509 visualType;
510 GET_CFG_ATTRIB(configs[i], EGL_SURFACE_TYPE, surfaceType);
511 if(surfaceType & (EGL_PIXMAP_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT))
512 PRERROR1("CFG 0x%.2x claims to support surface types that it doesn't actually support",
513 EGLConfigID(edpy, configs[i]));
514 GET_CFG_ATTRIB(configs[i], EGL_TRANSPARENT_TYPE, transparentType);
515 GET_CFG_ATTRIB(configs[i], EGL_NATIVE_RENDERABLE, nativeRenderable);
516 GET_CFG_ATTRIB(configs[i], EGL_NATIVE_VISUAL_ID, visualID);
517 GET_CFG_ATTRIB(configs[i], EGL_NATIVE_VISUAL_TYPE, visualType);
518
519 // VirtualGL should return a visual only for opaque GLXFBConfigs that
520 // support native rendering.
521 XVisualInfo *vis =
522 getVisualFromConfig(dpy, DefaultScreen(dpy), edpy, configs[i]);
523 bool hasVis = (vis != NULL);
524 if(vis) XFree(vis);
525 bool shouldHaveVis =
526 ((surfaceType & (EGL_WINDOW_BIT | EGL_PIXMAP_BIT)) != 0
527 && transparentType == EGL_NONE && nativeRenderable == EGL_TRUE
528 && visualID != 0 && visualType == TrueColor);
529 if(hasVis != shouldHaveVis)
530 PRERROR1(hasVis ?
531 "CFG 0x%.2x shouldn't have matching X visual but does" :
532 "No matching X visual for CFG 0x%.2x",
533 EGLConfigID(edpy, configs[i]));
534 }
535
536 printf("SUCCESS!\n");
537 }
538 catch(std::exception &e)

Callers 1

mainFunction · 0.70

Calls 10

XOpenDisplayFunction · 0.85
eglGetDisplayFunction · 0.85
eglInitializeFunction · 0.85
eglGetConfigsFunction · 0.85
XFreeFunction · 0.85
eglTerminateFunction · 0.85
XCloseDisplayFunction · 0.85
whatMethod · 0.80
EGLConfigIDFunction · 0.70
getVisualFromConfigFunction · 0.70

Tested by

no test coverage detected