Skip to content

Commit

Permalink
delete PixelInfo and just provide pixel_size
Browse files Browse the repository at this point in the history
  • Loading branch information
hymm committed Nov 28, 2022
1 parent af44e98 commit 9781f12
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions crates/bevy_render/src/texture/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,34 +467,15 @@ impl Volume for Extent3d {
}
}

/// Information about the pixel size in bytes and the number of different components.
pub struct PixelInfo {
/// The size of a component of a pixel in bytes.
pub type_size: usize,
/// The amount of different components (color channels).
pub num_components: usize,
}

/// Extends the wgpu [`TextureFormat`] with information about the pixel.
pub trait TextureFormatPixelInfo {
/// Returns the pixel information of the format.
fn pixel_info(&self) -> PixelInfo;
/// Returns the size of a pixel of the format.
fn pixel_size(&self) -> usize {
let info = self.pixel_info();
info.type_size * info.num_components
}
/// Returns the size in bytes of a pixel of the format.
fn pixel_size(&self) -> usize;
}

impl TextureFormatPixelInfo for TextureFormat {
#[allow(clippy::match_same_arms)]
fn pixel_info(&self) -> PixelInfo {
let info = self.describe();

PixelInfo {
type_size: info.block_size.into(),
num_components: info.components.into(),
}
fn pixel_size(&self) -> usize {
self.describe().block_size.into()
}
}

Expand Down

0 comments on commit 9781f12

Please sign in to comment.