summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-06-29 18:23:11 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-06-29 18:23:11 +0200
commitd666e739cdcc2084c14593888867d40066c232fe (patch)
tree68701bfd0d06f022887a0125a9c791572dce7e67 /graphics
parentcdce03cf7f520ef0227aaec4eaed19332197f53b (diff)
downloadiced-d666e739cdcc2084c14593888867d40066c232fe.tar.gz
iced-d666e739cdcc2084c14593888867d40066c232fe.tar.bz2
iced-d666e739cdcc2084c14593888867d40066c232fe.zip
Trim text measurements only before `layout`
Diffstat (limited to '')
-rw-r--r--graphics/src/backend.rs7
-rw-r--r--graphics/src/renderer.rs2
2 files changed, 9 insertions, 0 deletions
diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs
index 77bb650b..59e95bf8 100644
--- a/graphics/src/backend.rs
+++ b/graphics/src/backend.rs
@@ -12,6 +12,13 @@ use std::borrow::Cow;
pub trait Backend {
/// The custom kind of primitives this [`Backend`] supports.
type Primitive;
+
+ /// Trims the measurements cache.
+ ///
+ /// This method is currently necessary to properly trim the text cache in
+ /// `iced_wgpu` and `iced_glow` because of limitations in the text rendering
+ /// pipeline. It will be removed in the future.
+ fn trim_measurements(&mut self) {}
}
/// A graphics backend that supports text rendering.
diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs
index 476aa407..c0cec60a 100644
--- a/graphics/src/renderer.rs
+++ b/graphics/src/renderer.rs
@@ -93,6 +93,8 @@ impl<B: Backend, T> iced_core::Renderer for Renderer<B, T> {
element: &Element<'_, Message, Self>,
limits: &layout::Limits,
) -> layout::Node {
+ self.backend.trim_measurements();
+
element.as_widget().layout(self, limits)
}