diff options
Diffstat (limited to 'components/script/dom/webglprogram.rs')
-rw-r--r-- | components/script/dom/webglprogram.rs | 78 |
1 files changed, 43 insertions, 35 deletions
diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 61673289566..52c48872eb1 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -27,7 +27,7 @@ use crate::dom::webgluniformlocation::WebGLUniformLocation; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WebGLProgram { +pub(crate) struct WebGLProgram { webgl_object: WebGLObject, #[no_trace] id: WebGLProgramId, @@ -68,7 +68,7 @@ impl WebGLProgram { } } - pub fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> { + pub(crate) fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> { let (sender, receiver) = webgl_channel().unwrap(); context.send_command(WebGLCommand::CreateProgram(sender)); receiver @@ -77,7 +77,7 @@ impl WebGLProgram { .map(|id| WebGLProgram::new(context, id)) } - pub fn new(context: &WebGLRenderingContext, id: WebGLProgramId) -> DomRoot<Self> { + pub(crate) fn new(context: &WebGLRenderingContext, id: WebGLProgramId) -> DomRoot<Self> { reflect_dom_object( Box::new(WebGLProgram::new_inherited(context, id)), &*context.global(), @@ -87,12 +87,12 @@ impl WebGLProgram { } impl WebGLProgram { - pub fn id(&self) -> WebGLProgramId { + pub(crate) fn id(&self) -> WebGLProgramId { self.id } /// glDeleteProgram - pub fn mark_for_deletion(&self, operation_fallibility: Operation) { + pub(crate) fn mark_for_deletion(&self, operation_fallibility: Operation) { if self.marked_for_deletion.get() { return; } @@ -108,7 +108,7 @@ impl WebGLProgram { } } - pub fn in_use(&self, value: bool) { + pub(crate) fn in_use(&self, value: bool) { if self.is_in_use.get() == value { return; } @@ -130,24 +130,24 @@ impl WebGLProgram { } } - pub fn is_in_use(&self) -> bool { + pub(crate) fn is_in_use(&self) -> bool { self.is_in_use.get() } - pub fn is_marked_for_deletion(&self) -> bool { + pub(crate) fn is_marked_for_deletion(&self) -> bool { self.marked_for_deletion.get() } - pub fn is_deleted(&self) -> bool { + pub(crate) fn is_deleted(&self) -> bool { self.marked_for_deletion.get() && !self.is_in_use.get() } - pub fn is_linked(&self) -> bool { + pub(crate) fn is_linked(&self) -> bool { self.linked.get() } /// glLinkProgram - pub fn link(&self) -> WebGLResult<()> { + pub(crate) fn link(&self) -> WebGLResult<()> { self.linked.set(false); self.link_generation .set(self.link_generation.get().checked_add(1).unwrap()); @@ -212,20 +212,20 @@ impl WebGLProgram { Ok(()) } - pub fn active_attribs(&self) -> Ref<[ActiveAttribInfo]> { + pub(crate) fn active_attribs(&self) -> Ref<[ActiveAttribInfo]> { Ref::map(self.active_attribs.borrow(), |attribs| &**attribs) } - pub fn active_uniforms(&self) -> Ref<[ActiveUniformInfo]> { + pub(crate) fn active_uniforms(&self) -> Ref<[ActiveUniformInfo]> { Ref::map(self.active_uniforms.borrow(), |uniforms| &**uniforms) } - pub fn active_uniform_blocks(&self) -> Ref<[ActiveUniformBlockInfo]> { + pub(crate) fn active_uniform_blocks(&self) -> Ref<[ActiveUniformBlockInfo]> { Ref::map(self.active_uniform_blocks.borrow(), |blocks| &**blocks) } /// glValidateProgram - pub fn validate(&self) -> WebGLResult<()> { + pub(crate) fn validate(&self) -> WebGLResult<()> { if self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -236,7 +236,7 @@ impl WebGLProgram { } /// glAttachShader - pub fn attach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> { + pub(crate) fn attach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> { if self.is_deleted() || shader.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -264,7 +264,7 @@ impl WebGLProgram { } /// glDetachShader - pub fn detach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> { + pub(crate) fn detach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> { if self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -293,7 +293,7 @@ impl WebGLProgram { } /// glBindAttribLocation - pub fn bind_attrib_location(&self, index: u32, name: DOMString) -> WebGLResult<()> { + pub(crate) fn bind_attrib_location(&self, index: u32, name: DOMString) -> WebGLResult<()> { if self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -315,7 +315,7 @@ impl WebGLProgram { Ok(()) } - pub fn get_active_uniform(&self, index: u32) -> WebGLResult<DomRoot<WebGLActiveInfo>> { + pub(crate) fn get_active_uniform(&self, index: u32) -> WebGLResult<DomRoot<WebGLActiveInfo>> { if self.is_deleted() { return Err(WebGLError::InvalidValue); } @@ -332,7 +332,7 @@ impl WebGLProgram { } /// glGetActiveAttrib - pub fn get_active_attrib(&self, index: u32) -> WebGLResult<DomRoot<WebGLActiveInfo>> { + pub(crate) fn get_active_attrib(&self, index: u32) -> WebGLResult<DomRoot<WebGLActiveInfo>> { if self.is_deleted() { return Err(WebGLError::InvalidValue); } @@ -349,7 +349,7 @@ impl WebGLProgram { } /// glGetAttribLocation - pub fn get_attrib_location(&self, name: DOMString) -> WebGLResult<i32> { + pub(crate) fn get_attrib_location(&self, name: DOMString) -> WebGLResult<i32> { if !self.is_linked() || self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -372,7 +372,7 @@ impl WebGLProgram { } /// glGetFragDataLocation - pub fn get_frag_data_location(&self, name: DOMString) -> WebGLResult<i32> { + pub(crate) fn get_frag_data_location(&self, name: DOMString) -> WebGLResult<i32> { if !self.is_linked() || self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -396,7 +396,7 @@ impl WebGLProgram { } /// glGetUniformLocation - pub fn get_uniform_location( + pub(crate) fn get_uniform_location( &self, name: DOMString, ) -> WebGLResult<Option<DomRoot<WebGLUniformLocation>>> { @@ -454,7 +454,7 @@ impl WebGLProgram { ))) } - pub fn get_uniform_block_index(&self, name: DOMString) -> WebGLResult<u32> { + pub(crate) fn get_uniform_block_index(&self, name: DOMString) -> WebGLResult<u32> { if !self.link_called.get() || self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -474,7 +474,7 @@ impl WebGLProgram { Ok(receiver.recv().unwrap()) } - pub fn get_uniform_indices(&self, names: Vec<DOMString>) -> WebGLResult<Vec<u32>> { + pub(crate) fn get_uniform_indices(&self, names: Vec<DOMString>) -> WebGLResult<Vec<u32>> { if !self.link_called.get() || self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -500,7 +500,11 @@ impl WebGLProgram { Ok(receiver.recv().unwrap()) } - pub fn get_active_uniforms(&self, indices: Vec<u32>, pname: u32) -> WebGLResult<Vec<i32>> { + pub(crate) fn get_active_uniforms( + &self, + indices: Vec<u32>, + pname: u32, + ) -> WebGLResult<Vec<i32>> { if !self.is_linked() || self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -529,7 +533,7 @@ impl WebGLProgram { Ok(receiver.recv().unwrap()) } - pub fn get_active_uniform_block_parameter( + pub(crate) fn get_active_uniform_block_parameter( &self, block_index: u32, pname: u32, @@ -559,7 +563,7 @@ impl WebGLProgram { Ok(receiver.recv().unwrap()) } - pub fn get_active_uniform_block_name(&self, block_index: u32) -> WebGLResult<String> { + pub(crate) fn get_active_uniform_block_name(&self, block_index: u32) -> WebGLResult<String> { if !self.link_called.get() || self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -575,7 +579,11 @@ impl WebGLProgram { Ok(receiver.recv().unwrap()) } - pub fn bind_uniform_block(&self, block_index: u32, block_binding: u32) -> WebGLResult<()> { + pub(crate) fn bind_uniform_block( + &self, + block_index: u32, + block_binding: u32, + ) -> WebGLResult<()> { if block_index as usize >= self.active_uniform_blocks.borrow().len() { return Err(WebGLError::InvalidValue); } @@ -596,7 +604,7 @@ impl WebGLProgram { } /// glGetProgramInfoLog - pub fn get_info_log(&self) -> WebGLResult<String> { + pub(crate) fn get_info_log(&self) -> WebGLResult<String> { if self.is_deleted() { return Err(WebGLError::InvalidValue); } @@ -616,7 +624,7 @@ impl WebGLProgram { Ok(receiver.recv().unwrap()) } - pub fn attached_shaders(&self) -> WebGLResult<Vec<DomRoot<WebGLShader>>> { + pub(crate) fn attached_shaders(&self) -> WebGLResult<Vec<DomRoot<WebGLShader>>> { if self.marked_for_deletion.get() { return Err(WebGLError::InvalidValue); } @@ -631,15 +639,15 @@ impl WebGLProgram { ) } - pub fn link_generation(&self) -> u64 { + pub(crate) fn link_generation(&self) -> u64 { self.link_generation.get() } - pub fn transform_feedback_varyings_length(&self) -> i32 { + pub(crate) fn transform_feedback_varyings_length(&self) -> i32 { self.transform_feedback_varyings_length.get() } - pub fn transform_feedback_buffer_mode(&self) -> i32 { + pub(crate) fn transform_feedback_buffer_mode(&self) -> i32 { self.transform_feedback_mode.get() } } @@ -718,4 +726,4 @@ fn parse_uniform_name(name: &str) -> Option<(&str, Option<i32>)> { Some((&name[..bracket_pos], Some(index))) } -pub const MAX_UNIFORM_AND_ATTRIBUTE_LEN: usize = 256; +pub(crate) const MAX_UNIFORM_AND_ATTRIBUTE_LEN: usize = 256; |