Skip to content

Commit

Permalink
webgl: Throw an error when binding a deleted framebuffer.
Browse files Browse the repository at this point in the history
The spec was recently changed to clarify that this should throw an
error.
  • Loading branch information
anholt committed Oct 25, 2016
1 parent 6029c92 commit 5fda437
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions components/script/dom/webglrenderingcontext.rs
Expand Up @@ -804,13 +804,23 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
return self.webgl_error(InvalidOperation);
}

self.bound_framebuffer.set(framebuffer);
if let Some(framebuffer) = framebuffer {
framebuffer.bind(target)
if framebuffer.is_deleted() {
// From the WebGL spec:
//
// "An attempt to bind a deleted framebuffer will
// generate an INVALID_OPERATION error, and the
// current binding will remain untouched."
return self.webgl_error(InvalidOperation);
} else {
framebuffer.bind(target);
self.bound_framebuffer.set(Some(framebuffer));
}
} else {
// Bind the default framebuffer
let cmd = WebGLCommand::BindFramebuffer(target, WebGLFramebufferBindingRequest::Default);
self.ipc_renderer.send(CanvasMsg::WebGL(cmd)).unwrap();
self.bound_framebuffer.set(framebuffer);
}
}

Expand Down

0 comments on commit 5fda437

Please sign in to comment.