mirror of
https://github.com/penpot/penpot.git
synced 2026-03-28 06:10:28 +01:00
WIP
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -81,3 +81,4 @@
|
||||
/**/node_modules
|
||||
/**/.yarn/*
|
||||
/.pnpm-store
|
||||
/frontend/src/app/render_wasm/api/shared.js
|
||||
|
||||
@@ -1389,9 +1389,12 @@ impl RenderState {
|
||||
if tree.len() != 0 {
|
||||
let shape = tree.get(id).unwrap();
|
||||
let mut extrect = shape.extrect(tree, scale);
|
||||
println!(">extrect: {extrect:?}");
|
||||
|
||||
let margins = self.surfaces.margins;
|
||||
extrect.offset((margins.width as f32 / scale, margins.height as f32 / scale));
|
||||
|
||||
|
||||
self.surfaces.resize_export_surface(scale, extrect);
|
||||
self.surfaces.update_render_context(extrect, scale);
|
||||
|
||||
@@ -1658,10 +1661,14 @@ impl RenderState {
|
||||
shadow: &Shadow,
|
||||
clip_bounds: Option<ClipStack>,
|
||||
scale: f32,
|
||||
translation: (f32, f32),
|
||||
extra_layer_blur: Option<Blur>,
|
||||
target_surface: SurfaceId,
|
||||
) {
|
||||
|
||||
//let paint = skia::Paint::default();
|
||||
//let canvas = self.surfaces.canvas(SurfaceId::DropShadows);
|
||||
//canvas.draw_rect(shape.selrect, &paint);
|
||||
|
||||
let mut transformed_shadow: Cow<Shadow> = Cow::Borrowed(shadow);
|
||||
transformed_shadow.to_mut().offset = (0.0, 0.0);
|
||||
transformed_shadow.to_mut().color = skia::Color::BLACK;
|
||||
@@ -1720,8 +1727,9 @@ impl RenderState {
|
||||
let mut bounds = drop_filter.compute_fast_bounds(shape_bounds);
|
||||
// Account for the shadow offset so the temporary surface fully contains the shifted blur.
|
||||
bounds.offset(world_offset);
|
||||
// Early cull if the shadow bounds are outside the render area.
|
||||
if !bounds.intersects(self.render_area) {
|
||||
|
||||
// Early cull if the shadow bounds are outside the render area and not in export
|
||||
if !bounds.intersects(self.render_area) && target_surface != SurfaceId::Export {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1729,8 +1737,8 @@ impl RenderState {
|
||||
if scale > 1.0 && shadow.blur <= 0.0 {
|
||||
let drop_canvas = self.surfaces.canvas(SurfaceId::DropShadows);
|
||||
drop_canvas.save();
|
||||
drop_canvas.scale((scale, scale));
|
||||
drop_canvas.translate(translation);
|
||||
//drop_canvas.scale((scale, scale));
|
||||
//drop_canvas.translate(translation);
|
||||
|
||||
self.with_nested_blurs_suppressed(|state| {
|
||||
state.render_shape(
|
||||
@@ -1776,8 +1784,8 @@ impl RenderState {
|
||||
if use_low_zoom_path {
|
||||
let drop_canvas = self.surfaces.canvas(SurfaceId::DropShadows);
|
||||
drop_canvas.save_layer(&layer_rec);
|
||||
drop_canvas.scale((scale, scale));
|
||||
drop_canvas.translate(translation);
|
||||
//drop_canvas.scale((scale, scale));
|
||||
//drop_canvas.translate(translation);
|
||||
|
||||
self.with_nested_blurs_suppressed(|state| {
|
||||
state.render_shape(
|
||||
@@ -1844,8 +1852,8 @@ impl RenderState {
|
||||
if let Some((mut surface, filter_scale)) = filter_result {
|
||||
let drop_canvas = self.surfaces.canvas(SurfaceId::DropShadows);
|
||||
drop_canvas.save();
|
||||
drop_canvas.scale((scale, scale));
|
||||
drop_canvas.translate(translation);
|
||||
//drop_canvas.scale((scale, scale));
|
||||
//drop_canvas.translate(translation);
|
||||
let mut drop_paint = skia::Paint::default();
|
||||
drop_paint.set_image_filter(blur_filter.clone());
|
||||
|
||||
@@ -1909,7 +1917,6 @@ impl RenderState {
|
||||
shadow,
|
||||
clip_bounds.clone(),
|
||||
scale,
|
||||
translation,
|
||||
None,
|
||||
target_surface,
|
||||
);
|
||||
@@ -1939,7 +1946,6 @@ impl RenderState {
|
||||
shadow,
|
||||
nested_clip_bounds,
|
||||
scale,
|
||||
translation,
|
||||
inherited_layer_blur,
|
||||
target_surface,
|
||||
);
|
||||
@@ -1986,12 +1992,14 @@ impl RenderState {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let mut paint = skia::Paint::default();
|
||||
paint.set_color(shadow.color);
|
||||
paint.set_blend_mode(skia::BlendMode::SrcIn);
|
||||
self.surfaces
|
||||
.canvas(SurfaceId::DropShadows)
|
||||
.draw_paint(&paint);
|
||||
|
||||
self.surfaces.canvas(SurfaceId::DropShadows).restore();
|
||||
}
|
||||
|
||||
@@ -1999,39 +2007,91 @@ impl RenderState {
|
||||
let antialias = element.should_use_antialias(scale);
|
||||
self.surfaces.canvas(target_surface).save();
|
||||
for (bounds, corners, transform) in clips.iter() {
|
||||
let mut total_matrix = Matrix::new_identity();
|
||||
total_matrix.pre_scale((scale, scale), None);
|
||||
total_matrix.pre_translate((translation.0, translation.1));
|
||||
total_matrix.pre_concat(transform);
|
||||
if target_surface == SurfaceId::Export {
|
||||
let mut total_matrix = Matrix::new_identity();
|
||||
//total_matrix.pre_scale((scale, scale), None);
|
||||
// total_matrix.pre_translate((-88.0, -28.0));
|
||||
total_matrix.pre_concat(transform);
|
||||
|
||||
self.surfaces.canvas(target_surface).concat(&total_matrix);
|
||||
//self.surfaces
|
||||
// .canvas(target_surface)
|
||||
// .concat(&total_matrix);
|
||||
|
||||
if let Some(corners) = corners {
|
||||
let rrect = RRect::new_rect_radii(*bounds, corners);
|
||||
self.surfaces.canvas(target_surface).clip_rrect(
|
||||
rrect,
|
||||
skia::ClipOp::Intersect,
|
||||
antialias,
|
||||
);
|
||||
let mut bounds = *bounds;
|
||||
//bounds.offset((-88.0, -28.0));
|
||||
// bounds.offset((-899.99, 176.36));
|
||||
bounds.offset((-894.00006, 233.0));
|
||||
|
||||
let canvas = self.surfaces.canvas(target_surface);
|
||||
canvas.save();
|
||||
canvas.concat(&total_matrix);
|
||||
|
||||
let mut paint = skia::Paint::default();
|
||||
paint.set_style(skia::PaintStyle::Stroke);
|
||||
paint.set_color(skia::Color::RED);
|
||||
paint.set_stroke_width(4.0);
|
||||
|
||||
canvas.draw_rect(bounds, &paint);
|
||||
|
||||
println!(">{bounds:?}");
|
||||
|
||||
if let Some(corners) = corners {
|
||||
let rrect = RRect::new_rect_radii(bounds, corners);
|
||||
canvas.clip_rrect(
|
||||
rrect,
|
||||
skia::ClipOp::Intersect,
|
||||
antialias,
|
||||
);
|
||||
} else {
|
||||
canvas.clip_rect(
|
||||
bounds,
|
||||
skia::ClipOp::Intersect,
|
||||
antialias,
|
||||
);
|
||||
}
|
||||
canvas.restore();
|
||||
|
||||
//canvas.reset_matrix();
|
||||
// canvas.restore();
|
||||
} else {
|
||||
self.surfaces.canvas(target_surface).clip_rect(
|
||||
*bounds,
|
||||
skia::ClipOp::Intersect,
|
||||
antialias,
|
||||
);
|
||||
}
|
||||
let mut total_matrix = Matrix::new_identity();
|
||||
total_matrix.pre_scale((scale, scale), None);
|
||||
total_matrix.pre_translate((translation.0, translation.1));
|
||||
total_matrix.pre_concat(transform);
|
||||
|
||||
self.surfaces
|
||||
.canvas(target_surface)
|
||||
.concat(&total_matrix.invert().unwrap_or_default());
|
||||
self.surfaces
|
||||
.canvas(target_surface)
|
||||
.concat(&total_matrix);
|
||||
|
||||
if let Some(corners) = corners {
|
||||
let rrect = RRect::new_rect_radii(*bounds, corners);
|
||||
self.surfaces.canvas(target_surface).clip_rrect(
|
||||
rrect,
|
||||
skia::ClipOp::Intersect,
|
||||
antialias,
|
||||
);
|
||||
} else {
|
||||
self.surfaces.canvas(target_surface).clip_rect(
|
||||
*bounds,
|
||||
skia::ClipOp::Intersect,
|
||||
antialias,
|
||||
);
|
||||
}
|
||||
|
||||
self.surfaces
|
||||
.canvas(SurfaceId::Current)
|
||||
.concat(&total_matrix.invert().unwrap_or_default());
|
||||
}
|
||||
}
|
||||
self.surfaces
|
||||
.draw_into(SurfaceId::DropShadows, target_surface, None);
|
||||
self.surfaces.canvas(target_surface).restore();
|
||||
|
||||
} else {
|
||||
self.surfaces
|
||||
.draw_into(SurfaceId::DropShadows, target_surface, None);
|
||||
}
|
||||
|
||||
self.surfaces
|
||||
.canvas(SurfaceId::DropShadows)
|
||||
.clear(skia::Color::TRANSPARENT);
|
||||
|
||||
@@ -294,7 +294,8 @@ impl Surfaces {
|
||||
let surface_ids = SurfaceId::Fills as u32
|
||||
| SurfaceId::Strokes as u32
|
||||
| SurfaceId::InnerShadows as u32
|
||||
| SurfaceId::TextDropShadows as u32;
|
||||
| SurfaceId::TextDropShadows as u32
|
||||
| SurfaceId::DropShadows as u32;
|
||||
|
||||
// Clear surfaces before updating transformations to remove residual content
|
||||
self.apply_mut(surface_ids, |s| {
|
||||
@@ -306,6 +307,7 @@ impl Surfaces {
|
||||
self.mark_dirty(SurfaceId::Strokes);
|
||||
self.mark_dirty(SurfaceId::InnerShadows);
|
||||
self.mark_dirty(SurfaceId::TextDropShadows);
|
||||
self.mark_dirty(SurfaceId::DropShadows);
|
||||
|
||||
// Update transformations
|
||||
self.apply_mut(surface_ids, |s| {
|
||||
|
||||
Reference in New Issue
Block a user