Implement checks for vertex attribs enabled as arrays without a bound buffer

This commit is contained in:
Anthony Ramine 2018-06-20 15:10:32 +02:00
parent 440e855c33
commit fc3dd7cefc
9 changed files with 94 additions and 114 deletions

View file

@ -3,17 +3,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use canvas_traits::webgl::WebGLVertexArrayId;
use dom::bindings::cell::DomRefCell;
use dom::bindings::codegen::Bindings::WebGLVertexArrayObjectOESBinding;
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::root::{Dom, DomRoot, MutNullableDom};
use dom::bindings::root::{DomRoot, MutNullableDom};
use dom::globalscope::GlobalScope;
use dom::webglbuffer::WebGLBuffer;
use dom::webglobject::WebGLObject;
use dom::webglrenderingcontext::BoundAttribBuffers;
use dom_struct::dom_struct;
use std::cell::{Cell, Ref};
use std::collections::HashMap;
use std::iter::FromIterator;
use std::cell::Cell;
#[dom_struct]
pub struct WebGLVertexArrayObjectOES {
@ -21,7 +19,7 @@ pub struct WebGLVertexArrayObjectOES {
id: WebGLVertexArrayId,
ever_bound: Cell<bool>,
is_deleted: Cell<bool>,
bound_attrib_buffers: DomRefCell<HashMap<u32, Dom<WebGLBuffer>>>,
bound_attrib_buffers: BoundAttribBuffers,
bound_buffer_element_array: MutNullableDom<WebGLBuffer>,
}
@ -32,7 +30,7 @@ impl WebGLVertexArrayObjectOES {
id: id,
ever_bound: Cell::new(false),
is_deleted: Cell::new(false),
bound_attrib_buffers: DomRefCell::new(HashMap::new()),
bound_attrib_buffers: Default::default(),
bound_buffer_element_array: MutNullableDom::new(None),
}
}
@ -43,6 +41,10 @@ impl WebGLVertexArrayObjectOES {
WebGLVertexArrayObjectOESBinding::Wrap)
}
pub fn bound_attrib_buffers(&self) -> &BoundAttribBuffers {
&self.bound_attrib_buffers
}
pub fn id(&self) -> WebGLVertexArrayId {
self.id
}
@ -63,18 +65,6 @@ impl WebGLVertexArrayObjectOES {
self.ever_bound.set(true);
}
pub fn borrow_bound_attrib_buffers(&self) -> Ref<HashMap<u32, Dom<WebGLBuffer>>> {
self.bound_attrib_buffers.borrow()
}
pub fn bound_attrib_buffers(&self) -> Vec<DomRoot<WebGLBuffer>> {
self.bound_attrib_buffers.borrow().iter().map(|(_, b)| DomRoot::from_ref(&**b)).collect()
}
pub fn set_bound_attrib_buffers<'a, T>(&self, iter: T) where T: Iterator<Item=(u32, &'a WebGLBuffer)> {
*self.bound_attrib_buffers.borrow_mut() = HashMap::from_iter(iter.map(|(k,v)| (k, Dom::from_ref(v))));
}
pub fn bound_buffer_element_array(&self) -> Option<DomRoot<WebGLBuffer>> {
self.bound_buffer_element_array.get()
}