summaryrefslogtreecommitdiffstats
path: root/wgpu/src/layer
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--wgpu/src/layer.rs (renamed from graphics/src/layer.rs)96
-rw-r--r--wgpu/src/layer/image.rs (renamed from graphics/src/layer/image.rs)6
-rw-r--r--wgpu/src/layer/mesh.rs (renamed from graphics/src/layer/mesh.rs)8
-rw-r--r--wgpu/src/layer/quad.rs (renamed from graphics/src/layer/quad.rs)0
-rw-r--r--wgpu/src/layer/text.rs (renamed from graphics/src/layer/text.rs)14
5 files changed, 72 insertions, 52 deletions
diff --git a/graphics/src/layer.rs b/wgpu/src/layer.rs
index 1d453caa..8af72b9d 100644
--- a/graphics/src/layer.rs
+++ b/wgpu/src/layer.rs
@@ -10,10 +10,10 @@ pub use mesh::Mesh;
pub use quad::Quad;
pub use text::Text;
-use crate::alignment;
-use crate::{
- Background, Font, Point, Primitive, Rectangle, Size, Vector, Viewport,
-};
+use crate::core;
+use crate::core::alignment;
+use crate::core::{Background, Color, Font, Point, Rectangle, Size, Vector};
+use crate::graphics::{Primitive, Viewport};
/// A group of primitives that should be clipped together.
#[derive(Debug)]
@@ -60,18 +60,20 @@ impl<'a> Layer<'a> {
Point::new(11.0, 11.0 + 25.0 * i as f32),
Size::INFINITY,
),
- color: [0.9, 0.9, 0.9, 1.0],
+ color: Color::new(0.9, 0.9, 0.9, 1.0),
size: 20.0,
- font: Font::Default,
+ line_height: core::text::LineHeight::default(),
+ font: Font::MONOSPACE,
horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Top,
+ shaping: core::text::Shaping::Basic,
};
overlay.text.push(text);
overlay.text.push(Text {
bounds: text.bounds + Vector::new(-1.0, -1.0),
- color: [0.0, 0.0, 0.0, 1.0],
+ color: Color::BLACK,
..text
});
}
@@ -109,26 +111,16 @@ impl<'a> Layer<'a> {
current_layer: usize,
) {
match primitive {
- Primitive::None => {}
- Primitive::Group { primitives } => {
- // TODO: Inspect a bit and regroup (?)
- for primitive in primitives {
- Self::process_primitive(
- layers,
- translation,
- primitive,
- current_layer,
- )
- }
- }
Primitive::Text {
content,
bounds,
size,
+ line_height,
color,
font,
horizontal_alignment,
vertical_alignment,
+ shaping,
} => {
let layer = &mut layers[current_layer];
@@ -136,10 +128,12 @@ impl<'a> Layer<'a> {
content,
bounds: *bounds + translation,
size: *size,
- color: color.into_linear(),
+ line_height: *line_height,
+ color: *color,
font: *font,
horizontal_alignment: *horizontal_alignment,
vertical_alignment: *vertical_alignment,
+ shaping: *shaping,
});
}
Primitive::Quad {
@@ -166,6 +160,27 @@ impl<'a> Layer<'a> {
border_color: border_color.into_linear(),
});
}
+ Primitive::Image { handle, bounds } => {
+ let layer = &mut layers[current_layer];
+
+ layer.images.push(Image::Raster {
+ handle: handle.clone(),
+ bounds: *bounds + translation,
+ });
+ }
+ Primitive::Svg {
+ handle,
+ color,
+ bounds,
+ } => {
+ let layer = &mut layers[current_layer];
+
+ layer.images.push(Image::Vector {
+ handle: handle.clone(),
+ color: *color,
+ bounds: *bounds + translation,
+ });
+ }
Primitive::SolidMesh { buffers, size } => {
let layer = &mut layers[current_layer];
@@ -205,6 +220,17 @@ impl<'a> Layer<'a> {
});
}
}
+ Primitive::Group { primitives } => {
+ // TODO: Inspect a bit and regroup (?)
+ for primitive in primitives {
+ Self::process_primitive(
+ layers,
+ translation,
+ primitive,
+ current_layer,
+ )
+ }
+ }
Primitive::Clip { bounds, content } => {
let layer = &mut layers[current_layer];
let translated_bounds = *bounds + translation;
@@ -235,34 +261,20 @@ impl<'a> Layer<'a> {
current_layer,
);
}
- Primitive::Cached { cache } => {
+ Primitive::Cache { content } => {
Self::process_primitive(
layers,
translation,
- cache,
+ content,
current_layer,
);
}
- Primitive::Image { handle, bounds } => {
- let layer = &mut layers[current_layer];
-
- layer.images.push(Image::Raster {
- handle: handle.clone(),
- bounds: *bounds + translation,
- });
- }
- Primitive::Svg {
- handle,
- color,
- bounds,
- } => {
- let layer = &mut layers[current_layer];
-
- layer.images.push(Image::Vector {
- handle: handle.clone(),
- color: *color,
- bounds: *bounds + translation,
- });
+ _ => {
+ // Not supported!
+ log::warn!(
+ "Unsupported primitive in `iced_wgpu`: {:?}",
+ primitive
+ );
}
}
}
diff --git a/graphics/src/layer/image.rs b/wgpu/src/layer/image.rs
index 3eff2397..0de589f8 100644
--- a/graphics/src/layer/image.rs
+++ b/wgpu/src/layer/image.rs
@@ -1,6 +1,6 @@
-use crate::{Color, Rectangle};
-
-use iced_native::{image, svg};
+use crate::core::image;
+use crate::core::svg;
+use crate::core::{Color, Rectangle};
/// A raster or vector image.
#[derive(Debug, Clone)]
diff --git a/graphics/src/layer/mesh.rs b/wgpu/src/layer/mesh.rs
index 7661c5c9..9dd14391 100644
--- a/graphics/src/layer/mesh.rs
+++ b/wgpu/src/layer/mesh.rs
@@ -1,6 +1,6 @@
//! A collection of triangle primitives.
-use crate::triangle;
-use crate::{Gradient, Point, Rectangle};
+use crate::core::{Gradient, Point, Rectangle};
+use crate::graphics::primitive;
/// A mesh of triangles.
#[derive(Debug, Clone, Copy)]
@@ -11,7 +11,7 @@ pub enum Mesh<'a> {
origin: Point,
/// The vertex and index buffers of the [`Mesh`].
- buffers: &'a triangle::Mesh2D<triangle::ColoredVertex2D>,
+ buffers: &'a primitive::Mesh2D<primitive::ColoredVertex2D>,
/// The clipping bounds of the [`Mesh`].
clip_bounds: Rectangle<f32>,
@@ -22,7 +22,7 @@ pub enum Mesh<'a> {
origin: Point,
/// The vertex and index buffers of the [`Mesh`].
- buffers: &'a triangle::Mesh2D<triangle::Vertex2D>,
+ buffers: &'a primitive::Mesh2D<primitive::Vertex2D>,
/// The clipping bounds of the [`Mesh`].
clip_bounds: Rectangle<f32>,
diff --git a/graphics/src/layer/quad.rs b/wgpu/src/layer/quad.rs
index 0d8bde9d..0d8bde9d 100644
--- a/graphics/src/layer/quad.rs
+++ b/wgpu/src/layer/quad.rs
diff --git a/graphics/src/layer/text.rs b/wgpu/src/layer/text.rs
index 74f7a676..ba1bdca8 100644
--- a/graphics/src/layer/text.rs
+++ b/wgpu/src/layer/text.rs
@@ -1,4 +1,6 @@
-use crate::{alignment, Font, Rectangle};
+use crate::core::alignment;
+use crate::core::text;
+use crate::core::{Color, Font, Rectangle};
/// A paragraph of text.
#[derive(Debug, Clone, Copy)]
@@ -10,11 +12,14 @@ pub struct Text<'a> {
pub bounds: Rectangle,
/// The color of the [`Text`], in __linear RGB_.
- pub color: [f32; 4],
+ pub color: Color,
- /// The size of the [`Text`].
+ /// The size of the [`Text`] in logical pixels.
pub size: f32,
+ /// The line height of the [`Text`].
+ pub line_height: text::LineHeight,
+
/// The font of the [`Text`].
pub font: Font,
@@ -23,4 +28,7 @@ pub struct Text<'a> {
/// The vertical alignment of the [`Text`].
pub vertical_alignment: alignment::Vertical,
+
+ /// The shaping strategy of the text.
+ pub shaping: text::Shaping,
}