aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglrenderingcontext.rs
diff options
context:
space:
mode:
authorMátyás Mustoha <matyas.mustoha@h-lab.eu>2020-04-28 13:12:06 +0200
committerMátyás Mustoha <matyas.mustoha@h-lab.eu>2020-04-28 14:06:02 +0200
commit2810c8d41373cc957f91f668d8b393f3798870fe (patch)
treefc125e8dc2a8bfffd55e96d12cb95dbf4fb4992d /components/script/dom/webglrenderingcontext.rs
parentc9909643a2df6779e61387b7a6cd454b8bcac631 (diff)
downloadservo-2810c8d41373cc957f91f668d8b393f3798870fe.tar.gz
servo-2810c8d41373cc957f91f668d8b393f3798870fe.zip
Add support for WebGL2 buffer types in GetBufferParameter
This makes the new buffer types introduced in WebGL2 usable by the GetBufferParameter call.
Diffstat (limited to 'components/script/dom/webglrenderingcontext.rs')
-rw-r--r--components/script/dom/webglrenderingcontext.rs32
1 files changed, 17 insertions, 15 deletions
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)]