diff options
author | Imanol Fernandez <mortimergoro@gmail.com> | 2017-08-17 16:47:05 +0200 |
---|---|---|
committer | Imanol Fernandez <mortimergoro@gmail.com> | 2017-08-17 16:50:02 +0200 |
commit | 712998b086d31ad952354ec881680830020d2efe (patch) | |
tree | 12a1f2a109367ad725f58c0c7673a122e5b205b8 /components/script/dom/webglrenderingcontext.rs | |
parent | fbabcaf614662a52eace21a64f27802c7eff4304 (diff) | |
download | servo-712998b086d31ad952354ec881680830020d2efe.tar.gz servo-712998b086d31ad952354ec881680830020d2efe.zip |
Fix bound textures and framebuffers when a WebGL Canvas is resized
Diffstat (limited to 'components/script/dom/webglrenderingcontext.rs')
-rw-r--r-- | components/script/dom/webglrenderingcontext.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index c45362b4fe2..78e6c1e312c 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -279,6 +279,22 @@ impl WebGLRenderingContext { // default scissor when the canvas was created or the last scissor that the user set. let rect = self.current_scissor.get(); self.send_command(WebGLCommand::Scissor(rect.0, rect.1, rect.2, rect.3)); + + // Bound texture must not change when the canvas is resized. + // Right now offscreen_gl_context generates a new FBO and the bound texture is changed + // in order to create a new render to texture attachment. + // Send a command to re-bind the TEXTURE_2D, if any. + if let Some(texture) = self.bound_texture_2d.get() { + self.send_command(WebGLCommand::BindTexture(constants::TEXTURE_2D, Some(texture.id()))); + } + + // Bound framebuffer must not change when the canvas is resized. + // Right now offscreen_gl_context generates a new FBO on resize. + // Send a command to re-bind the framebuffer, if any. + if let Some(fbo) = self.bound_framebuffer.get() { + let id = WebGLFramebufferBindingRequest::Explicit(fbo.id()); + self.send_command(WebGLCommand::BindFramebuffer(constants::FRAMEBUFFER, id)); + } } pub fn webgl_sender(&self) -> WebGLMsgSender { |