mirror of
https://github.com/penpot/penpot.git
synced 2026-05-05 16:18:35 +00:00
pass flag to wasm to render rulers
This commit is contained in:
parent
60d2e9c117
commit
0cfaf52d03
@ -1401,15 +1401,17 @@
|
||||
[width height]
|
||||
(h/call wasm/internal-module "_resize_viewbox" width height))
|
||||
|
||||
(defn- debug-flags
|
||||
(defn- render-options-flags
|
||||
[]
|
||||
(cond-> 0
|
||||
(dbg/enabled? :wasm-viewbox)
|
||||
(bit-or 2r00000000000000000000000000000001)
|
||||
(bit-or 0x01)
|
||||
(text-editor-wasm?)
|
||||
(bit-or 2r00000000000000000000000000000100)
|
||||
(bit-or 0x04)
|
||||
(contains? cf/flags :render-wasm-info)
|
||||
(bit-or 2r00000000000000000000000000001000)))
|
||||
(bit-or 0x08)
|
||||
(contains? cf/flags :render-wasm-rulers)
|
||||
(bit-or 0x10)))
|
||||
|
||||
(defn- wasm-aa-threshold-from-route-params
|
||||
"Reads optional `aa_threshold` query param from the router"
|
||||
@ -1438,7 +1440,7 @@
|
||||
(defn init-canvas-context
|
||||
[canvas]
|
||||
(let [gl (unchecked-get wasm/internal-module "GL")
|
||||
flags (debug-flags)
|
||||
flags (render-options-flags)
|
||||
context-id (if (dbg/enabled? :wasm-gl-context-init-error) "fail" "webgl2")
|
||||
context (.getContext ^js canvas context-id default-context-options)
|
||||
context-init? (not (nil? context))
|
||||
|
||||
@ -141,6 +141,8 @@ pub extern "C" fn set_render_options(debug: u32, dpr: f32) -> Result<()> {
|
||||
let render_state = state.render_state_mut();
|
||||
render_state.set_debug_flags(debug);
|
||||
render_state.set_dpr(dpr)?;
|
||||
|
||||
println!("rulers enabled? {:?}", render_state.options.are_rulers_enabled());
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -607,7 +607,7 @@ impl RenderState {
|
||||
}
|
||||
|
||||
pub fn set_debug_flags(&mut self, debug: u32) {
|
||||
self.options.flags = debug;
|
||||
self.options.set_flags(debug);
|
||||
}
|
||||
|
||||
pub fn set_dpr(&mut self, dpr: f32) -> Result<()> {
|
||||
|
||||
@ -3,10 +3,11 @@ const DEBUG_VISIBLE: u32 = 0x01;
|
||||
const PROFILE_REBUILD_TILES: u32 = 0x02;
|
||||
const TEXT_EDITOR_V3: u32 = 0x04;
|
||||
const SHOW_WASM_INFO: u32 = 0x08;
|
||||
const ENABLE_RULERS: u32 = 0x10;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub struct RenderOptions {
|
||||
pub flags: u32,
|
||||
flags: u32,
|
||||
pub dpr: Option<f32>,
|
||||
fast_mode: bool,
|
||||
/// Minimum on-screen size (CSS px at 1:1 zoom) above which vector antialiasing is enabled.
|
||||
@ -25,6 +26,14 @@ impl Default for RenderOptions {
|
||||
}
|
||||
|
||||
impl RenderOptions {
|
||||
pub fn set_flags(&mut self, flags: u32) {
|
||||
self.flags = flags;
|
||||
}
|
||||
|
||||
pub fn are_rulers_enabled(&self) -> bool {
|
||||
self.flags & ENABLE_RULERS == ENABLE_RULERS
|
||||
}
|
||||
|
||||
pub fn is_debug_visible(&self) -> bool {
|
||||
self.flags & DEBUG_VISIBLE == DEBUG_VISIBLE
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user