From 619842152d62cd29d2a4387a8a18802e2c6e5352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Albeza?= Date: Wed, 18 Mar 2026 13:16:13 +0100 Subject: [PATCH] :recycle: Refactor render options (wasm) --- frontend/src/app/render_wasm/api.cljs | 4 ++-- render-wasm/src/main.rs | 1 - render-wasm/src/options.rs | 5 ----- render-wasm/src/render/debug.rs | 2 +- render-wasm/src/render/options.rs | 25 +++++++++++++------------ 5 files changed, 16 insertions(+), 21 deletions(-) delete mode 100644 render-wasm/src/options.rs diff --git a/frontend/src/app/render_wasm/api.cljs b/frontend/src/app/render_wasm/api.cljs index ddbd3d0085..04546d9ef1 100644 --- a/frontend/src/app/render_wasm/api.cljs +++ b/frontend/src/app/render_wasm/api.cljs @@ -1401,9 +1401,9 @@ (dbg/enabled? :wasm-viewbox) (bit-or 2r00000000000000000000000000000001) (text-editor-wasm?) - (bit-or 2r00000000000000000000000000001000) + (bit-or 2r00000000000000000000000000000100) (contains? cf/flags :render-wasm-info) - (bit-or 2r00000000000000000000000000010000))) + (bit-or 2r00000000000000000000000000001000))) (defn set-canvas-size [canvas] diff --git a/render-wasm/src/main.rs b/render-wasm/src/main.rs index 6e519cc249..ed0ba87f10 100644 --- a/render-wasm/src/main.rs +++ b/render-wasm/src/main.rs @@ -3,7 +3,6 @@ mod emscripten; mod error; mod math; mod mem; -mod options; mod performance; mod render; mod shapes; diff --git a/render-wasm/src/options.rs b/render-wasm/src/options.rs deleted file mode 100644 index 56fa7b0ae1..0000000000 --- a/render-wasm/src/options.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub const DEBUG_VISIBLE: u32 = 0x01; -pub const PROFILE_REBUILD_TILES: u32 = 0x02; -pub const FAST_MODE: u32 = 0x04; -pub const TEXT_EDITOR_V3: u32 = 0x08; -pub const SHOW_WASM_INFO: u32 = 0x10; diff --git a/render-wasm/src/render/debug.rs b/render-wasm/src/render/debug.rs index 9bfa690441..4ff244020b 100644 --- a/render-wasm/src/render/debug.rs +++ b/render-wasm/src/render/debug.rs @@ -61,7 +61,7 @@ pub fn render_wasm_label(render_state: &mut RenderState) { let debug_font = render_state.fonts.debug_font(); canvas.draw_str(str, p, debug_font, &paint); - if render_state.options.show_info_text() { + if render_state.options.is_text_editor_v3() { str = "TEXT EDITOR / V3"; let (scalar, _) = render_state.fonts.debug_font().measure_str(str, None); diff --git a/render-wasm/src/render/options.rs b/render-wasm/src/render/options.rs index dfa8f7ec86..9505d0b254 100644 --- a/render-wasm/src/render/options.rs +++ b/render-wasm/src/render/options.rs @@ -1,42 +1,43 @@ -use crate::options; +// Render options flags +const DEBUG_VISIBLE: u32 = 0x01; +const PROFILE_REBUILD_TILES: u32 = 0x02; +const TEXT_EDITOR_V3: u32 = 0x04; +const SHOW_WASM_INFO: u32 = 0x08; #[derive(Debug, Copy, Clone, PartialEq, Default)] pub struct RenderOptions { pub flags: u32, pub dpr: Option, + fast_mode: bool, } impl RenderOptions { pub fn is_debug_visible(&self) -> bool { - self.flags & options::DEBUG_VISIBLE == options::DEBUG_VISIBLE + self.flags & DEBUG_VISIBLE == DEBUG_VISIBLE } pub fn is_profile_rebuild_tiles(&self) -> bool { - self.flags & options::PROFILE_REBUILD_TILES == options::PROFILE_REBUILD_TILES + self.flags & PROFILE_REBUILD_TILES == PROFILE_REBUILD_TILES } /// Use fast mode to enable / disable expensive operations pub fn is_fast_mode(&self) -> bool { - self.flags & options::FAST_MODE == options::FAST_MODE + self.fast_mode } pub fn set_fast_mode(&mut self, enabled: bool) { - if enabled { - self.flags |= options::FAST_MODE; - } else { - self.flags &= !options::FAST_MODE; - } + self.fast_mode = enabled; } pub fn dpr(&self) -> f32 { self.dpr.unwrap_or(1.0) } - pub fn show_info_text(&self) -> bool { - self.flags & options::TEXT_EDITOR_V3 == options::TEXT_EDITOR_V3 + pub fn is_text_editor_v3(&self) -> bool { + self.flags & TEXT_EDITOR_V3 == TEXT_EDITOR_V3 } pub fn show_wasm_info(&self) -> bool { - self.flags & options::SHOW_WASM_INFO == options::SHOW_WASM_INFO + self.flags & SHOW_WASM_INFO == SHOW_WASM_INFO } }