Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Software renderer, runtime renderer fallback, and core consolidation #1748

Merged
merged 64 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
5100b5d
Introduce `iced_renderer` subcrate featuring runtime renderer fallback
hecrj Feb 24, 2023
1475f5f
Update `resvg` in `iced_graphics`
hecrj Feb 25, 2023
27e21a8
Merge branch 'update/svg-deps' into feature/software-renderer
hecrj Feb 25, 2023
a01bc86
Trim measurements in `renderer::Backend`
hecrj Feb 25, 2023
f07fdba
Merge pull request #1733 from iced-rs/update/svg-deps
hecrj Feb 25, 2023
8c373cd
Scaffold `iced_tiny_skia` and connect it to `iced_renderer`
hecrj Feb 25, 2023
535d7a4
Implement basic presentation with `softbuffer` for `iced_tiny_skia`
hecrj Feb 25, 2023
445b31c
Resize `Surface::buffer` instead of reallocating in `iced_tiny_skia`
hecrj Feb 25, 2023
871b7e0
Fix `Padding::fit` on irregular values for an axis
hecrj Feb 25, 2023
be8102e
Merge pull request #1734 from iced-rs/fix/padding-fit
hecrj Feb 25, 2023
5f93437
Bump version of `iced_core` :tada:
hecrj Feb 25, 2023
df5d664
Draft support for `Quad` and `Clip` primitives in `iced_tiny_skia`
hecrj Feb 25, 2023
744f302
Use `Surface::buffer` directly for drawing in `iced_tiny_skia`
hecrj Feb 25, 2023
64fb722
Draft text support in `iced_tiny_skia`
hecrj Feb 26, 2023
3386402
Implement text alignment support in `iced_tiny_skia`
hecrj Feb 26, 2023
4067c42
Fix glyphs with color mask in `iced_tiny_skia`
hecrj Feb 26, 2023
53573cf
Draw debug overlay in `iced_tiny_skia`
hecrj Feb 26, 2023
fbb14bf
Implement `border_radius` support for quads in `iced_tiny_skia`
hecrj Feb 26, 2023
4e615a6
Fix `clippy` lints
hecrj Feb 27, 2023
37ce30f
Use `kurbo` to approximate arcs in `iced_tiny_skia`
hecrj Feb 27, 2023
8750d83
Short-circuit rectangle path building in `iced_tiny_skia`
hecrj Feb 27, 2023
3105ad2
Remove useless `f32` conversion in `iced_tiny_skia`
hecrj Feb 27, 2023
c1ff803
Implement basic glyph cache in `iced_tiny_skia`
hecrj Feb 27, 2023
151daf9
Remove unnecessary `cast_slice` in `iced_tiny_skia`
hecrj Feb 27, 2023
9e815cb
Remove `Fill` variant for `Alignment`
hecrj Feb 27, 2023
fd06de5
Use `get_image_uncached` in `iced_tiny_skia`
hecrj Feb 28, 2023
86b85d1
Merge pull request #1735 from iced-rs/remove-alignment-fill
hecrj Feb 28, 2023
3f6e28f
Use `iced_renderer` instead of `iced_graphics` in root crate
hecrj Feb 28, 2023
5fd5d1c
Implement `Canvas` support for `iced_tiny_skia`
hecrj Mar 1, 2023
5c0427e
Fix `Clip` primitive translation in `iced_tiny_skia`
hecrj Mar 1, 2023
838fd96
Disable `anti_alias` for `Frame::fill_rectangle` in `iced_tiny_skia`
hecrj Mar 1, 2023
119cf2e
Remove magic boolean in `into_paint`
hecrj Mar 1, 2023
350427e
Fix missing `qr_code` module in `iced_native`
hecrj Mar 1, 2023
868f79d
Reuse `ClipMask` in `iced_tiny_skia`
hecrj Mar 1, 2023
b2a9a1e
Fixed fullscreen only being possible on primary monitor.
bungoboingo Mar 2, 2023
a9ca89c
Added example of toggling fullscreen to TODOs.
bungoboingo Mar 2, 2023
bbeaf10
Mark `Primitive` as `non-exhaustive` in `iced_graphics`
hecrj Mar 3, 2023
d13d19b
Rename `canvas::frame` to `canvas` in `iced_wgpu`
hecrj Mar 3, 2023
6cc48b5
Move `Canvas` and `QRCode` to `iced` crate
hecrj Mar 3, 2023
c54409d
Remove `canvas` leftovers in `iced_native`
hecrj Mar 3, 2023
12781c7
Expose `window` commands for Wasm builds
hecrj Mar 3, 2023
d73ca4d
Merge pull request #1742 from bungoboingo/fix/fullscreen
hecrj Mar 3, 2023
3a0d34c
Create `iced_widget` subcrate and re-organize the whole codebase
hecrj Mar 4, 2023
bacbaee
Merge branch 'advanced-text' into feature/software-renderer
hecrj Mar 4, 2023
5fed065
Update `glyphon` in `iced_wgpu`
hecrj Mar 4, 2023
f4cf488
Remove generic `Hasher` and `Event` from `subscription::Recipe`
hecrj Mar 5, 2023
cfb8abb
Use `no_run` for widget doc-tests
hecrj Mar 5, 2023
43414bb
Fix `wasm-bindgen` backend in `iced_futures`
hecrj Mar 5, 2023
8af69be
Converge `Command` types from `iced_futures` and `iced_native`
hecrj Mar 5, 2023
99e0a71
Rename `iced_native` to `iced_runtime`
hecrj Mar 5, 2023
1c36446
Fix `README` of `iced_runtime`
hecrj Mar 5, 2023
06bbcc3
Move `webgl` feature selection for `wgpu` into `iced_wgpu`
hecrj Mar 5, 2023
9b4bcd2
Introduce backend feature flags in `iced_renderer`
hecrj Mar 6, 2023
3a26baa
Remove `image` abstractions in `iced_graphics`
hecrj Mar 7, 2023
bb49e17
Implement `raster` pipeline in `iced_tiny_skia`
hecrj Mar 7, 2023
5b3977d
Implement `vector` pipeline in `iced_tiny_skia`
hecrj Mar 7, 2023
a8d55ce
Trim `raster` cache in `iced_tiny_skia`
hecrj Mar 7, 2023
81d154d
Use default features in `svg` example
hecrj Mar 7, 2023
0850f52
Use `ceil` to avoid cut text in `iced_tiny_skia`
hecrj Mar 7, 2023
24c3d20
Tell `clippy` to go learn the borrow rules
hecrj Mar 7, 2023
d3900e0
Enable renderer backends in `integration` example
hecrj Mar 7, 2023
df68cca
Update `sysinfo` to `0.28`
hecrj Mar 7, 2023
aa4b5bb
Merge branch 'master' into feature/software-renderer
hecrj Mar 7, 2023
424ac81
Implement color filter support for `Primitive::Svg` in `iced_tiny_skia`
hecrj Mar 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reuse ClipMask in iced_tiny_skia
  • Loading branch information
