diff options
author | Josh Matthews <josh@joshmatthews.net> | 2018-09-10 12:10:27 -0400 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2018-11-05 14:13:46 +0100 |
commit | e31462c37c2305a8e88e5d27901299ff76d7a853 (patch) | |
tree | c2b653ca3a72e5ef8f215d54e3e6f2b873714848 /components/script/dom/webglrenderbuffer.rs | |
parent | 176d984b3badba7265f3e7442159adcb54d8b90e (diff) | |
download | servo-e31462c37c2305a8e88e5d27901299ff76d7a853.tar.gz servo-e31462c37c2305a8e88e5d27901299ff76d7a853.zip |
Implement WEBGL_color_buffer_float and EXT_color_buffer_half_float (fixes #22113)
Diffstat (limited to 'components/script/dom/webglrenderbuffer.rs')
-rw-r--r-- | components/script/dom/webglrenderbuffer.rs | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs index 7b9863257de..2447ef28c09 100644 --- a/components/script/dom/webglrenderbuffer.rs +++ b/components/script/dom/webglrenderbuffer.rs @@ -4,7 +4,9 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::webgl::{WebGLCommand, WebGLError, WebGLRenderbufferId, WebGLResult, is_gles, webgl_channel}; -use dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as WebGl2Constants; +use dom::bindings::codegen::Bindings::EXTColorBufferHalfFloatBinding::EXTColorBufferHalfFloatConstants; +use dom::bindings::codegen::Bindings::WEBGLColorBufferFloatBinding::WEBGLColorBufferFloatConstants; +use dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants; use dom::bindings::codegen::Bindings::WebGLRenderbufferBinding; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use dom::bindings::inheritance::Castable; @@ -124,13 +126,13 @@ impl WebGLRenderbuffer { constants::DEPTH_COMPONENT16 | constants::STENCIL_INDEX8 => internal_format, // https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.8 - constants::DEPTH_STENCIL => WebGl2Constants::DEPTH24_STENCIL8, + constants::DEPTH_STENCIL => WebGL2RenderingContextConstants::DEPTH24_STENCIL8, constants::RGB5_A1 => { // 16-bit RGBA formats are not supported on desktop GL. if is_gles() { constants::RGB5_A1 } else { - WebGl2Constants::RGBA8 + WebGL2RenderingContextConstants::RGBA8 } } constants::RGB565 => { @@ -138,17 +140,28 @@ impl WebGLRenderbuffer { if is_gles() { constants::RGB565 } else { - WebGl2Constants::RGB8 + WebGL2RenderingContextConstants::RGB8 } } + EXTColorBufferHalfFloatConstants::RGBA16F_EXT | + EXTColorBufferHalfFloatConstants::RGB16F_EXT => { + if !self.upcast().context().extension_manager().is_half_float_buffer_renderable() { + return Err(WebGLError::InvalidEnum); + } + internal_format + }, + WEBGLColorBufferFloatConstants::RGBA32F_EXT => { + if !self.upcast().context().extension_manager().is_float_buffer_renderable() { + return Err(WebGLError::InvalidEnum); + } + internal_format + }, _ => return Err(WebGLError::InvalidEnum), }; self.internal_format.set(Some(internal_format)); self.is_initialized.set(false); - // FIXME: Invalidate completeness after the call - self.upcast::<WebGLObject>() .context() .send_command(WebGLCommand::RenderbufferStorage( |