Apply Transformation to RawText primitives

This commit is contained in:
Héctor Ramón Jiménez 2024-02-02 14:43:04 +01:00
parent a06682ff42
commit b3adf31845
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 21 additions and 19 deletions

View file

@ -181,20 +181,13 @@ impl<'a> Layer<'a> {
clip_bounds: *clip_bounds * transformation, clip_bounds: *clip_bounds * transformation,
})); }));
} }
graphics::Primitive::RawText(graphics::text::Raw { graphics::Primitive::RawText(raw) => {
buffer,
position,
color,
clip_bounds,
}) => {
let layer = &mut layers[current_layer]; let layer = &mut layers[current_layer];
layer.text.push(Text::Raw(graphics::text::Raw { layer.text.push(Text::Raw {
buffer: buffer.clone(), raw: raw.clone(),
position: *position * transformation, transformation,
color: *color, });
clip_bounds: *clip_bounds * transformation,
}));
} }
Primitive::Quad { Primitive::Quad {
bounds, bounds,

View file

@ -29,7 +29,11 @@ pub enum Text<'a> {
/// Some cached text. /// Some cached text.
Cached(Cached<'a>), Cached(Cached<'a>),
/// Some raw text. /// Some raw text.
Raw(graphics::text::Raw), #[allow(missing_docs)]
Raw {
raw: graphics::text::Raw,
transformation: Transformation,
},
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View file

@ -109,7 +109,9 @@ impl Pipeline {
Some(Allocation::Cache(key)) Some(Allocation::Cache(key))
} }
Text::Raw(text) => text.buffer.upgrade().map(Allocation::Raw), Text::Raw { raw, .. } => {
raw.buffer.upgrade().map(Allocation::Raw)
}
}) })
.collect(); .collect();
@ -194,7 +196,10 @@ impl Pipeline {
Transformation::IDENTITY, Transformation::IDENTITY,
) )
} }
Text::Raw(text) => { Text::Raw {
raw,
transformation,
} => {
let Some(Allocation::Raw(buffer)) = allocation else { let Some(Allocation::Raw(buffer)) = allocation else {
return None; return None;
}; };
@ -204,14 +209,14 @@ impl Pipeline {
( (
buffer.as_ref(), buffer.as_ref(),
Rectangle::new( Rectangle::new(
text.position, raw.position,
Size::new(width, height), Size::new(width, height),
), ),
alignment::Horizontal::Left, alignment::Horizontal::Left,
alignment::Vertical::Top, alignment::Vertical::Top,
text.color, raw.color,
text.clip_bounds, raw.clip_bounds,
Transformation::IDENTITY, *transformation,
) )
} }
}; };