aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/webgl2renderingcontext.rs6
-rw-r--r--components/script/dom/webglrenderingcontext.rs32
-rw-r--r--tests/wpt/webgl/meta/conformance2/state/gl-object-get-calls.html.ini45
3 files changed, 21 insertions, 62 deletions
diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs
index 1828ab6fe7d..116de787178 100644
--- a/components/script/dom/webgl2renderingcontext.rs
+++ b/components/script/dom/webgl2renderingcontext.rs
@@ -867,8 +867,10 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
- fn GetBufferParameter(&self, cx: JSContext, target: u32, parameter: u32) -> JSVal {
- self.base.GetBufferParameter(cx, target, parameter)
+ fn GetBufferParameter(&self, _cx: JSContext, target: u32, parameter: u32) -> JSVal {
+ let buffer =
+ handle_potential_webgl_error!(self.base, self.bound_buffer(target), return NullValue());
+ self.base.get_buffer_param(buffer, parameter)
}
#[allow(unsafe_code)]
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index bb9f8d16934..e616410b31d 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -1873,6 +1873,20 @@ impl WebGLRenderingContext {
Ok(())
});
}
+
+ pub fn get_buffer_param(&self, buffer: Option<DomRoot<WebGLBuffer>>, parameter: u32) -> JSVal {
+ let buffer =
+ handle_potential_webgl_error!(self, buffer.ok_or(InvalidOperation), return NullValue());
+
+ match parameter {
+ constants::BUFFER_SIZE => Int32Value(buffer.capacity() as i32),
+ constants::BUFFER_USAGE => Int32Value(buffer.usage() as i32),
+ _ => {
+ self.webgl_error(InvalidEnum);
+ NullValue()
+ },
+ }
+ }
}
#[cfg(not(feature = "webgl_backtrace"))]
@@ -1934,21 +1948,9 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
fn GetBufferParameter(&self, _cx: SafeJSContext, target: u32, parameter: u32) -> JSVal {
- let buffer = handle_potential_webgl_error!(
- self,
- self.bound_buffer(target)
- .and_then(|buf| buf.ok_or(InvalidOperation)),
- return NullValue()
- );
-
- match parameter {
- constants::BUFFER_SIZE => Int32Value(buffer.capacity() as i32),
- constants::BUFFER_USAGE => Int32Value(buffer.usage() as i32),
- _ => {
- self.webgl_error(InvalidEnum);
- NullValue()
- },
- }
+ let buffer =
+ handle_potential_webgl_error!(self, self.bound_buffer(target), return NullValue());
+ self.get_buffer_param(buffer, parameter)
}
#[allow(unsafe_code)]
diff --git a/tests/wpt/webgl/meta/conformance2/state/gl-object-get-calls.html.ini b/tests/wpt/webgl/meta/conformance2/state/gl-object-get-calls.html.ini
index c8728fc9e57..83e3157f1de 100644
--- a/tests/wpt/webgl/meta/conformance2/state/gl-object-get-calls.html.ini
+++ b/tests/wpt/webgl/meta/conformance2/state/gl-object-get-calls.html.ini
@@ -6,27 +6,12 @@
[WebGL test #201: gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_WRAP_R) should be 33071 (of type number). Was null (of type object).]
expected: FAIL
- [WebGL test #10: gl.getBufferParameter(gl.COPY_WRITE_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).]
- expected: FAIL
-
- [WebGL test #9: gl.getBufferParameter(gl.COPY_WRITE_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).]
- expected: FAIL
-
- [WebGL test #16: gl.getBufferParameter(gl.PIXEL_UNPACK_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).]
- expected: FAIL
-
- [WebGL test #4: gl.getBufferParameter(gl.ELEMENT_ARRAY_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).]
- expected: FAIL
-
[WebGL test #203: gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_IMMUTABLE_LEVELS) should be 0 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #204: getTexParameter returned 1 instead of null for invalid parameter enum: 0x84fe]
expected: FAIL
- [WebGL test #13: gl.getBufferParameter(gl.PIXEL_PACK_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).]
- expected: FAIL
-
[WebGL test #196: gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC) should be 515 (of type number). Was null (of type object).]
expected: FAIL
@@ -36,9 +21,6 @@
[WebGL test #199: gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MAX_LOD) should be 10 (of type number). Was null (of type object).]
expected: FAIL
- [WebGL test #15: gl.getBufferParameter(gl.PIXEL_UNPACK_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).]
- expected: FAIL
-
[WebGL test #202: gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_IMMUTABLE_FORMAT) should be false (of type boolean). Was null (of type object).]
expected: FAIL
@@ -48,9 +30,6 @@
[WebGL test #337: gl.getActiveUniformBlockName(program, 0) should be Transform. Was _uTransform.]
expected: FAIL
- [WebGL test #22: gl.getBufferParameter(gl.UNIFORM_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).]
- expected: FAIL
-
[WebGL test #259: gl.getUniform(samplerForWebGL2Program, s2DArrayValLoc) should be 1. Was 0.]
expected: FAIL
@@ -66,30 +45,6 @@
[WebGL test #195: gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_BASE_LEVEL) should be 0 (of type number). Was null (of type object).]
expected: FAIL
- [WebGL test #3: gl.getBufferParameter(gl.ELEMENT_ARRAY_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).]
- expected: FAIL
-
- [WebGL test #5: getBufferParameter did not generate INVALID_ENUM for invalid parameter enum: NO_ERROR]
- expected: FAIL
-
- [WebGL test #18: gl.getBufferParameter(gl.TRANSFORM_FEEDBACK_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).]
- expected: FAIL
-
- [WebGL test #19: gl.getBufferParameter(gl.TRANSFORM_FEEDBACK_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).]
- expected: FAIL
-
- [WebGL test #21: gl.getBufferParameter(gl.UNIFORM_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).]
- expected: FAIL
-
- [WebGL test #7: gl.getBufferParameter(gl.COPY_READ_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).]
- expected: FAIL
-
- [WebGL test #6: gl.getBufferParameter(gl.COPY_READ_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).]
- expected: FAIL
-
- [WebGL test #12: gl.getBufferParameter(gl.PIXEL_PACK_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).]
- expected: FAIL
-
[WebGL test #197: gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE) should be 34894 (of type number). Was null (of type object).]
expected: FAIL