hecrj committed Mar 1, 2023
commit 868f79d22e2be82e98b06d66da3b4cbc6139d7c7
41 changes: 27 additions & 14 deletions tiny_skia/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ impl Backend {
pub fn draw<T: AsRef<str>>(
&mut self,
pixels: &mut tiny_skia::PixmapMut<'_>,
clip_mask: &mut tiny_skia::ClipMask,
primitives: &[Primitive],
viewport: &Viewport,
background_color: Color,
Expand All @@ -38,6 +39,7 @@ impl Backend {
self.draw_primitive(
primitive,
pixels,
clip_mask,
None,
scale_factor,
Vector::ZERO,
Expand All @@ -63,6 +65,7 @@ impl Backend {
vertical_alignment: alignment::Vertical::Top,
},
pixels,
clip_mask,
None,
scale_factor,
Vector::ZERO,
Expand All @@ -76,7 +79,8 @@ impl Backend {
&mut self,
primitive: &Primitive,
pixels: &mut tiny_skia::PixmapMut<'_>,
clip_mask: Option<&tiny_skia::ClipMask>,
clip_mask: &mut tiny_skia::ClipMask,
clip_bounds: Option<Rectangle>,
scale_factor: f32,
translation: Vector,
) {
Expand All @@ -95,6 +99,7 @@ impl Backend {
.post_scale(scale_factor, scale_factor);

let path = rounded_rectangle(*bounds, *border_radius);
let clip_mask = clip_bounds.map(|_| clip_mask as &_);

pixels.fill_path(
&path,
Expand Down Expand Up @@ -151,7 +156,7 @@ impl Backend {
*horizontal_alignment,
*vertical_alignment,
pixels,
clip_mask,
clip_bounds.map(|_| clip_mask as &_),
);
}
Primitive::Image { .. } => {
Expand All @@ -173,7 +178,7 @@ impl Backend {
transform
.post_translate(translation.x, translation.y)
.post_scale(scale_factor, scale_factor),
clip_mask,
clip_bounds.map(|_| clip_mask as &_),
);
}
Primitive::Stroke {
Expand All @@ -189,7 +194,7 @@ impl Backend {
transform
.post_translate(translation.x, translation.y)
.post_scale(scale_factor, scale_factor),
clip_mask,
clip_bounds.map(|_| clip_mask as &_),
);
}
Primitive::Group { primitives } => {
Expand All @@ -198,6 +203,7 @@ impl Backend {
primitive,
pixels,
clip_mask,
clip_bounds,
scale_factor,
translation,
);
Expand All @@ -211,27 +217,37 @@ impl Backend {
content,
pixels,
clip_mask,
clip_bounds,
scale_factor,
translation + *offset,
);
}
Primitive::Clip { bounds, content } => {
let bounds = (*bounds + translation) * scale_factor;

adjust_clip_mask(clip_mask, pixels, bounds);

self.draw_primitive(
content,
pixels,
Some(&rectangular_clip_mask(
pixels,
(*bounds + translation) * scale_factor,
)),
clip_mask,
Some(bounds),
scale_factor,
translation,
);

if let Some(bounds) = clip_bounds {
adjust_clip_mask(clip_mask, pixels, bounds);
} else {
clip_mask.clear();
}
}
Primitive::Cache { content } => {
self.draw_primitive(
content,
pixels,
clip_mask,
clip_bounds,
scale_factor,
translation,
);
Expand Down Expand Up @@ -393,12 +409,11 @@ fn arc_to(
}
}

fn rectangular_clip_mask(
fn adjust_clip_mask(
clip_mask: &mut tiny_skia::ClipMask,
pixels: &tiny_skia::PixmapMut<'_>,
bounds: Rectangle,
) -> tiny_skia::ClipMask {
let mut clip_mask = tiny_skia::ClipMask::new();

) {
let path = {
let mut builder = tiny_skia::PathBuilder::new();
builder.push_rect(bounds.x, bounds.y, bounds.width, bounds.height);
Expand All @@ -415,8 +430,6 @@ fn rectangular_clip_mask(
true,
)
.expect("Set path of clipping area");

clip_mask
}

impl iced_graphics::Backend for Backend {
Expand Down
7 changes: 5 additions & 2 deletions tiny_skia/src/window/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
use std::marker::PhantomData;

pub struct Compositor<Theme> {
clip_mask: tiny_skia::ClipMask,
_theme: PhantomData<Theme>,
}

Expand Down Expand Up @@ -83,17 +84,18 @@ impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> {
}

pub fn new<Theme>(settings: Settings) -> (Compositor<Theme>, Backend) {
// TODO
// TOD
(
Compositor {
clip_mask: tiny_skia::ClipMask::new(),
_theme: PhantomData,
},
Backend::new(settings),
)
}

pub fn present<Theme, T: AsRef<str>>(
_compositor: &mut Compositor<Theme>,
compositor: &mut Compositor<Theme>,
backend: &mut Backend,
surface: &mut Surface,
primitives: &[Primitive],
Expand All @@ -110,6 +112,7 @@ pub fn present<Theme, T: AsRef<str>>(
physical_size.height,
)
.expect("Create pixel map"),
&mut compositor.clip_mask,
primitives,
viewport,
background_color,
Expand Down