Bug 1233819 - Fix WebGL on WinXP. - r=jrmuizel

This commit is contained in:
Jeff Gilbert 2016-01-21 18:47:29 -08:00
parent f8897884d2
commit e9a675dbb6
5 changed files with 96 additions and 65 deletions

View File

@ -7,7 +7,7 @@
TEST_DIRS += ['compiledtest']
# Number changes to this file to avoid bug 1081323 (clobber after changing a manifest):
# 2
# 3
MOCHITEST_MANIFESTS += [
'test/crossorigin/mochitest.ini',

View File

@ -30,13 +30,13 @@ skip-if = android_version == '10' || android_version == '18' #Android 2.3 and 4.
[webgl-mochitest/test_texsubimage_float.html]
[webgl-mochitest/test_uninit_data.html]
[webgl-mochitest/test_webgl_available.html]
skip-if = toolkit == 'android' #bug 865443- seperate suite - the non_conf* tests pass except for one on armv6 tests
#[webgl-mochitest/test_webgl_color_buffer_float.html]
# We haven't cleaned up the Try results yet, but let's get this on the books first.
[webgl-mochitest/test_webgl_conformance.html]
skip-if = toolkit == 'android' #bug 865443- seperate suite - the non_conf* tests pass except for one on armv6 tests
[webgl-mochitest/test_webgl_compressed_texture_es3.html]
[webgl-mochitest/test_webgl_disjoint_timer_query.html]
[webgl-mochitest/test_webgl_force_enable.html]
[webgl-mochitest/test_webgl_request_context.html]
skip-if = toolkit == 'android' #bug 865443- seperate suite - the non_conf* tests pass except for one on armv6 tests
[webgl-mochitest/test_webgl_request_mismatch.html]

View File

@ -1,50 +1,19 @@
<!DOCTYPE HTML>
<html>
<head>
<title>WebGL test: Check that WebGL works (or not) if it should (or should not).</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<script src="webgl-util.js"></script>
<script src="driver-info.js"></script>
</head>
<body>
<canvas id="c"></canvas>
<script>
<head>
<meta charset='utf-8'/>
<title>WebGL test: Check that WebGL works out-of-the-box.</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
</head>
<body>
<script>
function test() {
ok(SpecialPowers.getBoolPref('webgl.force-enabled'), 'WebGL should be force-enabled.');
'use strict';
var c = document.createElement('canvas');
var gl = c.getContext('experimental-webgl');
ok(gl, 'Expected WebGL creation to succeed.');
var shouldSucceed = true;
var shouldFail = false;
if (DriverInfo.getOS() == DriverInfo.OS.ANDROID &&
DriverInfo.getOSVersion() < 15)
{
// Consider 'random'. Actually, ARMv6 fails, and ARMv7 succeeds, but we have
// not been successful at determining this from JS. (see bug 917478)
shouldSucceed = false;
shouldFail = false;
}
var gl = WebGLUtil.getWebGL('c');
if (shouldSucceed) {
ok(gl, 'Expected WebGL creation to succeed.');
}
if (shouldFail) {
ok(!gl, 'Expected WebGL creation to fail.');
}
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
var prefArrArr = [
['webgl.force-enabled', true]
];
var prefEnv = {'set': prefArrArr};
SpecialPowers.pushPrefEnv(prefEnv, test);
</script>
</body>
</script>
</body>
</html>

View File

@ -0,0 +1,50 @@
<!DOCTYPE HTML>
<html>
<head>
<title>WebGL test: Check that WebGL works (or not) if it should (or should not).</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<script src="webgl-util.js"></script>
<script src="driver-info.js"></script>
</head>
<body>
<canvas id="c"></canvas>
<script>
function test() {
ok(SpecialPowers.getBoolPref('webgl.force-enabled'), 'WebGL should be force-enabled.');
var shouldSucceed = true;
var shouldFail = false;
if (DriverInfo.getOS() == DriverInfo.OS.ANDROID &&
DriverInfo.getOSVersion() < 15)
{
// Consider 'random'. Actually, ARMv6 fails, and ARMv7 succeeds, but we have
// not been successful at determining this from JS. (see bug 917478)
shouldSucceed = false;
shouldFail = false;
}
var gl = WebGLUtil.getWebGL('c');
if (shouldSucceed) {
ok(gl, 'Expected WebGL creation to succeed.');
}
if (shouldFail) {
ok(!gl, 'Expected WebGL creation to fail.');
}
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
var prefArrArr = [
['webgl.force-enabled', true]
];
var prefEnv = {'set': prefArrArr};
SpecialPowers.pushPrefEnv(prefEnv, test);
</script>
</body>
</html>

View File

@ -153,6 +153,34 @@ GetAndInitDisplay(GLLibraryEGL& egl, void* displayType)
return display;
}
static EGLDisplay
GetAndInitDisplayForAccelANGLE(GLLibraryEGL& egl)
{
EGLDisplay ret = 0;
// D3D11 ANGLE only works with OMTC; there's a bug in the non-OMTC layer
// manager, and it's pointless to try to fix it. We also don't try
// D3D11 ANGLE if the layer manager is prefering D3D9 (hrm, do we care?)
if (gfxPrefs::LayersOffMainThreadCompositionEnabled() &&
!gfxPrefs::LayersPreferD3D9())
{
if (gfxPrefs::WebGLANGLEForceD3D11())
return GetAndInitDisplay(egl, LOCAL_EGL_D3D11_ONLY_DISPLAY_ANGLE);
if (gfxPrefs::WebGLANGLETryD3D11() &&
gfxPlatform::CanUseDirect3D11ANGLE())
{
ret = GetAndInitDisplay(egl, LOCAL_EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE);
}
}
if (!ret) {
ret = GetAndInitDisplay(egl, EGL_DEFAULT_DISPLAY);
}
return ret;
}
bool
GLLibraryEGL::ReadbackEGLImage(EGLImage image, gfx::DataSourceSurface* out_surface)
{
@ -367,30 +395,14 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel)
if (!chosenDisplay) {
// If falling back to WARP did not work and we don't want to try
// using HW accelerated ANGLE, then fail
// using HW accelerated ANGLE, then fail.
if (!shouldTryAccel) {
NS_ERROR("Fallback WARP ANGLE context failed to initialize.");
return false;
}
// Hardware accelerated ANGLE path
// D3D11 ANGLE only works with OMTC; there's a bug in the non-OMTC layer
// manager, and it's pointless to try to fix it. We also don't try
// D3D11 ANGLE if the layer manager is prefering D3D9 (hrm, do we care?)
if (gfxPrefs::LayersOffMainThreadCompositionEnabled() &&
!gfxPrefs::LayersPreferD3D9())
{
if (gfxPrefs::WebGLANGLEForceD3D11()) {
chosenDisplay = GetAndInitDisplay(*this,
LOCAL_EGL_D3D11_ONLY_DISPLAY_ANGLE);
} else if (gfxPrefs::WebGLANGLETryD3D11() &&
gfxPlatform::CanUseDirect3D11ANGLE())
{
chosenDisplay = GetAndInitDisplay(*this,
LOCAL_EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE);
}
}
chosenDisplay = GetAndInitDisplayForAccelANGLE(*this);
}
} else {
chosenDisplay = GetAndInitDisplay(*this, EGL_DEFAULT_DISPLAY);