Introduce with_transformation to Renderer trait
This commit is contained in:
parent
a6e91d13d5
commit
f4d6648601
31 changed files with 161 additions and 118 deletions
|
|
@ -2,9 +2,8 @@ mod cache;
|
|||
|
||||
pub use cache::Cache;
|
||||
|
||||
use crate::core::{Point, Rectangle, Size, Vector};
|
||||
use crate::core::{Point, Rectangle, Size, Transformation, Vector};
|
||||
use crate::graphics::geometry::{Fill, Path, Stroke, Text};
|
||||
use crate::graphics::Transformation;
|
||||
use crate::Renderer;
|
||||
|
||||
macro_rules! delegate {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ pub use geometry::Geometry;
|
|||
|
||||
use crate::core::renderer;
|
||||
use crate::core::text::{self, Text};
|
||||
use crate::core::{Background, Color, Font, Pixels, Point, Rectangle, Vector};
|
||||
use crate::core::{
|
||||
Background, Color, Font, Pixels, Point, Rectangle, Transformation,
|
||||
};
|
||||
use crate::graphics::text::Editor;
|
||||
use crate::graphics::text::Paragraph;
|
||||
use crate::graphics::Mesh;
|
||||
|
|
@ -97,20 +99,20 @@ impl core::Renderer for Renderer {
|
|||
}
|
||||
}
|
||||
|
||||
fn with_translation(
|
||||
fn with_transformation(
|
||||
&mut self,
|
||||
translation: Vector,
|
||||
transformation: Transformation,
|
||||
f: impl FnOnce(&mut Self),
|
||||
) {
|
||||
match self {
|
||||
Self::TinySkia(renderer) => {
|
||||
let primitives = renderer.start_translation();
|
||||
let primitives = renderer.start_transformation();
|
||||
|
||||
f(self);
|
||||
|
||||
match self {
|
||||
Self::TinySkia(renderer) => {
|
||||
renderer.end_translation(primitives, translation);
|
||||
renderer.end_transformation(primitives, transformation);
|
||||
}
|
||||
#[cfg(feature = "wgpu")]
|
||||
_ => unreachable!(),
|
||||
|
|
@ -118,14 +120,14 @@ impl core::Renderer for Renderer {
|
|||
}
|
||||
#[cfg(feature = "wgpu")]
|
||||
Self::Wgpu(renderer) => {
|
||||
let primitives = renderer.start_translation();
|
||||
let primitives = renderer.start_transformation();
|
||||
|
||||
f(self);
|
||||
|
||||
match self {
|
||||
#[cfg(feature = "wgpu")]
|
||||
Self::Wgpu(renderer) => {
|
||||
renderer.end_translation(primitives, translation);
|
||||
renderer.end_transformation(primitives, transformation);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue