Introduce with_transformation to Renderer trait

This commit is contained in:
Héctor Ramón Jiménez 2023-10-24 05:34:03 +02:00
parent a6e91d13d5
commit f4d6648601
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
31 changed files with 161 additions and 118 deletions

View file

@ -1,7 +1,7 @@
use crate::core::{Color, Size};
use crate::core::{Color, Size, Transformation};
use crate::graphics::backend;
use crate::graphics::color;
use crate::graphics::{Transformation, Viewport};
use crate::graphics::Viewport;
use crate::primitive::pipeline;
use crate::primitive::{self, Primitive};
use crate::quad;

View file

@ -1,6 +1,6 @@
//! Build and draw geometry.
use crate::core::text::LineHeight;
use crate::core::{Pixels, Point, Rectangle, Size, Vector};
use crate::core::{Pixels, Point, Rectangle, Size, Transformation, Vector};
use crate::graphics::color;
use crate::graphics::geometry::fill::{self, Fill};
use crate::graphics::geometry::{
@ -8,7 +8,6 @@ use crate::graphics::geometry::{
};
use crate::graphics::gradient::{self, Gradient};
use crate::graphics::mesh::{self, Mesh};
use crate::graphics::Transformation;
use crate::primitive::{self, Primitive};
use lyon::geom::euclid;

View file

@ -8,8 +8,7 @@ mod vector;
use atlas::Atlas;
use crate::core::{Rectangle, Size};
use crate::graphics::Transformation;
use crate::core::{Rectangle, Size, Transformation};
use crate::layer;
use crate::Buffer;

View file

@ -12,10 +12,12 @@ pub use text::Text;
use crate::core;
use crate::core::alignment;
use crate::core::{Color, Font, Pixels, Point, Rectangle, Size, Vector};
use crate::core::{
Color, Font, Pixels, Point, Rectangle, Size, Transformation, Vector,
};
use crate::graphics;
use crate::graphics::color;
use crate::graphics::{Transformation, Viewport};
use crate::graphics::Viewport;
use crate::primitive::{self, Primitive};
use crate::quad::{self, Quad};
@ -130,10 +132,10 @@ impl<'a> Layer<'a> {
layer.text.push(Text::Paragraph {
paragraph: paragraph.clone(),
position: *position * transformation,
position: *position,
color: *color,
clip_bounds: *clip_bounds * transformation,
scale: transformation.scale_factor(),
clip_bounds: *clip_bounds,
transformation,
});
}
Primitive::Editor {
@ -146,10 +148,10 @@ impl<'a> Layer<'a> {
layer.text.push(Text::Editor {
editor: editor.clone(),
position: *position * transformation,
position: *position,
color: *color,
clip_bounds: *clip_bounds * transformation,
scale: transformation.scale_factor(),
clip_bounds: *clip_bounds,
transformation,
});
}
Primitive::Text {
@ -168,7 +170,7 @@ impl<'a> Layer<'a> {
layer.text.push(Text::Cached(text::Cached {
content,
bounds: *bounds * transformation,
bounds: *bounds + transformation.translation(),
size: *size * transformation.scale_factor(),
line_height: *line_height,
color: *color,

View file

@ -1,7 +1,6 @@
//! A collection of triangle primitives.
use crate::core::Rectangle;
use crate::core::{Rectangle, Transformation};
use crate::graphics::mesh;
use crate::graphics::Transformation;
/// A mesh of triangles.
#[derive(Debug, Clone, Copy)]

View file

@ -1,6 +1,6 @@
use crate::core::alignment;
use crate::core::text;
use crate::core::{Color, Font, Pixels, Point, Rectangle};
use crate::core::{Color, Font, Pixels, Point, Rectangle, Transformation};
use crate::graphics;
use crate::graphics::text::editor;
use crate::graphics::text::paragraph;
@ -15,7 +15,7 @@ pub enum Text<'a> {
position: Point,
color: Color,
clip_bounds: Rectangle,
scale: f32,
transformation: Transformation,
},
/// An editor.
#[allow(missing_docs)]
@ -24,7 +24,7 @@ pub enum Text<'a> {
position: Point,
color: Color,
clip_bounds: Rectangle,
scale: f32,
transformation: Transformation,
},
/// Some cached text.
Cached(Cached<'a>),

View file

@ -4,9 +4,9 @@ mod solid;
use gradient::Gradient;
use solid::Solid;
use crate::core::{Background, Rectangle};
use crate::core::{Background, Rectangle, Transformation};
use crate::graphics;
use crate::graphics::color;
use crate::graphics::{self, Transformation};
use bytemuck::{Pod, Zeroable};

View file

@ -1,5 +1,5 @@
use crate::core::alignment;
use crate::core::{Rectangle, Size};
use crate::core::{Rectangle, Size, Transformation};
use crate::graphics::color;
use crate::graphics::text::cache::{self, Cache};
use crate::graphics::text::{font_system, to_color, Editor, Paragraph};
@ -124,13 +124,13 @@ impl Pipeline {
vertical_alignment,
color,
clip_bounds,
scale,
transformation,
) = match section {
Text::Paragraph {
position,
color,
clip_bounds,
scale,
transformation,
..
} => {
use crate::core::text::Paragraph as _;
@ -147,14 +147,14 @@ impl Pipeline {
paragraph.vertical_alignment(),
*color,
*clip_bounds,
*scale,
*transformation,
)
}
Text::Editor {
position,
color,
clip_bounds,
scale,
transformation,
..
} => {
use crate::core::text::Editor as _;
@ -171,7 +171,7 @@ impl Pipeline {
alignment::Vertical::Top,
*color,
*clip_bounds,
*scale,
*transformation,
)
}
Text::Cached(text) => {
@ -191,7 +191,7 @@ impl Pipeline {
text.vertical_alignment,
text.color,
text.clip_bounds,
1.0,
Transformation::IDENTITY,
)
}
Text::Raw(text) => {
@ -211,12 +211,12 @@ impl Pipeline {
alignment::Vertical::Top,
text.color,
text.clip_bounds,
1.0,
Transformation::IDENTITY,
)
}
};
let bounds = bounds * scale_factor;
let bounds = bounds * transformation * scale_factor;
let left = match horizontal_alignment {
alignment::Horizontal::Left => bounds.x,
@ -241,7 +241,7 @@ impl Pipeline {
buffer,
left,
top,
scale: scale * scale_factor,
scale: scale_factor * transformation.scale_factor(),
bounds: glyphon::TextBounds {
left: clip_bounds.x as i32,
top: clip_bounds.y as i32,

View file

@ -1,8 +1,8 @@
//! Draw meshes of triangles.
mod msaa;
use crate::core::Size;
use crate::graphics::{Antialiasing, Transformation};
use crate::core::{Size, Transformation};
use crate::graphics::Antialiasing;
use crate::layer::mesh::{self, Mesh};
use crate::Buffer;