mirror of
https://github.com/penpot/penpot.git
synced 2025-04-01 01:21:21 -05:00
🐛 Fix WebGL warning when switching pages
This commit is contained in:
parent
12ec3b4942
commit
2f80d337ad
3 changed files with 15 additions and 8 deletions
|
@ -460,11 +460,6 @@
|
||||||
:stencil true
|
:stencil true
|
||||||
:alpha true})
|
:alpha true})
|
||||||
|
|
||||||
(defn clear-canvas
|
|
||||||
[]
|
|
||||||
;; TODO: perform corresponding cleaning
|
|
||||||
)
|
|
||||||
|
|
||||||
(defn resize-viewbox
|
(defn resize-viewbox
|
||||||
[width height]
|
[width height]
|
||||||
(h/call internal-module "_resize_viewbox" width height))
|
(h/call internal-module "_resize_viewbox" width height))
|
||||||
|
@ -488,10 +483,14 @@
|
||||||
;; Initialize Wasm Render Engine
|
;; Initialize Wasm Render Engine
|
||||||
(h/call internal-module "_init" (/ (.-width ^js canvas) dpr) (/ (.-height ^js canvas) dpr))
|
(h/call internal-module "_init" (/ (.-width ^js canvas) dpr) (/ (.-height ^js canvas) dpr))
|
||||||
(h/call internal-module "_set_render_options" flags dpr))
|
(h/call internal-module "_set_render_options" flags dpr))
|
||||||
|
|
||||||
(set! (.-width canvas) (* dpr (.-clientWidth ^js canvas)))
|
(set! (.-width canvas) (* dpr (.-clientWidth ^js canvas)))
|
||||||
(set! (.-height canvas) (* dpr (.-clientHeight ^js canvas))))
|
(set! (.-height canvas) (* dpr (.-clientHeight ^js canvas))))
|
||||||
|
|
||||||
|
(defn clear-canvas
|
||||||
|
[]
|
||||||
|
;; TODO: perform corresponding cleaning
|
||||||
|
(h/call internal-module "_clean_up"))
|
||||||
|
|
||||||
(defn set-canvas-background
|
(defn set-canvas-background
|
||||||
[background]
|
[background]
|
||||||
(let [rgba (rgba-from-hex background 1)]
|
(let [rgba (rgba-from-hex background 1)]
|
||||||
|
|
|
@ -40,6 +40,12 @@ pub extern "C" fn init(width: i32, height: i32) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn clean_up() {
|
||||||
|
unsafe { STATE = None }
|
||||||
|
mem::free_bytes();
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn set_render_options(debug: u32, dpr: f32) {
|
pub extern "C" fn set_render_options(debug: u32, dpr: f32) {
|
||||||
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
|
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
|
||||||
|
|
|
@ -15,8 +15,10 @@ pub extern "C" fn alloc_bytes(len: usize) -> *mut u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_bytes() {
|
pub fn free_bytes() {
|
||||||
let buffer = unsafe { BUFFERU8.take() }.expect("uninitialized buffer");
|
if unsafe { BUFFERU8.is_some() } {
|
||||||
std::mem::drop(buffer);
|
let buffer = unsafe { BUFFERU8.take() }.expect("uninitialized buffer");
|
||||||
|
std::mem::drop(buffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer_ptr() -> *mut u8 {
|
pub fn buffer_ptr() -> *mut u8 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue