///////////////////////////////////////////////////////
| 799 | |
| 800 | //////////////////////////////////////////////////////////// |
| 801 | int GlContext::evaluateFormat( |
| 802 | unsigned int bitsPerPixel, |
| 803 | const ContextSettings& settings, |
| 804 | int colorBits, |
| 805 | int depthBits, |
| 806 | int stencilBits, |
| 807 | int antiAliasing, |
| 808 | bool accelerated, |
| 809 | bool sRgb) |
| 810 | { |
| 811 | int colorDiff = static_cast<int>(bitsPerPixel) - colorBits; |
| 812 | int depthDiff = static_cast<int>(settings.depthBits) - depthBits; |
| 813 | int stencilDiff = static_cast<int>(settings.stencilBits) - stencilBits; |
| 814 | int antiAliasingDiff = static_cast<int>(settings.antiAliasingLevel) - antiAliasing; |
| 815 | |
| 816 | // Weight sub-scores so that better settings don't score equally as bad as worse settings |
| 817 | colorDiff *= ((colorDiff > 0) ? 100'000 : 1); |
| 818 | depthDiff *= ((depthDiff > 0) ? 100'000 : 1); |
| 819 | stencilDiff *= ((stencilDiff > 0) ? 100'000 : 1); |
| 820 | antiAliasingDiff *= ((antiAliasingDiff > 0) ? 100'000 : 1); |
| 821 | |
| 822 | // Aggregate the scores |
| 823 | int score = std::abs(colorDiff) + std::abs(depthDiff) + std::abs(stencilDiff) + std::abs(antiAliasingDiff); |
| 824 | |
| 825 | // If the user wants an sRGB capable format, try really hard to get one |
| 826 | if (settings.sRgbCapable && !sRgb) |
| 827 | score += 10'000'000; |
| 828 | |
| 829 | // Make sure we prefer hardware acceleration over features |
| 830 | if (!accelerated) |
| 831 | score += 100'000'000; |
| 832 | |
| 833 | return score; |
| 834 | } |
| 835 | |
| 836 | |
| 837 | //////////////////////////////////////////////////////////// |
nothing calls this directly
no outgoing calls
no test coverage detected