1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 05:40:03 -04:00

Implement bytemuck behind a feature (#775)

This commit is contained in:
Stock84
2021-10-07 22:30:15 +02:00
committed by GitHub
parent ce8d863249
commit cd2227814f
12 changed files with 42 additions and 0 deletions

View File

@@ -34,6 +34,7 @@ cint = { version = "^0.2.2", optional = true }
nohash-hasher = "0.2"
parking_lot = { version = "0.11", optional = true } # Using parking_lot over std::sync::Mutex gives 50% speedups in some real-world scenarios.
serde = { version = "1", features = ["derive"], optional = true }
bytemuck = { version = "1.7.2", features = ["derive"], optional = true }
[features]
default = ["default_fonts", "multi_threaded"]
@@ -53,6 +54,9 @@ mint = ["emath/mint"]
# implement serde on most types.
serialize = ["serde", "emath/serde"]
# implement bytemuck on most types.
convert_bytemuck = ["bytemuck", "emath/bytemuck"]
single_threaded = ["atomic_refcell"]
# Only needed if you plan to use the same fonts from multiple threads.

View File

@@ -13,8 +13,10 @@
///
/// Internally this uses 0-255 gamma space `sRGBA` color with premultiplied alpha.
/// Alpha channel is in linear space.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))]
pub struct Color32(pub(crate) [u8; 4]);
impl std::ops::Index<usize> for Color32 {

View File

@@ -7,6 +7,7 @@ use emath::*;
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))]
pub struct Vertex {
/// Logical pixel coordinates (points).
/// (0,0) is the top left corner of the screen.