summaryrefslogtreecommitdiffstats
path: root/tiny_skia/src/backend.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-01-12 06:45:40 +0100
committerLibravatar GitHub <noreply@github.com>2024-01-12 06:45:40 +0100
commita5ae442819227b3cd55116028e6d6c96caa6fda9 (patch)
tree111e7b424a2c7044f8d98612015540282bf2ca8a /tiny_skia/src/backend.rs
parent89fc4f54bdbf62a29fcd06bc2e77926180143413 (diff)
parent603832e66c710ea39a95009ddc905de20c6856bd (diff)
downloadiced-a5ae442819227b3cd55116028e6d6c96caa6fda9.tar.gz
iced-a5ae442819227b3cd55116028e6d6c96caa6fda9.tar.bz2
iced-a5ae442819227b3cd55116028e6d6c96caa6fda9.zip
Merge pull request #2158 from iced-rs/feature/raw-text-primitive
Introduce `RawText` to `Primitive` in `iced_graphics`
Diffstat (limited to 'tiny_skia/src/backend.rs')
-rw-r--r--tiny_skia/src/backend.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs
index 3e9bd2a5..706db40e 100644
--- a/tiny_skia/src/backend.rs
+++ b/tiny_skia/src/backend.rs
@@ -1,5 +1,6 @@
use crate::core::{Background, Color, Gradient, Rectangle, Vector};
use crate::graphics::backend;
+use crate::graphics::text;
use crate::graphics::Viewport;
use crate::primitive::{self, Primitive};
@@ -444,6 +445,35 @@ impl Backend {
clip_mask,
);
}
+ Primitive::RawText(text::Raw {
+ buffer,
+ position,
+ color,
+ clip_bounds: text_clip_bounds,
+ }) => {
+ let Some(buffer) = buffer.upgrade() else {
+ return;
+ };
+
+ let physical_bounds =
+ (*text_clip_bounds + translation) * scale_factor;
+
+ if !clip_bounds.intersects(&physical_bounds) {
+ return;
+ }
+
+ let clip_mask = (!physical_bounds.is_within(&clip_bounds))
+ .then_some(clip_mask as &_);
+
+ self.text_pipeline.draw_raw(
+ &buffer,
+ *position + translation,
+ *color,
+ scale_factor,
+ pixels,
+ clip_mask,
+ );
+ }
#[cfg(feature = "image")]
Primitive::Image {
handle,