aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webgl2renderingcontext.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/webgl2renderingcontext.rs')
-rw-r--r--components/script/dom/webgl2renderingcontext.rs62
1 files changed, 60 insertions, 2 deletions
diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs
index 699631de5d2..dabcd4cf54e 100644
--- a/components/script/dom/webgl2renderingcontext.rs
+++ b/components/script/dom/webgl2renderingcontext.rs
@@ -42,7 +42,8 @@ use crate::js::conversions::ToJSValConvertible;
use crate::script_runtime::JSContext;
use canvas_traits::webgl::WebGLError::*;
use canvas_traits::webgl::{
- webgl_channel, GLContextAttributes, WebGLCommand, WebGLResult, WebGLVersion,
+ webgl_channel, GLContextAttributes, InternalFormatParameter, WebGLCommand, WebGLResult,
+ WebGLVersion,
};
use dom_struct::dom_struct;
use euclid::default::{Point2D, Rect, Size2D};
@@ -51,7 +52,7 @@ use js::jsapi::{JSObject, Type};
use js::jsval::{BooleanValue, DoubleValue, Int32Value, UInt32Value};
use js::jsval::{JSVal, NullValue, ObjectValue, UndefinedValue};
use js::rust::CustomAutoRooterGuard;
-use js::typedarray::{ArrayBufferView, CreateWith, Float32, Uint32, Uint32Array};
+use js::typedarray::{ArrayBufferView, CreateWith, Float32, Int32Array, Uint32, Uint32Array};
use script_layout_interface::HTMLCanvasDataSource;
use std::cell::Cell;
use std::cmp;
@@ -2459,6 +2460,9 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
&uniform_get(triple, WebGLCommand::GetUniformFloat4x3),
)
},
+ constants::SAMPLER_3D | constants::SAMPLER_2D_ARRAY => {
+ Int32Value(uniform_get(triple, WebGLCommand::GetUniformInt))
+ },
_ => self.base.GetUniform(cx, program, location),
}
}
@@ -3753,6 +3757,60 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
None => self.base.webgl_error(InvalidOperation),
}
}
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.5
+ #[allow(unsafe_code)]
+ fn GetInternalformatParameter(
+ &self,
+ cx: JSContext,
+ target: u32,
+ internal_format: u32,
+ pname: u32,
+ ) -> JSVal {
+ if target != constants::RENDERBUFFER {
+ self.base.webgl_error(InvalidEnum);
+ return NullValue();
+ }
+
+ match handle_potential_webgl_error!(
+ self.base,
+ InternalFormatParameter::from_u32(pname),
+ return NullValue()
+ ) {
+ InternalFormatParameter::IntVec(param) => unsafe {
+ let (sender, receiver) = webgl_channel().unwrap();
+ self.base
+ .send_command(WebGLCommand::GetInternalFormatIntVec(
+ target,
+ internal_format,
+ param,
+ sender,
+ ));
+
+ rooted!(in(*cx) let mut rval = ptr::null_mut::<JSObject>());
+ let _ = Int32Array::create(
+ *cx,
+ CreateWith::Slice(&receiver.recv().unwrap()),
+ rval.handle_mut(),
+ )
+ .unwrap();
+ ObjectValue(rval.get())
+ },
+ }
+ }
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.5
+ fn RenderbufferStorageMultisample(
+ &self,
+ target: u32,
+ samples: i32,
+ internal_format: u32,
+ width: i32,
+ height: i32,
+ ) {
+ self.base
+ .renderbuffer_storage(target, samples, internal_format, width, height)
+ }
}
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<WebGL2RenderingContext> {