script: Limit public exports. (#34915)

* script: Restrict reexport visibility of DOM types.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Mass pub->pub(crate) conversion.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Hide existing dead code warnings.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix clippy warnings.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix unit tests.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix clippy.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* More formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-01-10 03:19:19 -05:00 committed by GitHub
parent f220d6d3a5
commit c94d909a86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
585 changed files with 5411 additions and 5013 deletions

View file

@ -29,7 +29,7 @@ use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext};
use crate::dom::xrsession::XRSession;
use crate::script_runtime::CanGc;
pub enum TexParameterValue {
pub(crate) enum TexParameterValue {
Float(f32),
Int(i32),
Bool(bool),
@ -49,7 +49,7 @@ const MAX_LEVEL_COUNT: usize = 31;
const MAX_FACE_COUNT: usize = 6;
#[dom_struct]
pub struct WebGLTexture {
pub(crate) struct WebGLTexture {
webgl_object: WebGLObject,
#[no_trace]
id: WebGLTextureId,
@ -99,7 +99,7 @@ impl WebGLTexture {
}
}
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::CreateTexture(sender));
receiver
@ -108,7 +108,7 @@ impl WebGLTexture {
.map(|id| WebGLTexture::new(context, id))
}
pub fn new(context: &WebGLRenderingContext, id: WebGLTextureId) -> DomRoot<Self> {
pub(crate) fn new(context: &WebGLRenderingContext, id: WebGLTextureId) -> DomRoot<Self> {
reflect_dom_object(
Box::new(WebGLTexture::new_inherited(
context,
@ -122,7 +122,7 @@ impl WebGLTexture {
}
#[cfg(feature = "webxr")]
pub fn new_webxr(
pub(crate) fn new_webxr(
context: &WebGLRenderingContext,
id: WebGLTextureId,
session: &XRSession,
@ -136,12 +136,12 @@ impl WebGLTexture {
}
impl WebGLTexture {
pub fn id(&self) -> WebGLTextureId {
pub(crate) fn id(&self) -> WebGLTextureId {
self.id
}
// NB: Only valid texture targets come here
pub fn bind(&self, target: u32) -> WebGLResult<()> {
pub(crate) fn bind(&self, target: u32) -> WebGLResult<()> {
if self.is_invalid() {
return Err(WebGLError::InvalidOperation);
}
@ -169,7 +169,7 @@ impl WebGLTexture {
}
#[allow(clippy::too_many_arguments)]
pub fn initialize(
pub(crate) fn initialize(
&self,
target: TexImageTarget,
width: u32,
@ -197,7 +197,7 @@ impl WebGLTexture {
Ok(())
}
pub fn generate_mipmap(&self) -> WebGLResult<()> {
pub(crate) fn generate_mipmap(&self) -> WebGLResult<()> {
let target = match self.target.get() {
Some(target) => target,
None => {
@ -233,7 +233,7 @@ impl WebGLTexture {
self.populate_mip_chain(self.base_mipmap_level, last_level)
}
pub fn delete(&self, operation_fallibility: Operation) {
pub(crate) fn delete(&self, operation_fallibility: Operation) {
if !self.is_deleted.get() {
self.is_deleted.set(true);
let context = self.upcast::<WebGLObject>().context();
@ -267,7 +267,7 @@ impl WebGLTexture {
}
}
pub fn is_invalid(&self) -> bool {
pub(crate) fn is_invalid(&self) -> bool {
// https://immersive-web.github.io/layers/#xrwebglsubimagetype
#[cfg(feature = "webxr")]
if let WebGLTextureOwner::WebXR(ref session) = self.owner {
@ -278,15 +278,15 @@ impl WebGLTexture {
self.is_deleted.get()
}
pub fn is_immutable(&self) -> bool {
pub(crate) fn is_immutable(&self) -> bool {
self.immutable_levels.get().is_some()
}
pub fn target(&self) -> Option<u32> {
pub(crate) fn target(&self) -> Option<u32> {
self.target.get()
}
pub fn maybe_get_tex_parameter(&self, param: TexParameter) -> Option<TexParameterValue> {
pub(crate) fn maybe_get_tex_parameter(&self, param: TexParameter) -> Option<TexParameterValue> {
match param {
TexParameter::Int(TexParameterInt::TextureImmutableLevels) => Some(
TexParameterValue::Int(self.immutable_levels.get().unwrap_or(0) as i32),
@ -300,7 +300,7 @@ impl WebGLTexture {
/// We have to follow the conversion rules for GLES 2.0. See:
/// <https://www.khronos.org/webgl/public-mailing-list/archives/1008/msg00014.html>
pub fn tex_parameter(&self, param: u32, value: TexParameterValue) -> WebGLResult<()> {
pub(crate) fn tex_parameter(&self, param: u32, value: TexParameterValue) -> WebGLResult<()> {
let target = self.target().unwrap();
let (int_value, float_value) = match value {
@ -356,15 +356,15 @@ impl WebGLTexture {
}
}
pub fn min_filter(&self) -> u32 {
pub(crate) fn min_filter(&self) -> u32 {
self.min_filter.get()
}
pub fn mag_filter(&self) -> u32 {
pub(crate) fn mag_filter(&self) -> u32 {
self.mag_filter.get()
}
pub fn is_using_linear_filtering(&self) -> bool {
pub(crate) fn is_using_linear_filtering(&self) -> bool {
let filters = [self.min_filter.get(), self.mag_filter.get()];
filters.iter().any(|filter| {
matches!(
@ -377,7 +377,7 @@ impl WebGLTexture {
})
}
pub fn populate_mip_chain(&self, first_level: u32, last_level: u32) -> WebGLResult<()> {
pub(crate) fn populate_mip_chain(&self, first_level: u32, last_level: u32) -> WebGLResult<()> {
let base_image_info = self
.image_info_at_face(0, first_level)
.ok_or(WebGLError::InvalidOperation)?;
@ -451,12 +451,16 @@ impl WebGLTexture {
}
}
pub fn image_info_for_target(&self, target: &TexImageTarget, level: u32) -> Option<ImageInfo> {
pub(crate) fn image_info_for_target(
&self,
target: &TexImageTarget,
level: u32,
) -> Option<ImageInfo> {
let face_index = self.face_index_for_target(target);
self.image_info_at_face(face_index, level)
}
pub fn image_info_at_face(&self, face: u8, level: u32) -> Option<ImageInfo> {
pub(crate) fn image_info_at_face(&self, face: u8, level: u32) -> Option<ImageInfo> {
let pos = (level * self.face_count.get() as u32) + face as u32;
self.image_info_array.borrow()[pos as usize]
}
@ -479,15 +483,15 @@ impl WebGLTexture {
self.image_info_at_face(0, self.base_mipmap_level)
}
pub fn attach_to_framebuffer(&self, fb: &WebGLFramebuffer) {
pub(crate) fn attach_to_framebuffer(&self, fb: &WebGLFramebuffer) {
self.attached_framebuffer.set(Some(fb));
}
pub fn detach_from_framebuffer(&self) {
pub(crate) fn detach_from_framebuffer(&self) {
self.attached_framebuffer.set(None);
}
pub fn storage(
pub(crate) fn storage(
&self,
target: TexImageTarget,
levels: u32,
@ -547,7 +551,7 @@ impl Drop for WebGLTexture {
}
#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)]
pub struct ImageInfo {
pub(crate) struct ImageInfo {
width: u32,
height: u32,
depth: u32,
@ -558,19 +562,19 @@ pub struct ImageInfo {
}
impl ImageInfo {
pub fn width(&self) -> u32 {
pub(crate) fn width(&self) -> u32 {
self.width
}
pub fn height(&self) -> u32 {
pub(crate) fn height(&self) -> u32 {
self.height
}
pub fn internal_format(&self) -> TexFormat {
pub(crate) fn internal_format(&self) -> TexFormat {
self.internal_format
}
pub fn data_type(&self) -> Option<TexDataType> {
pub(crate) fn data_type(&self) -> Option<TexDataType> {
self.data_type
}
@ -595,17 +599,17 @@ impl ImageInfo {
}
#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf)]
pub enum TexCompressionValidation {
pub(crate) enum TexCompressionValidation {
None,
S3TC,
}
#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf)]
pub struct TexCompression {
pub(crate) struct TexCompression {
#[no_trace]
pub format: TexFormat,
pub bytes_per_block: u8,
pub block_width: u8,
pub block_height: u8,
pub validation: TexCompressionValidation,
pub(crate) format: TexFormat,
pub(crate) bytes_per_block: u8,
pub(crate) block_width: u8,
pub(crate) block_height: u8,
pub(crate) validation: TexCompressionValidation,
}