mirror of
https://github.com/penpot/penpot.git
synced 2026-03-23 02:44:04 +00:00
Merge pull request #8451 from penpot/superalex-update-skia-version
🎉 Update skia version
This commit is contained in:
@@ -51,15 +51,18 @@ fn draw_image_fill(
|
||||
canvas.clip_rect(container, skia::ClipOp::Intersect, antialias);
|
||||
}
|
||||
Type::Circle => {
|
||||
let mut oval_path = skia::Path::new();
|
||||
oval_path.add_oval(container, None);
|
||||
let oval_path = {
|
||||
let mut pb = skia::PathBuilder::new();
|
||||
pb.add_oval(container, None, None);
|
||||
pb.detach()
|
||||
};
|
||||
canvas.clip_path(&oval_path, skia::ClipOp::Intersect, antialias);
|
||||
}
|
||||
shape_type @ (Type::Path(_) | Type::Bool(_)) => {
|
||||
if let Some(path) = shape_type.path() {
|
||||
if let Some(path_transform) = path_transform {
|
||||
canvas.clip_path(
|
||||
path.to_skia_path().transform(&path_transform),
|
||||
&path.to_skia_path().make_transform(&path_transform),
|
||||
skia::ClipOp::Intersect,
|
||||
antialias,
|
||||
);
|
||||
|
||||
@@ -24,7 +24,11 @@ pub fn render_overlay(zoom: f32, canvas: &skia::Canvas, shape: &Shape, shapes: S
|
||||
cell.anchor + hv + vv,
|
||||
cell.anchor + vv,
|
||||
];
|
||||
let polygon = skia::Path::polygon(&points, true, None, None);
|
||||
let polygon = {
|
||||
let mut pb = skia::PathBuilder::new();
|
||||
pb.add_polygon(&points, true);
|
||||
pb.detach()
|
||||
};
|
||||
canvas.draw_path(&polygon, &paint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,8 +83,11 @@ fn draw_stroke_on_circle(
|
||||
if let Some(clip_op) = stroke.clip_op() {
|
||||
let layer_rec = skia::canvas::SaveLayerRec::default().paint(&paint);
|
||||
canvas.save_layer(&layer_rec);
|
||||
let mut clip_path = skia::Path::new();
|
||||
clip_path.add_oval(rect, None);
|
||||
let clip_path = {
|
||||
let mut pb = skia::PathBuilder::new();
|
||||
pb.add_oval(rect, None, None);
|
||||
pb.detach()
|
||||
};
|
||||
canvas.clip_path(&clip_path, clip_op, antialias);
|
||||
canvas.draw_oval(stroke_rect, &paint);
|
||||
canvas.restore();
|
||||
@@ -153,8 +156,9 @@ fn draw_stroke_on_path(
|
||||
blur: Option<&ImageFilter>,
|
||||
antialias: bool,
|
||||
) {
|
||||
let mut skia_path = path.to_skia_path();
|
||||
skia_path.transform(path_transform.unwrap_or(&Matrix::default()));
|
||||
let skia_path = path
|
||||
.to_skia_path()
|
||||
.make_transform(path_transform.unwrap_or(&Matrix::default()));
|
||||
|
||||
let is_open = path.is_open();
|
||||
|
||||
@@ -174,15 +178,7 @@ fn draw_stroke_on_path(
|
||||
}
|
||||
}
|
||||
|
||||
handle_stroke_caps(
|
||||
&mut skia_path,
|
||||
stroke,
|
||||
canvas,
|
||||
is_open,
|
||||
paint,
|
||||
blur,
|
||||
antialias,
|
||||
);
|
||||
handle_stroke_caps(&skia_path, stroke, canvas, is_open, paint, blur, antialias);
|
||||
}
|
||||
|
||||
fn handle_stroke_cap(
|
||||
@@ -224,7 +220,7 @@ fn handle_stroke_cap(
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn handle_stroke_caps(
|
||||
path: &mut skia::Path,
|
||||
path: &skia::Path,
|
||||
stroke: &Stroke,
|
||||
canvas: &skia::Canvas,
|
||||
is_open: bool,
|
||||
@@ -232,8 +228,7 @@ fn handle_stroke_caps(
|
||||
blur: Option<&ImageFilter>,
|
||||
_antialias: bool,
|
||||
) {
|
||||
let mut points = vec![Point::default(); path.count_points()];
|
||||
path.get_points(&mut points);
|
||||
let mut points = path.points().to_vec();
|
||||
// Curves can have duplicated points, so let's remove consecutive duplicated points
|
||||
points.dedup();
|
||||
let c_points = points.len();
|
||||
@@ -304,13 +299,16 @@ fn draw_square_cap(
|
||||
let mut transformed_points = points;
|
||||
matrix.map_points(&mut transformed_points, &points);
|
||||
|
||||
let mut path = skia::Path::new();
|
||||
path.move_to(Point::new(center.x, center.y));
|
||||
path.move_to(transformed_points[0]);
|
||||
path.line_to(transformed_points[1]);
|
||||
path.line_to(transformed_points[2]);
|
||||
path.line_to(transformed_points[3]);
|
||||
path.close();
|
||||
let path = {
|
||||
let mut pb = skia::PathBuilder::new();
|
||||
pb.move_to(Point::new(center.x, center.y));
|
||||
pb.move_to(transformed_points[0]);
|
||||
pb.line_to(transformed_points[1]);
|
||||
pb.line_to(transformed_points[2]);
|
||||
pb.line_to(transformed_points[3]);
|
||||
pb.close();
|
||||
pb.detach()
|
||||
};
|
||||
canvas.draw_path(&path, paint);
|
||||
}
|
||||
|
||||
@@ -338,13 +336,15 @@ fn draw_arrow_cap(
|
||||
let mut transformed_points = points;
|
||||
matrix.map_points(&mut transformed_points, &points);
|
||||
|
||||
let mut path = skia::Path::new();
|
||||
path.move_to(transformed_points[1]);
|
||||
path.line_to(transformed_points[0]);
|
||||
path.line_to(transformed_points[2]);
|
||||
path.move_to(Point::new(center.x, center.y));
|
||||
path.line_to(transformed_points[0]);
|
||||
|
||||
let path = {
|
||||
let mut pb = skia::PathBuilder::new();
|
||||
pb.move_to(transformed_points[1]);
|
||||
pb.line_to(transformed_points[0]);
|
||||
pb.line_to(transformed_points[2]);
|
||||
pb.move_to(Point::new(center.x, center.y));
|
||||
pb.line_to(transformed_points[0]);
|
||||
pb.detach()
|
||||
};
|
||||
canvas.draw_path(&path, paint);
|
||||
}
|
||||
|
||||
@@ -372,12 +372,14 @@ fn draw_triangle_cap(
|
||||
let mut transformed_points = points;
|
||||
matrix.map_points(&mut transformed_points, &points);
|
||||
|
||||
let mut path = skia::Path::new();
|
||||
path.move_to(transformed_points[0]);
|
||||
path.line_to(transformed_points[1]);
|
||||
path.line_to(transformed_points[2]);
|
||||
path.close();
|
||||
|
||||
let path = {
|
||||
let mut pb = skia::PathBuilder::new();
|
||||
pb.move_to(transformed_points[0]);
|
||||
pb.line_to(transformed_points[1]);
|
||||
pb.line_to(transformed_points[2]);
|
||||
pb.close();
|
||||
pb.detach()
|
||||
};
|
||||
canvas.draw_path(&path, paint);
|
||||
}
|
||||
|
||||
@@ -441,8 +443,7 @@ fn draw_image_stroke_in_container(
|
||||
shape_type @ (Type::Path(_) | Type::Bool(_)) => {
|
||||
if let Some(p) = shape_type.path() {
|
||||
canvas.save();
|
||||
let mut path = p.to_skia_path();
|
||||
path.transform(&path_transform.unwrap());
|
||||
let path = p.to_skia_path().make_transform(&path_transform.unwrap());
|
||||
let stroke_kind = stroke.render_kind(p.is_open());
|
||||
match stroke_kind {
|
||||
StrokeKind::Inner => {
|
||||
@@ -464,7 +465,7 @@ fn draw_image_stroke_in_container(
|
||||
canvas.draw_path(&path, &thin_paint);
|
||||
}
|
||||
handle_stroke_caps(
|
||||
&mut path,
|
||||
&path,
|
||||
stroke,
|
||||
canvas,
|
||||
is_open,
|
||||
@@ -504,8 +505,7 @@ fn draw_image_stroke_in_container(
|
||||
// Clear outer stroke for paths if necessary. When adding an outer stroke we need to empty the stroke added too in the inner area.
|
||||
if let Type::Path(p) = &shape.shape_type {
|
||||
if stroke.render_kind(p.is_open()) == StrokeKind::Outer {
|
||||
let mut path = p.to_skia_path();
|
||||
path.transform(&path_transform.unwrap());
|
||||
let path = p.to_skia_path().make_transform(&path_transform.unwrap());
|
||||
let mut clear_paint = skia::Paint::default();
|
||||
clear_paint.set_blend_mode(skia::BlendMode::Clear);
|
||||
clear_paint.set_anti_alias(antialias);
|
||||
|
||||
@@ -456,11 +456,7 @@ impl Surfaces {
|
||||
self.current.height() - TILE_SIZE_MULTIPLIER * self.margins.height,
|
||||
);
|
||||
|
||||
let snapshot = self.current.image_snapshot();
|
||||
let mut direct_context = self.current.direct_context();
|
||||
let tile_image_opt = snapshot
|
||||
.make_subset(direct_context.as_mut(), rect)
|
||||
.or_else(|| self.current.image_snapshot_with_bounds(rect));
|
||||
let tile_image_opt = self.current.image_snapshot_with_bounds(rect);
|
||||
|
||||
if let Some(tile_image) = tile_image_opt {
|
||||
// Draw to cache first (takes reference), then move to tile cache
|
||||
|
||||
Reference in New Issue
Block a user