Skip to content

[Merged by Bors] - Clean up duplicated color conversion code #4360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions crates/bevy_sprite/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,9 @@ pub fn queue_sprites(

// Store the vertex data and add the item to the render phase
if current_batch.colored {
let color = extracted_sprite.color.as_linear_rgba_f32();
// encode color as a single u32 to save space
let color = (color[0] * 255.0) as u32
| ((color[1] * 255.0) as u32) << 8
| ((color[2] * 255.0) as u32) << 16
| ((color[3] * 255.0) as u32) << 24;
let color = extracted_sprite.color.as_linear_rgba_u32();

for i in QUAD_INDICES.iter() {
sprite_meta.colored_vertices.push(ColoredSpriteVertex {
position: positions[*i],
Expand Down
6 changes: 1 addition & 5 deletions crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,8 @@ pub fn prepare_uinodes(
]
.map(|pos| pos / atlas_extent);

let color = extracted_uinode.color.as_linear_rgba_f32();
// encode color as a single u32 to save space
let color = (color[0] * 255.0) as u32
| ((color[1] * 255.0) as u32) << 8
| ((color[2] * 255.0) as u32) << 16
| ((color[3] * 255.0) as u32) << 24;
let color = extracted_uinode.color.as_linear_rgba_u32();

for i in QUAD_INDICES {
ui_meta.vertices.push(UiVertex {
Expand Down