diff --git a/common/src/app/common/flags.cljc b/common/src/app/common/flags.cljc index 9b64aca37b..9e70950566 100644 --- a/common/src/app/common/flags.cljc +++ b/common/src/app/common/flags.cljc @@ -136,6 +136,8 @@ :webhooks ;; TODO: deprecate this flag and consolidate the code :render-wasm-dpr + ;; Show WASM renderer info label (hidden by default). + :render-wasm-info :hide-release-modal :subscriptions :subscriptions-old diff --git a/frontend/src/app/render_wasm/api.cljs b/frontend/src/app/render_wasm/api.cljs index e4d097cc06..5ffc60a0bd 100644 --- a/frontend/src/app/render_wasm/api.cljs +++ b/frontend/src/app/render_wasm/api.cljs @@ -55,10 +55,11 @@ (defn text-editor-wasm? [] - (let [runtime-features (get @st/state :features-runtime) - enabled-features (get @st/state :features)] - (or (contains? runtime-features "text-editor-wasm/v1") - (contains? enabled-features "text-editor-wasm/v1")))) + (or (contains? cf/flags :feature-text-editor-wasm) + (let [runtime-features (get @st/state :features-runtime) + enabled-features (get @st/state :features)] + (or (contains? runtime-features "text-editor-wasm/v1") + (contains? enabled-features "text-editor-wasm/v1"))))) (def ^:const UUID-U8-SIZE 16) (def ^:const UUID-U32-SIZE (/ UUID-U8-SIZE 4)) @@ -1401,6 +1402,8 @@ (dbg/enabled? :wasm-viewbox) (bit-or 2r00000000000000000000000000000001) (text-editor-wasm?) + (bit-or 2r00000000000000000000000000000100) + (contains? cf/flags :render-wasm-info) (bit-or 2r00000000000000000000000000001000))) (defn set-canvas-size diff --git a/render-wasm/src/main.rs b/render-wasm/src/main.rs index 017540a11b..ca9d1cc266 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 beeeec5a30..0000000000 --- a/render-wasm/src/options.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub const DEBUG_VISIBLE: u32 = 0x01; -pub const PROFILE_REBUILD_TILES: u32 = 0x02; -pub const FAST_MODE: u32 = 0x04; -pub const INFO_TEXT: u32 = 0x08; diff --git a/render-wasm/src/render/debug.rs b/render-wasm/src/render/debug.rs index 27f8da07a8..624cdaef78 100644 --- a/render-wasm/src/render/debug.rs +++ b/render-wasm/src/render/debug.rs @@ -41,6 +41,10 @@ pub fn render_debug_cache_surface(render_state: &mut RenderState) { } pub fn render_wasm_label(render_state: &mut RenderState) { + if !render_state.options.show_wasm_info() { + return; + } + let canvas = render_state.surfaces.canvas(SurfaceId::Target); let skia::ISize { width, height } = canvas.base_layer_size(); let mut paint = skia::Paint::default(); @@ -57,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 d6f1d1396f..9505d0b254 100644 --- a/render-wasm/src/render/options.rs +++ b/render-wasm/src/render/options.rs @@ -1,38 +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::INFO_TEXT == options::INFO_TEXT + 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 & SHOW_WASM_INFO == SHOW_WASM_INFO } }