Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions tiny_skia/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ impl Layer {
clip_bounds: Rectangle,
transformation: Transformation,
) {
self.text
.push(Item::Group(text, clip_bounds, transformation));
self.text.push(Item::Group(
text,
clip_bounds * transformation,
transformation,
));
}

pub fn draw_text_cache(
Expand All @@ -119,8 +122,11 @@ impl Layer {
clip_bounds: Rectangle,
transformation: Transformation,
) {
self.text
.push(Item::Cached(text, clip_bounds, transformation));
self.text.push(Item::Cached(
text,
clip_bounds * transformation,
transformation,
));
}

pub fn draw_image(&mut self, image: Image, transformation: Transformation) {
Expand Down
12 changes: 11 additions & 1 deletion tiny_skia/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,25 @@ impl Renderer {
let render_span = debug::render(debug::Primitive::Image);

for group in &layer.text {
let Some(group_bounds) =
(group.clip_bounds() * scale_factor).intersection(&layer_bounds)
else {
continue;
};

engine::adjust_clip_mask(clip_mask, group_bounds);

for text in group.as_slice() {
self.engine.draw_text(
text,
Transformation::scale(scale_factor) * group.transformation(),
pixels,
clip_mask,
layer_bounds,
group_bounds,
);
}

engine::adjust_clip_mask(clip_mask, layer_bounds);
}

render_span.finish();
Expand Down