| 327 | // already been read. |
| 328 | |
| 329 | static VisualID matchVisual2D(Display *dpy, int screen, int depth, int c_class, |
| 330 | int bpc, int stereo, bool strictMatch) |
| 331 | { |
| 332 | int i, tryStereo; |
| 333 | if(!dpy) return 0; |
| 334 | |
| 335 | buildVisAttribTable(dpy, screen); |
| 336 | GET_VA_TABLE() |
| 337 | |
| 338 | // Try to find an exact match |
| 339 | for(tryStereo = 1; tryStereo >= 0; tryStereo--) |
| 340 | { |
| 341 | for(i = 0; i < vaEntries; i++) |
| 342 | { |
| 343 | int match = 1; |
| 344 | if(va[i].c_class != c_class) match = 0; |
| 345 | if(strictMatch) |
| 346 | { |
| 347 | if(va[i].depth != depth) match = 0; |
| 348 | if(va[i].bpc != bpc && va[i].depth > 30) match = 0; |
| 349 | } |
| 350 | else |
| 351 | { |
| 352 | if(depth == 24 && (va[i].depth != 24 |
| 353 | && (va[i].depth != 32 || va[i].bpc != 8))) |
| 354 | match = 0; |
| 355 | if(depth == 30 && (va[i].depth != 30 |
| 356 | && (va[i].depth != 32 || va[i].bpc != 10))) |
| 357 | match = 0; |
| 358 | if(depth == 32 && bpc == 8 && (va[i].depth != 24 |
| 359 | && (va[i].depth != depth || va[i].bpc != bpc))) |
| 360 | match = 0; |
| 361 | if(depth == 32 && bpc == 10 && (va[i].depth != 30 |
| 362 | && (va[i].depth != depth || va[i].bpc != bpc))) |
| 363 | match = 0; |
| 364 | } |
| 365 | if(fconfig.stereo == RRSTEREO_QUADBUF && tryStereo) |
| 366 | { |
| 367 | if(stereo != va[i].isStereo) match = 0; |
| 368 | if(stereo && !va[i].isDB) match = 0; |
| 369 | if(stereo && !va[i].isGL) match = 0; |
| 370 | if(stereo && va[i].c_class != TrueColor |
| 371 | && va[i].c_class != DirectColor) |
| 372 | match = 0; |
| 373 | } |
| 374 | if(match) return va[i].visualID; |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | return 0; |
| 379 | } |
| 380 | |
| 381 | |
| 382 | // This function finds a 2D X server visual that is suitable for use with a |
no test coverage detected