aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglrenderbuffer.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2018-09-10 16:27:58 -0400
committerJosh Matthews <josh@joshmatthews.net>2018-09-10 16:31:33 -0400
commit4edb7b194c99a1d394dddaeac2f5064ed8e93f62 (patch)
treeee03e8f206e878c546e637b949668820074250fa /components/script/dom/webglrenderbuffer.rs
parentb8ee62e67bae0ffda558e7e9d819257265f5a16f (diff)
downloadservo-4edb7b194c99a1d394dddaeac2f5064ed8e93f62.tar.gz
servo-4edb7b194c99a1d394dddaeac2f5064ed8e93f62.zip
webgl: Remove knowledge of attached framebuffers from renderbuffers and textures.
Diffstat (limited to 'components/script/dom/webglrenderbuffer.rs')
-rw-r--r--components/script/dom/webglrenderbuffer.rs38
1 files changed, 4 insertions, 34 deletions
diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs
index 9637dae02e1..96ef3bb0d67 100644
--- a/components/script/dom/webglrenderbuffer.rs
+++ b/components/script/dom/webglrenderbuffer.rs
@@ -4,14 +4,12 @@
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLError, WebGLRenderbufferId, WebGLResult};
-use dom::bindings::cell::DomRefCell;
use dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as WebGl2Constants;
use dom::bindings::codegen::Bindings::WebGLRenderbufferBinding;
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, reflect_dom_object};
-use dom::bindings::root::{DomRoot, Dom};
-use dom::webglframebuffer::WebGLFramebuffer;
+use dom::bindings::root::DomRoot;
use dom::webglobject::WebGLObject;
use dom::webglrenderingcontext::{WebGLRenderingContext, is_gles};
use dom_struct::dom_struct;
@@ -26,8 +24,6 @@ pub struct WebGLRenderbuffer {
size: Cell<Option<(i32, i32)>>,
internal_format: Cell<Option<u32>>,
is_initialized: Cell<bool>,
- // Framebuffer that this texture is attached to.
- attached_framebuffers: DomRefCell<Vec<Dom<WebGLFramebuffer>>>,
}
impl WebGLRenderbuffer {
@@ -40,7 +36,6 @@ impl WebGLRenderbuffer {
internal_format: Cell::new(None),
size: Cell::new(None),
is_initialized: Cell::new(false),
- attached_framebuffers: Default::default(),
}
}
@@ -102,16 +97,9 @@ impl WebGLRenderbuffer {
let currently_bound_framebuffer =
self.upcast::<WebGLObject>()
.context()
- .bound_framebuffer()
- .map_or(0, |fb| fb.id().get());
- let current_framebuffer =
- self.attached_framebuffers
- .borrow()
- .iter()
- .position(|fb| fb.id().get() == currently_bound_framebuffer);
- if let Some(fb_index) = current_framebuffer {
- self.attached_framebuffers.borrow()[fb_index].detach_renderbuffer(self);
- self.attached_framebuffers.borrow_mut().remove(fb_index);
+ .bound_framebuffer();
+ if let Some(fb) = currently_bound_framebuffer {
+ fb.detach_renderbuffer(self);
}
self.upcast::<WebGLObject>()
@@ -173,22 +161,4 @@ impl WebGLRenderbuffer {
Ok(())
}
-
- pub fn attach(&self, framebuffer: &WebGLFramebuffer) -> WebGLResult<()> {
- if !self.ever_bound.get() {
- return Err(WebGLError::InvalidOperation);
- }
- self.attached_framebuffers.borrow_mut().push(Dom::from_ref(framebuffer));
- Ok(())
- }
-
- pub fn unattach(&self, fb: &WebGLFramebuffer) {
- let mut attached_framebuffers = self.attached_framebuffers.borrow_mut();
- let idx = attached_framebuffers.iter().position(|attached| {
- attached.id() == fb.id()
- });
- if let Some(idx) = idx {
- attached_framebuffers.remove(idx);
- }
- }
}