Skip to content

Commit cb11a94

Browse files
AxiomaticSemanticsAxiomaticSemantics
AxiomaticSemantics
and
AxiomaticSemantics
committed
Constify SpritePipelineKey implementation. (#6976)
# Objective - Describe the objective or issue this PR addresses. SpritePipelineKey could use more constification. ## Solution Constify SpritePipelineKey implementation. ## Changelog Co-authored-by: AxiomaticSemantics <[email protected]>
1 parent 909b711 commit cb11a94

File tree

1 file changed

+9
-5
lines changed
  • crates/bevy_sprite/src/render

1 file changed

+9
-5
lines changed

crates/bevy_sprite/src/render/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,25 +160,29 @@ impl SpritePipelineKey {
160160
const MSAA_MASK_BITS: u32 = 0b111;
161161
const MSAA_SHIFT_BITS: u32 = 32 - Self::MSAA_MASK_BITS.count_ones();
162162

163-
pub fn from_msaa_samples(msaa_samples: u32) -> Self {
163+
#[inline]
164+
pub const fn from_msaa_samples(msaa_samples: u32) -> Self {
164165
let msaa_bits =
165166
(msaa_samples.trailing_zeros() & Self::MSAA_MASK_BITS) << Self::MSAA_SHIFT_BITS;
166-
Self::from_bits(msaa_bits).unwrap()
167+
Self::from_bits_truncate(msaa_bits)
167168
}
168169

169-
pub fn msaa_samples(&self) -> u32 {
170+
#[inline]
171+
pub const fn msaa_samples(&self) -> u32 {
170172
1 << ((self.bits >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS)
171173
}
172174

173-
pub fn from_colored(colored: bool) -> Self {
175+
#[inline]
176+
pub const fn from_colored(colored: bool) -> Self {
174177
if colored {
175178
SpritePipelineKey::COLORED
176179
} else {
177180
SpritePipelineKey::NONE
178181
}
179182
}
180183

181-
pub fn from_hdr(hdr: bool) -> Self {
184+
#[inline]
185+
pub const fn from_hdr(hdr: bool) -> Self {
182186
if hdr {
183187
SpritePipelineKey::HDR
184188
} else {

0 commit comments

Comments
 (0)