mirror of
https://github.com/penpot/penpot.git
synced 2026-03-22 10:23:43 +00:00
Merge pull request #8674 from penpot/ladybenko-13720-flag-wasm-debug-info
🔧 Show / Hide wasm info label via config flag
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,7 +3,6 @@ mod emscripten;
|
||||
mod error;
|
||||
mod math;
|
||||
mod mem;
|
||||
mod options;
|
||||
mod performance;
|
||||
mod render;
|
||||
mod shapes;
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
@@ -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<f32>,
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user