Skip to content

Commit caf2836

Browse files
authored
Merge pull request #1748 from iced-rs/feature/software-renderer
Software renderer, runtime renderer fallback, and core consolidation
2 parents 11b2c3b + 424ac81 commit caf2836

File tree

261 files changed

+5931
-3959
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

261 files changed

+5931
-3959
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ jobs:
3737
run: cargo build --package tour --target wasm32-unknown-unknown
3838
- name: Check compilation of `todos` example
3939
run: cargo build --package todos --target wasm32-unknown-unknown
40-
- name: Check compilation of `integration_wgpu` example
40+
- name: Check compilation of `integration` example
4141
run: cargo build --package integration --target wasm32-unknown-unknown

Cargo.toml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,21 @@ keywords = ["gui", "ui", "graphics", "interface", "widgets"]
1212
categories = ["gui"]
1313

1414
[features]
15+
default = ["wgpu", "tiny-skia"]
16+
# Enable the `wgpu` GPU-accelerated renderer backend
17+
wgpu = ["iced_renderer/wgpu"]
18+
# Enable the `tiny-skia` software renderer backend
19+
tiny-skia = ["iced_renderer/tiny-skia"]
1520
# Enables the `Image` widget
16-
image = ["iced_wgpu/image", "image_rs"]
21+
image = ["iced_widget/image", "image_rs"]
1722
# Enables the `Svg` widget
18-
svg = ["iced_wgpu/svg"]
23+
svg = ["iced_widget/svg"]
1924
# Enables the `Canvas` widget
20-
canvas = ["iced_graphics/canvas"]
25+
canvas = ["iced_widget/canvas"]
2126
# Enables the `QRCode` widget
22-
qr_code = ["iced_graphics/qr_code"]
27+
qr_code = ["iced_widget/qr_code"]
28+
# Enables lazy widgets
29+
lazy = ["iced_widget/lazy"]
2330
# Enables a debug view in native platforms (press F12)
2431
debug = ["iced_winit/debug"]
2532
# Enables `tokio` as the `executor::Default` on native platforms
@@ -32,11 +39,8 @@ smol = ["iced_futures/smol"]
3239
palette = ["iced_core/palette"]
3340
# Enables querying system information
3441
system = ["iced_winit/system"]
35-
# Enables chrome traces
36-
chrome-trace = [
37-
"iced_winit/chrome-trace",
38-
"iced_wgpu/tracing",
39-
]
42+
# Enables the advanced module
43+
advanced = []
4044

4145
[badges]
4246
maintenance = { status = "actively-developed" }
@@ -46,33 +50,29 @@ members = [
4650
"core",
4751
"futures",
4852
"graphics",
49-
"lazy",
50-
"native",
53+
"runtime",
54+
"renderer",
5155
"style",
56+
"tiny_skia",
5257
"wgpu",
58+
"widget",
5359
"winit",
5460
"examples/*",
5561
]
5662

5763
[dependencies]
5864
iced_core = { version = "0.8", path = "core" }
5965
iced_futures = { version = "0.6", path = "futures" }
60-
iced_native = { version = "0.9", path = "native" }
61-
iced_graphics = { version = "0.7", path = "graphics" }
66+
iced_renderer = { version = "0.1", path = "renderer" }
67+
iced_widget = { version = "0.1", path = "widget" }
6268
iced_winit = { version = "0.8", path = "winit", features = ["application"] }
63-
thiserror = "1.0"
69+
thiserror = "1"
6470

6571
[dependencies.image_rs]
6672
version = "0.24"
6773
package = "image"
6874
optional = true
6975

70-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
71-
iced_wgpu = { version = "0.9", path = "wgpu" }
72-
73-
[target.'cfg(target_arch = "wasm32")'.dependencies]
74-
iced_wgpu = { version = "0.9", path = "wgpu", features = ["webgl"] }
75-
7676
[package.metadata.docs.rs]
7777
rustdoc-args = ["--cfg", "docsrs"]
7878
features = ["image", "svg", "canvas", "qr_code"]

core/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "iced_core"
3-
version = "0.8.0"
3+
version = "0.8.1"
44
authors = ["Héctor Ramón Jiménez <[email protected]>"]
55
edition = "2021"
66
description = "The essential concepts of Iced"
@@ -9,6 +9,8 @@ repository = "https://github.com/iced-rs/iced"
99

1010
[dependencies]
1111
bitflags = "1.2"
12+
thiserror = "1"
13+
twox-hash = { version = "1.5", default-features = false }
1214

1315
[dependencies.palette]
1416
version = "0.6"

core/src/alignment.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ pub enum Alignment {
1111

1212
/// Align at the end of the axis.
1313
End,
14-
15-
/// Fill the entire axis.
16-
Fill,
1714
}
1815

