aboutsummaryrefslogtreecommitdiff
path: root/stockton-passes/src/ui.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-25 17:44:23 +0100
committertcmal <me@aria.rip>2024-08-25 17:44:23 +0100
commit13d1d5214d7d7043f22dee0837fd6600aaa50797 (patch)
treed2adedb0c5a0986bab28855b10aa54e8575357d8 /stockton-passes/src/ui.rs
parent6ab13f2d0cb345795f761181a06777ade61ff09c (diff)
refactor(all): various cleanup
Diffstat (limited to 'stockton-passes/src/ui.rs')
-rw-r--r--stockton-passes/src/ui.rs22
1 files changed, 8 insertions, 14 deletions
diff --git a/stockton-passes/src/ui.rs b/stockton-passes/src/ui.rs
index 4b4e1c2..bc1ba69 100644
--- a/stockton-passes/src/ui.rs
+++ b/stockton-passes/src/ui.rs
@@ -117,7 +117,9 @@ impl<'a> DrawPass for UiDrawPass<'a> {
}
let (_out, shapes) = ui.end_frame();
- let screen = ui.dimensions().ok_or(anyhow!("UI not set up properly."))?;
+ let screen = ui
+ .dimensions()
+ .ok_or_else(|| anyhow!("UI not set up properly."))?;
let shapes = ui.ctx().tessellate(shapes);
for ClippedMesh(rect, tris) in shapes.iter() {
@@ -376,23 +378,15 @@ impl LoadableImage for UiTexture {
fn height(&self) -> u32 {
self.0.height as u32
}
- fn copy_row(&self, y: u32, ptr: *mut u8) {
+ unsafe fn copy_row(&self, y: u32, ptr: *mut u8) {
let row_size = self.0.width as u32;
let pixels = &self.0.pixels[(y * row_size) as usize..((y + 1) * row_size) as usize];
for (i, x) in pixels.iter().enumerate() {
- unsafe {
- *ptr.offset(i as isize * 4) = 255;
- *ptr.offset((i as isize * 4) + 1) = 255;
- *ptr.offset((i as isize * 4) + 2) = 255;
- *ptr.offset((i as isize * 4) + 3) = *x;
- }
- }
- }
-
- unsafe fn copy_into(&self, ptr: *mut u8, row_size: usize) {
- for y in 0..self.height() {
- self.copy_row(y, ptr.offset((row_size * y as usize).try_into().unwrap()));
+ *ptr.offset(i as isize * 4) = 255;
+ *ptr.offset((i as isize * 4) + 1) = 255;
+ *ptr.offset((i as isize * 4) + 2) = 255;
+ *ptr.offset((i as isize * 4) + 3) = *x;
}
}
}