diff options
Diffstat (limited to 'testing/web-platform/tests/webxr/xrWebGLLayer_framebuffer_scale.https.html')
-rw-r--r-- | testing/web-platform/tests/webxr/xrWebGLLayer_framebuffer_scale.https.html | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webxr/xrWebGLLayer_framebuffer_scale.https.html b/testing/web-platform/tests/webxr/xrWebGLLayer_framebuffer_scale.https.html new file mode 100644 index 0000000000..065fc3df4e --- /dev/null +++ b/testing/web-platform/tests/webxr/xrWebGLLayer_framebuffer_scale.https.html @@ -0,0 +1,58 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/webxr_util.js"></script> +<script src="resources/webxr_test_constants.js"></script> + +<script> + +let testName = "Ensure framebuffer scaling works as expected."; + +let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; + +let testFunction = + (session, fakeDeviceController, t, sessionObjects) => new Promise((resolve, reject) => { + let gl = sessionObjects.gl; + let webglLayer = sessionObjects.glLayer; + let defaultFramebufferWidth = webglLayer.framebufferWidth; + let defaultFramebufferHeight = webglLayer.framebufferHeight; + let nativeScale = XRWebGLLayer.getNativeFramebufferScaleFactor(session); + + t.step(() => { + // Ensure the framebuffer default sizes and native scale are all non-zero. + assert_greater_than(defaultFramebufferWidth, 0); + assert_greater_than(defaultFramebufferHeight, 0); + assert_greater_than(nativeScale, 0); + + // The native scale should be the inverse for the default framebuffer scale. + assert_approx_equals(nativeScale, 1/fakeDeviceController.defaultFramebufferScale_, FLOAT_EPSILON); + }); + + webglLayer = new XRWebGLLayer(session, gl, { framebufferScaleFactor: nativeScale }); + t.step(() => { + // Ensure that requesting a native scale framebuffer gives the expected result. + assert_approx_equals(webglLayer.framebufferWidth, defaultFramebufferWidth*nativeScale, 2); + assert_approx_equals(webglLayer.framebufferHeight, defaultFramebufferHeight*nativeScale, 2); + }); + + webglLayer = new XRWebGLLayer(session, gl, { framebufferScaleFactor: 0 }); + t.step(() => { + // Ensure that the framebuffer has a lower bounds clamp. + assert_greater_than(webglLayer.framebufferWidth, 0); + assert_greater_than(webglLayer.framebufferHeight, 0); + }); + + webglLayer = new XRWebGLLayer(session, gl, { framebufferScaleFactor: 100 }); + t.step(() => { + // Ensure that the framebuffer has a reasonable upper bounds clamp. + assert_less_than(webglLayer.framebufferWidth, defaultFramebufferWidth*100); + assert_less_than(webglLayer.framebufferHeight, defaultFramebufferHeight*100); + }); + + resolve(); +}); + +xr_session_promise_test( + testName, testFunction, fakeDeviceInitParams, 'immersive-vr'); + +</script> |