1916
impl From<Horizontal> for Alignment {

core/src/clipboard.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! Access the clipboard.
2+
3+
/// A buffer for short-term storage and transfer within and between
4+
/// applications.
5+
pub trait Clipboard {
6+
/// Reads the current content of the [`Clipboard`] as text.
7+
fn read(&self) -> Option<String>;
8+
9+
/// Writes the given text contents to the [`Clipboard`].
10+
fn write(&mut self, contents: String);
11+
}
12+
13+
/// A null implementation of the [`Clipboard`] trait.
14+
#[derive(Debug, Clone, Copy)]
15+
pub struct Null;
16+
17+
impl Clipboard for Null {
18+
fn read(&self) -> Option<String> {
19+
None
20+
}
21+
22+
fn write(&mut self, _contents: String) {}
23+
}

native/src/element.rs renamed to core/src/element.rs

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -90,41 +90,65 @@ impl<'a, Message, Renderer> Element<'a, Message, Renderer> {
9090
/// We compose the previous __messages__ with the index of the counter
9191
/// producing them. Let's implement our __view logic__ now:
9292
///
93-
/// ```
93+
/// ```no_run
9494
/// # mod counter {
95-
/// # type Text<'a> = iced_native::widget::Text<'a, iced_native::renderer::Null>;
96-
/// #
9795
/// # #[derive(Debug, Clone, Copy)]
9896
/// # pub enum Message {}
9997
/// # pub struct Counter;
10098
/// #
10199
/// # impl Counter {
102-
/// # pub fn view(&mut self) -> Text {
103-
/// # Text::new("")
100+
/// # pub fn view(
101+
/// # &self,
102+
/// # ) -> iced_core::Element<Message, iced_core::renderer::Null> {
103+
/// # unimplemented!()
104104
/// # }
105105
/// # }
106106
/// # }
107107
/// #
108-
/// # mod iced_wgpu {
109-
/// # pub use iced_native::renderer::Null as Renderer;
110-
/// # }
108+
/// # mod iced {
109+
/// # pub use iced_core::renderer::Null as Renderer;
110+
/// # pub use iced_core::Element;
111111
/// #
112-
/// # use counter::Counter;
112+
/// # pub mod widget {
113+
/// # pub struct Row<Message> {
114+
/// # _t: std::marker::PhantomData<Message>,
115+
/// # }
113116
/// #
114-
/// # struct ManyCounters {
115-
/// # counters: Vec<Counter>,
116-
/// # }
117+
/// # impl<Message> Row<Message> {
118+
/// # pub fn new() -> Self {
119+
/// # unimplemented!()
120+
/// # }
117121
/// #
118-
/// # #[derive(Debug, Clone, Copy)]
119-
/// # pub enum Message {
120-
/// # Counter(usize, counter::Message)
122+
/// # pub fn spacing(mut self, _: u32) -> Self {
123+
/// # unimplemented!()
124+
/// # }
125+
/// #
126+
/// # pub fn push(
127+
/// # mut self,
128+
/// # _: iced_core::Element<Message, iced_core::renderer::Null>,
129+
/// # ) -> Self {
130+
/// # unimplemented!()
131+
/// # }
132+
/// # }
133+
/// # }
121134
/// # }
122-
/// use iced_native::Element;
123-
/// use iced_native::widget::Row;
124-
/// use iced_wgpu::Renderer;
135+
/// #
136+
/// use counter::Counter;
137+
///
138+
/// use iced::widget::Row;
139+
/// use iced::{Element, Renderer};
140+
///
141+
/// struct ManyCounters {
142+
/// counters: Vec<Counter>,
143+
/// }
144+
///
145+
/// #[derive(Debug, Clone, Copy)]
146+
/// pub enum Message {
147+
/// Counter(usize, counter::Message),
148+
/// }
125149
///
126150
/// impl ManyCounters {
127-
/// pub fn view(&mut self) -> Row<Message, Renderer> {
151+
/// pub fn view(&mut self) -> Row<Message> {
128152
/// // We can quickly populate a `Row` by folding over our counters
129153
/// self.counters.iter_mut().enumerate().fold(
130154
/// Row::new().spacing(20),
@@ -137,9 +161,10 @@ impl<'a, Message, Renderer> Element<'a, Message, Renderer> {
137161
/// // Here we turn our `Element<counter::Message>` into
138162
/// // an `Element<Message>` by combining the `index` and the
139163
/// // message of the `element`.
140-
/// element.map(move |message| Message::Counter(index, message))
164+
/// element
165+
/// .map(move |message| Message::Counter(index, message)),
141166
/// )
142-
/// }
167+
/// },
143168
/// )
144169
/// }
145170
/// }

native/src/event.rs renamed to core/src/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl Status {
6262
/// `Captured` takes precedence over `Ignored`:
6363
///
6464
/// ```
65-
/// use iced_native::event::Status;
65+
/// use iced_core::event::Status;
6666
///
6767
/// assert_eq!(Status::Ignored.merge(Status::Ignored), Status::Ignored);
6868
/// assert_eq!(Status::Ignored.merge(Status::Captured), Status::Captured);
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)