This commit is contained in:
Aitor Moreno
2025-07-21 09:49:46 +02:00
parent f56420d327
commit 5b26a9a269
2 changed files with 43 additions and 7 deletions

View File

@@ -27,7 +27,7 @@ export function assignCanvas(canvas) {
context.getExtension("WEBGL_debug_renderer_info"); context.getExtension("WEBGL_debug_renderer_info");
Module._init(canvas.width, canvas.height); Module._init(canvas.width, canvas.height);
Module._set_render_options(0, 1); Module._set_render_options(1, 1);
} }
export function hexToU32ARGB(hex, opacity = 1) { export function hexToU32ARGB(hex, opacity = 1) {

View File

@@ -12,7 +12,7 @@ mod surfaces;
mod text; mod text;
mod ui; mod ui;
use skia_safe::{self as skia, Matrix, Rect}; use skia_safe::{self as skia, Color, Matrix, Rect};
use std::borrow::Cow; use std::borrow::Cow;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
@@ -516,6 +516,7 @@ impl RenderState {
| SurfaceId::DropShadows as u32 | SurfaceId::DropShadows as u32
| SurfaceId::InnerShadows as u32; | SurfaceId::InnerShadows as u32;
self.surfaces.apply_mut(surface_ids, |s| { self.surfaces.apply_mut(surface_ids, |s| {
emscripten::log!(emscripten::Log::Default, "render_shape::save");
s.canvas().save(); s.canvas().save();
}); });
@@ -536,8 +537,10 @@ impl RenderState {
match &shape.shape_type { match &shape.shape_type {
Type::SVGRaw(sr) => { Type::SVGRaw(sr) => {
if let Some(modifiers) = modifiers { if let Some(modifiers) = modifiers {
emscripten::log!(emscripten::Log::Default, "render_shape::concat (modifiers)");
self.surfaces.canvas(SurfaceId::Fills).concat(modifiers); self.surfaces.canvas(SurfaceId::Fills).concat(modifiers);
} }
emscripten::log!(emscripten::Log::Default, "render_shape::concat");
self.surfaces.canvas(SurfaceId::Fills).concat(&matrix); self.surfaces.canvas(SurfaceId::Fills).concat(&matrix);
if let Some(svg) = shape.svg.as_ref() { if let Some(svg) = shape.svg.as_ref() {
svg.render(self.surfaces.canvas(SurfaceId::Fills)) svg.render(self.surfaces.canvas(SurfaceId::Fills))
@@ -562,6 +565,7 @@ impl RenderState {
| SurfaceId::DropShadows as u32 | SurfaceId::DropShadows as u32
| SurfaceId::InnerShadows as u32; | SurfaceId::InnerShadows as u32;
self.surfaces.apply_mut(surface_ids, |s| { self.surfaces.apply_mut(surface_ids, |s| {
emscripten::log!(emscripten::Log::Default, "render_shape::concat");
s.canvas().concat(&matrix); s.canvas().concat(&matrix);
}); });
@@ -621,6 +625,7 @@ impl RenderState {
| SurfaceId::DropShadows as u32 | SurfaceId::DropShadows as u32
| SurfaceId::InnerShadows as u32; | SurfaceId::InnerShadows as u32;
self.surfaces.apply_mut(surface_ids, |s| { self.surfaces.apply_mut(surface_ids, |s| {
emscripten::log!(emscripten::Log::Default, "render_shape::concat");
s.canvas().concat(&matrix); s.canvas().concat(&matrix);
}); });
@@ -661,6 +666,7 @@ impl RenderState {
| SurfaceId::DropShadows as u32 | SurfaceId::DropShadows as u32
| SurfaceId::InnerShadows as u32; | SurfaceId::InnerShadows as u32;
self.surfaces.apply_mut(surface_ids, |s| { self.surfaces.apply_mut(surface_ids, |s| {
emscripten::log!(emscripten::Log::Default, "render_shape::restore");
s.canvas().restore(); s.canvas().restore();
}); });
} }
@@ -992,16 +998,36 @@ impl RenderState {
self.render_is_full = false; self.render_is_full = false;
} }
if self.options.is_debug_visible() { emscripten::log!(emscripten::Log::Default, "dumping tiles");
debug::render(self);
}
while let Some(next_tile) = self.pending_tiles.pop() { while let Some(next_tile) = self.pending_tiles.pop() {
emscripten::log!(emscripten::Log::Default, "next_tile {} {}", next_tile.0, next_tile.1); emscripten::log!(emscripten::Log::Default, "next_tile {} {}", next_tile.0, next_tile.1);
self.update_render_context(&next_tile); if self.surfaces.has_cached_tile_surface(next_tile) {
emscripten::log!(emscripten::Log::Default, "cached");
performance::begin_measure!("render_shape_tree::cached");
let tile_rect = self.get_current_tile_bounds();
self.surfaces.draw_cached_tile_surface(
next_tile,
tile_rect,
self.background_color,
);
performance::end_measure!("render_shape_tree::cached");
if self.options.is_debug_visible() {
debug::render_workspace_current_tile(
self,
"Cached".to_string(),
next_tile,
tile_rect,
);
}
}
// self.update_render_context(&next_tile);
self.render_current_tile_to_final_canvas(false); self.render_current_tile_to_final_canvas(false);
} }
if self.options.is_debug_visible() {
debug::render(self);
}
debug::render_wasm_label(self); debug::render_wasm_label(self);
emscripten::log!(emscripten::Log::Default, "render_shape_tree_full:end"); emscripten::log!(emscripten::Log::Default, "render_shape_tree_full:end");
@@ -1104,6 +1130,16 @@ impl RenderState {
.to_string(), .to_string(),
)?; )?;
/*
let mut paint = skia::Paint::default();
paint.set_color(Color::from_argb(255, 255, 0, 255));
paint.set_style(skia::PaintStyle::Fill);
paint.set_anti_alias(false);
paint.set_blend_mode(skia::BlendMode::SrcOver);
self.surfaces.draw_rect_to(SurfaceId::Current, element, &paint);
*/
emscripten::log!(emscripten::Log::Default, "a {} {}", element.id, node_render_state.is_root()); emscripten::log!(emscripten::Log::Default, "a {} {}", element.id, node_render_state.is_root());
if !node_render_state.is_root() { if !node_render_state.is_root() {
let mut transformed_element: Cow<Shape> = Cow::Borrowed(element); let mut transformed_element: Cow<Shape> = Cow::Borrowed(element);