mirror of
https://github.com/penpot/penpot.git
synced 2025-06-11 14:21:39 +02:00
🔧 Fix Rust tests (#6208)
* 🔧 Fix test script (rust wasm) * 🔧 Make code compile in test mode + using aarch64 as a target for tests
This commit is contained in:
parent
d279b6c232
commit
6f91da9461
8 changed files with 50 additions and 8 deletions
|
@ -4,6 +4,7 @@ use crate::uuid::Uuid;
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::view::Viewbox;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use crate::{run_script, run_script_int};
|
||||
|
||||
mod blend;
|
||||
|
@ -33,10 +34,17 @@ const VIEWPORT_INTEREST_AREA_THRESHOLD: i32 = 1;
|
|||
const MAX_BLOCKING_TIME_MS: i32 = 32;
|
||||
const NODE_BATCH_THRESHOLD: i32 = 10;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn get_time() -> i32 {
|
||||
run_script_int!("performance.now()")
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn get_time() -> i32 {
|
||||
let now = std::time::Instant::now();
|
||||
now.elapsed().as_millis() as i32
|
||||
}
|
||||
|
||||
pub struct NodeRenderState {
|
||||
pub id: Uuid,
|
||||
// We use this bool to keep that we've traversed all the children inside this node.
|
||||
|
@ -485,14 +493,24 @@ impl RenderState {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn request_animation_frame(&mut self) -> i32 {
|
||||
run_script_int!("requestAnimationFrame(_process_animation_frame)")
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn request_animation_frame(&mut self) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn cancel_animation_frame(&mut self, frame_id: i32) {
|
||||
run_script!(format!("cancelAnimationFrame({})", frame_id))
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn cancel_animation_frame(&mut self, _frame_id: i32) {}
|
||||
|
||||
pub fn process_animation_frame(
|
||||
&mut self,
|
||||
tree: &mut HashMap<Uuid, Shape>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue