mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
webgl: Add destructors for texture, program, shader, buffer and framebuffer
This allows to cleanup resources earlier if they stop being used. Right now all resources were cleaned up when the context was destroyed, this is a slightly better approach. We ignore the possible failure of the send() call, since we don't keep track of these resources from the `WebGLRenderingContext` structure, so a texture could be destroyed after the context and give us problems.
This commit is contained in:
parent
601169c0e5
commit
95a0d0584f
6 changed files with 36 additions and 6 deletions
|
@ -71,7 +71,13 @@ impl WebGLBuffer {
|
|||
pub fn delete(&self) {
|
||||
if !self.is_deleted.get() {
|
||||
self.is_deleted.set(true);
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteBuffer(self.id))).unwrap();
|
||||
let _ = self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteBuffer(self.id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for WebGLBuffer {
|
||||
fn drop(&mut self) {
|
||||
self.delete();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue