Apply Transformation to RawText primitives
This commit is contained in:
parent
a06682ff42
commit
b3adf31845
3 changed files with 21 additions and 19 deletions
|
|
@ -181,20 +181,13 @@ impl<'a> Layer<'a> {
|
|||
clip_bounds: *clip_bounds * transformation,
|
||||
}));
|
||||
}
|
||||
graphics::Primitive::RawText(graphics::text::Raw {
|
||||
buffer,
|
||||
position,
|
||||
color,
|
||||
clip_bounds,
|
||||
}) => {
|
||||
graphics::Primitive::RawText(raw) => {
|
||||
let layer = &mut layers[current_layer];
|
||||
|
||||
layer.text.push(Text::Raw(graphics::text::Raw {
|
||||
buffer: buffer.clone(),
|
||||
position: *position * transformation,
|
||||
color: *color,
|
||||
clip_bounds: *clip_bounds * transformation,
|
||||
}));
|
||||
layer.text.push(Text::Raw {
|
||||
raw: raw.clone(),
|
||||
transformation,
|
||||
});
|
||||
}
|
||||
Primitive::Quad {
|
||||
bounds,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,11 @@ pub enum Text<'a> {
|
|||
/// Some cached text.
|
||||
Cached(Cached<'a>),
|
||||
/// Some raw text.
|
||||
Raw(graphics::text::Raw),
|
||||
#[allow(missing_docs)]
|
||||
Raw {
|
||||
raw: graphics::text::Raw,
|
||||
transformation: Transformation,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
|||
|
|
@ -109,7 +109,9 @@ impl Pipeline {
|
|||
|
||||
Some(Allocation::Cache(key))
|
||||
}
|
||||
Text::Raw(text) => text.buffer.upgrade().map(Allocation::Raw),
|
||||
Text::Raw { raw, .. } => {
|
||||
raw.buffer.upgrade().map(Allocation::Raw)
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
|
@ -194,7 +196,10 @@ impl Pipeline {
|
|||
Transformation::IDENTITY,
|
||||
)
|
||||
}
|
||||
Text::Raw(text) => {
|
||||
Text::Raw {
|
||||
raw,
|
||||
transformation,
|
||||
} => {
|
||||
let Some(Allocation::Raw(buffer)) = allocation else {
|
||||
return None;
|
||||
};
|
||||
|
|
@ -204,14 +209,14 @@ impl Pipeline {
|
|||
(
|
||||
buffer.as_ref(),
|
||||
Rectangle::new(
|
||||
text.position,
|
||||
raw.position,
|
||||
Size::new(width, height),
|
||||
),
|
||||
alignment::Horizontal::Left,
|
||||
alignment::Vertical::Top,
|
||||
text.color,
|
||||
text.clip_bounds,
|
||||
Transformation::IDENTITY,
|
||||
raw.color,
|
||||
raw.clip_bounds,
|
||||
*transformation,
|
||||
)
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue