Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelselleck committed Oct 29, 2024
1 parent e33e593 commit 8bb1c2f
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 51 deletions.
6 changes: 3 additions & 3 deletions pax-chassis-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ include = ["/src", "/interface/public"]
crate-type = ["cdylib", "rlib"]

[features]
default = ["console_error_panic_hook", "gpu"]
default = ["console_error_panic_hook"]
designtime = ["dep:pax-designtime", "pax-runtime/designtime"]
gpu = []

[dependencies]
piet = "0.7.0"
piet-web = "0.7.0"
pax-runtime = { path = "../pax-runtime", version="0.38.3" }
pax-pixels = {path = "../pax-pixels", version = "0.38.3"}
pax-runtime = { path = "../pax-runtime", version="0.38.3"}
pax-message = {path = "../pax-message", version="0.38.3"}
pax-runtime-api = { path = "../pax-runtime-api", version="0.38.3" }
pax-manifest = {path="../pax-manifest", version="0.38.3"}
pax-designtime = {path="../pax-designtime", version="0.38.3", optional=true}
serde-wasm-bindgen = "0.6"
Expand Down
20 changes: 5 additions & 15 deletions pax-chassis-web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,19 @@
use js_sys::Uint8Array;
use pax_message::ImageLoadInterruptArgs;
use pax_message::ScreenshotData;
use pax_pixels::render_backend::RenderBackend;
use pax_pixels::render_backend::RenderConfig;
use pax_pixels::WgpuRenderer;
use pax_runtime::api::borrow;
use pax_runtime::api::borrow_mut;
use pax_runtime::api::math::Point2;
use pax_runtime::api::use_RefCell;
use pax_runtime::api::ButtonClick;
use pax_runtime::api::Event;
use pax_runtime::api::Focus;
use pax_runtime::api::Platform;
use pax_runtime::api::RenderContext;
use pax_runtime::api::SelectStart;
use pax_runtime::api::TextboxChange;
use pax_runtime::api::OS;
use pax_runtime::pax_pixels_render_context::PaxPixelsRenderer;
use pax_runtime::piet_render_context::PietRenderer;
use pax_runtime::DefinitionToInstanceTraverser;
use pax_runtime_api::borrow_mut;
use pax_runtime_api::Event;
use pax_runtime_api::Focus;
use pax_runtime_api::SelectStart;
use piet_web::WebRenderContext;
use web_sys::CanvasRenderingContext2d;
use web_sys::WebGl2RenderingContext;
use web_sys::WebGlRenderingContext;
use web_time::Instant;
use_RefCell!();

Expand All @@ -34,8 +25,7 @@ pub mod web_render_contexts;
use pax_runtime::PaxEngine;
use std::rc::Rc;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use web_sys::{window, HtmlCanvasElement};
use web_sys::window;

pub use {console_error_panic_hook, console_log};

Expand Down
2 changes: 1 addition & 1 deletion pax-chassis-web/src/web_render_contexts.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pax_runtime_api::RenderContext;
use pax_runtime::api::RenderContext;
use wasm_bindgen::JsCast;
use web_sys::{HtmlCanvasElement, Window};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.pax
2 changes: 1 addition & 1 deletion pax-designer/src/project_mode_toggle/mod.pax
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Group x=50% y=50% width={100% - 20px} height={100% - 20px}>
if self.edit_mode {
<Text text="Play" id=text fill=WHITE />
<Path id=play_symbol class=play_triangle _raycastable=false/>
<Path class=play_triangle _raycastable=false/>
}
if self.running_mode {
<Text text="Stop" id=text fill=WHITE />
Expand Down
7 changes: 2 additions & 5 deletions pax-pixels/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
[package]
name = "pax-pixels"
version = "0.10.7"
version = "0.38.3"
edition = "2021"
authors = ["Samuel Selleck <sellecksamuel@gmail.com>"]
license = "MIT OR Apache-2.0"
homepage = "https://pax.dev/"
repository = "https://www.github.com/pax-lang/pax"
description = "WGPU rendering library for the pax framework"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
pax-runtime-api = {path = "../pax-runtime-api", version="0.38.1"}
pax-runtime-api = {path = "../pax-runtime-api", version="0.38.3"}
log = "0.4.20"
bytemuck = { version = "1.14", features = ["derive"] }
anyhow = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion pax-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pax-designtime = {version="0.38.3", path = "../pax-designtime", optional = true}
pax-runtime-api = {version="0.38.3", path = "../pax-runtime-api"}
piet = "0.7.0"
piet-common = "0.7.0"
pax-pixels = {path = "../pax-pixels"}
pax-pixels = {path = "../pax-pixels", version = "0.38.3"}
serde = {version="1.0.196", features=["derive"]}
wasm-bindgen = {version = "0.2.93", features=["serde-serialize"]}
wasm-bindgen-futures = "0.4.42"
Expand Down
35 changes: 20 additions & 15 deletions pax-runtime/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{
};
use_RefCell!();
use std::collections::HashMap;
use std::ops::Range;
use std::rc::Rc;
use std::sync::atomic::{AtomicUsize, Ordering};

Expand Down Expand Up @@ -270,7 +271,6 @@ impl PaxEngine {
/// a. find lowest node (last child of last node)
/// b. start rendering, from lowest node on-up, throughout tree
pub fn tick(&mut self) -> Vec<NativeMessage> {
// self.runtime_context.set_all_canvases_dirty();
//
// 1. UPDATE NODES (properties, etc.). This part we should be able to
// completely remove once reactive properties dirty-dag is a thing.
Expand All @@ -289,18 +289,7 @@ impl PaxEngine {
}

pub fn render(&mut self, rcs: &mut dyn RenderContext) {
static LAST_LAYER_COUNT: AtomicUsize = AtomicUsize::new(0); // last-patch layer_count
let curr_layer_count = self.runtime_context.layer_count.get();
let old_layer_count = LAST_LAYER_COUNT.load(Ordering::Relaxed);
if old_layer_count != curr_layer_count {
rcs.resize_layers_to(
curr_layer_count,
Rc::clone(&self.runtime_context.dirty_canvases),
);
self.runtime_context
.resize_canvas_layers_to(curr_layer_count);
LAST_LAYER_COUNT.store(curr_layer_count, Ordering::Relaxed)
}
let new_range = self.update_layer_count(rcs);

for i in 0..rcs.layers() {
if self
Expand All @@ -325,8 +314,8 @@ impl PaxEngine {
}
self.runtime_context.clear_all_dirty_canvases();

//dirtify the canvases that where created this frame (why is this needed?)
for i in old_layer_count..curr_layer_count {
//dirtify the canvases that where created this frame
for i in new_range {
self.runtime_context.set_canvas_dirty(i);
}
}
Expand All @@ -345,6 +334,22 @@ impl PaxEngine {
});
}

pub fn update_layer_count(&self, rcs: &mut dyn RenderContext) -> Range<usize> {
static LAST_LAYER_COUNT: AtomicUsize = AtomicUsize::new(0); // last-patch layer_count
let curr_layer_count = self.runtime_context.layer_count.get();
let old_layer_count = LAST_LAYER_COUNT.load(Ordering::Relaxed);
if old_layer_count != curr_layer_count {
rcs.resize_layers_to(
curr_layer_count,
Rc::clone(&self.runtime_context.dirty_canvases),
);
self.runtime_context
.resize_canvas_layers_to(curr_layer_count);
LAST_LAYER_COUNT.store(curr_layer_count, Ordering::Relaxed)
}
old_layer_count..curr_layer_count
}

pub fn global_dispatch_focus(&self, args: Focus) -> bool {
let mut prevent_default = false;
self.root_expanded_node
Expand Down
9 changes: 0 additions & 9 deletions pax-runtime/src/engine/occlusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,6 @@ fn update_node_occlusion_recursive(
.map(|v| v.to_u32()),
};

let cp = borrow!(node.common_properties);
let cp = borrow!(cp);
if cp
.id
.read(|i| i.as_ref().is_some_and(|i| i == "play_symbol"))
{
log::debug!("new occl: {:#?}", new_occlusion);
}

if (layer == Layer::Native || borrow!(node.instance_node).clips_content(&node))
&& node.occlusion.get() != new_occlusion
{
Expand Down
1 change: 0 additions & 1 deletion pax-runtime/src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ impl RuntimeContext {

pub fn clear_all_dirty_canvases(&self) {
let mut dirty_canvases = borrow_mut!(self.dirty_canvases);
log::debug!("dirty canvases: {:#?}", dirty_canvases);
for v in dirty_canvases.iter_mut() {
*v = false;
}
Expand Down

0 comments on commit 8bb1c2f

Please sign in to comment.