Fix clippy lints
This commit is contained in:
parent
f193f10ec0
commit
b0d6ffbf17
4 changed files with 15 additions and 19 deletions
|
|
@ -67,21 +67,18 @@ fn main() {
|
||||||
fn pre_render_frames(width: usize, height: usize) -> Vec<Vec<u32>>{
|
fn pre_render_frames(width: usize, height: usize) -> Vec<Vec<u32>>{
|
||||||
let render = |frame_id|{
|
let render = |frame_id|{
|
||||||
let elapsed = ((frame_id as f64)/(60.0))*2.0*PI;
|
let elapsed = ((frame_id as f64)/(60.0))*2.0*PI;
|
||||||
let buffer = (0..((width * height) as usize))
|
|
||||||
|
(0..(width * height))
|
||||||
.map(|index| {
|
.map(|index| {
|
||||||
let y = ((index / (width as usize)) as f64)/(height as f64);
|
let y = ((index / width) as f64)/(height as f64);
|
||||||
let x = ((index % (width as usize)) as f64)/(width as f64);
|
let x = ((index % width) as f64)/(width as f64);
|
||||||
let red = ((((y + elapsed).sin()*0.5+0.5)*255.0).round() as u32).clamp(0, 255);
|
let red = ((((y + elapsed).sin()*0.5+0.5)*255.0).round() as u32).clamp(0, 255);
|
||||||
let green = ((((x + elapsed).sin()*0.5+0.5)*255.0).round() as u32).clamp(0, 255);
|
let green = ((((x + elapsed).sin()*0.5+0.5)*255.0).round() as u32).clamp(0, 255);
|
||||||
let blue = ((((y - elapsed).cos()*0.5+0.5)*255.0).round() as u32).clamp(0, 255);
|
let blue = ((((y - elapsed).cos()*0.5+0.5)*255.0).round() as u32).clamp(0, 255);
|
||||||
|
|
||||||
let color = blue | (green << 8) | (red << 16);
|
blue | (green << 8) | (red << 16)
|
||||||
|
|
||||||
color
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>()
|
||||||
|
|
||||||
buffer
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@ fn main() {
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
Event::RedrawRequested(window_id) if window_id == window.id() => {
|
Event::RedrawRequested(window_id) if window_id == window.id() => {
|
||||||
let buffer = (0..((BUFFER_WIDTH * BUFFER_HEIGHT) as usize))
|
let buffer = (0..(BUFFER_WIDTH * BUFFER_HEIGHT))
|
||||||
.map(|index| {
|
.map(|index| {
|
||||||
let y = index / (BUFFER_WIDTH as usize);
|
let y = index / BUFFER_WIDTH;
|
||||||
let x = index % (BUFFER_WIDTH as usize);
|
let x = index % BUFFER_WIDTH;
|
||||||
let red = x % 255;
|
let red = x % 255;
|
||||||
let green = y % 255;
|
let green = y % 255;
|
||||||
let blue = (x * y) % 255;
|
let blue = (x * y) % 255;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ impl WaylandBuffer {
|
||||||
.expect("Failed to create memfd to store buffer.");
|
.expect("Failed to create memfd to store buffer.");
|
||||||
let tempfile = unsafe { File::from_raw_fd(tempfile_fd) };
|
let tempfile = unsafe { File::from_raw_fd(tempfile_fd) };
|
||||||
let pool_size = width * height * 4;
|
let pool_size = width * height * 4;
|
||||||
let pool = shm.create_pool(tempfile.as_raw_fd(), pool_size, &qh, ());
|
let pool = shm.create_pool(tempfile.as_raw_fd(), pool_size, qh, ());
|
||||||
let released = Arc::new(AtomicBool::new(true));
|
let released = Arc::new(AtomicBool::new(true));
|
||||||
let buffer = pool.create_buffer(
|
let buffer = pool.create_buffer(
|
||||||
0,
|
0,
|
||||||
|
|
@ -41,7 +41,7 @@ impl WaylandBuffer {
|
||||||
height,
|
height,
|
||||||
width * 4,
|
width * 4,
|
||||||
wl_shm::Format::Xrgb8888,
|
wl_shm::Format::Xrgb8888,
|
||||||
&qh,
|
qh,
|
||||||
released.clone(),
|
released.clone(),
|
||||||
);
|
);
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -129,9 +129,8 @@ impl Dispatch<wl_buffer::WlBuffer, Arc<AtomicBool>> for State {
|
||||||
_: &Connection,
|
_: &Connection,
|
||||||
_: &QueueHandle<State>,
|
_: &QueueHandle<State>,
|
||||||
) {
|
) {
|
||||||
match event {
|
if let wl_buffer::Event::Release = event {
|
||||||
wl_buffer::Event::Release => released.store(true, Ordering::SeqCst),
|
released.store(true, Ordering::SeqCst);
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ impl WaylandImpl {
|
||||||
"Failed to create proxy for surface ID.",
|
"Failed to create proxy for surface ID.",
|
||||||
)?;
|
)?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
event_queue: event_queue,
|
event_queue,
|
||||||
qh,
|
qh,
|
||||||
surface,
|
surface,
|
||||||
shm,
|
shm,
|
||||||
|
|
@ -67,7 +67,7 @@ impl WaylandImpl {
|
||||||
buffer
|
buffer
|
||||||
} else {
|
} else {
|
||||||
// If we have more than 1 unreleased buffer, destroy it
|
// If we have more than 1 unreleased buffer, destroy it
|
||||||
if self.buffers.len() == 0 {
|
if self.buffers.is_empty() {
|
||||||
self.buffers.push_back(buffer);
|
self.buffers.push_back(buffer);
|
||||||
}
|
}
|
||||||
WaylandBuffer::new(&self.shm, width, height, &self.qh)
|
WaylandBuffer::new(&self.shm, width, height, &self.qh)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue