Replaced failible boolean with an enum

This commit is contained in:
Tobias Tschinkowitz 2020-04-23 18:23:01 +02:00
parent 60e75314fe
commit 9c343fcc96
15 changed files with 106 additions and 111 deletions

View file

@ -12,7 +12,7 @@ use crate::dom::bindings::root::{DomRoot, MutNullableDom};
use crate::dom::bindings::str::DOMString;
use crate::dom::webglactiveinfo::WebGLActiveInfo;
use crate::dom::webglobject::WebGLObject;
use crate::dom::webglrenderingcontext::WebGLRenderingContext;
use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext};
use crate::dom::webglshader::WebGLShader;
use crate::dom::webgluniformlocation::WebGLUniformLocation;
use canvas_traits::webgl::{webgl_channel, WebGLProgramId, WebGLResult};
@ -84,17 +84,16 @@ impl WebGLProgram {
}
/// glDeleteProgram
pub fn mark_for_deletion(&self, fallible: bool) {
pub fn mark_for_deletion(&self, operation_fallibility: Operation) {
if self.marked_for_deletion.get() {
return;
}
self.marked_for_deletion.set(true);
let cmd = WebGLCommand::DeleteProgram(self.id);
let context = self.upcast::<WebGLObject>().context();
if fallible {
context.send_command_ignored(cmd);
} else {
context.send_command(cmd);
match operation_fallibility {
Operation::Fallible => context.send_command_ignored(cmd),
Operation::Infallible => context.send_command(cmd),
}
if self.is_deleted() {
self.detach_shaders();
@ -639,7 +638,7 @@ impl WebGLProgram {
impl Drop for WebGLProgram {
fn drop(&mut self) {
self.in_use(false);
self.mark_for_deletion(true);
self.mark_for_deletion(Operation::Fallible);
}
}