summaryrefslogtreecommitdiffstats
path: root/graphics/src/geometry
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-22 01:53:48 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-22 01:53:48 +0100
commit85800c99ab285efd244c0addfdcf3c732a98de1d (patch)
tree7e8c785019ad0cf9729803c20a763976e605efff /graphics/src/geometry
parent53a183fe0d6aed460fbb8155ac9541757277aab3 (diff)
downloadiced-85800c99ab285efd244c0addfdcf3c732a98de1d.tar.gz
iced-85800c99ab285efd244c0addfdcf3c732a98de1d.tar.bz2
iced-85800c99ab285efd244c0addfdcf3c732a98de1d.zip
Fix broken links in documentation
Diffstat (limited to 'graphics/src/geometry')
-rw-r--r--graphics/src/geometry/cache.rs33
-rw-r--r--graphics/src/geometry/frame.rs11
2 files changed, 17 insertions, 27 deletions
diff --git a/graphics/src/geometry/cache.rs b/graphics/src/geometry/cache.rs
index 490e69e2..37d433c2 100644
--- a/graphics/src/geometry/cache.rs
+++ b/graphics/src/geometry/cache.rs
@@ -1,11 +1,10 @@
use crate::core::Size;
-use crate::geometry::{self, Frame, Geometry};
-use crate::Primitive;
+use crate::geometry::{self, Frame};
+use crate::Cached;
use std::cell::RefCell;
-use std::sync::Arc;
-/// A simple cache that stores generated [`Geometry`] to avoid recomputation.
+/// A simple cache that stores generated geometry to avoid recomputation.
///
/// A [`Cache`] will not redraw its geometry unless the dimensions of its layer
/// change or it is explicitly cleared.
@@ -32,16 +31,16 @@ where
*self.state.borrow_mut() = State::Empty;
}
- /// Draws [`Geometry`] using the provided closure and stores it in the
+ /// Draws geometry using the provided closure and stores it in the
/// [`Cache`].
///
/// The closure will only be called when
/// - the bounds have changed since the previous draw call.
/// - the [`Cache`] is empty or has been explicitly cleared.
///
- /// Otherwise, the previously stored [`Geometry`] will be returned. The
+ /// Otherwise, the previously stored geometry will be returned. The
/// [`Cache`] is not cleared in this case. In other words, it will keep
- /// returning the stored [`Geometry`] if needed.
+ /// returning the stored geometry if needed.
pub fn draw(
&self,
renderer: &Renderer,
@@ -56,7 +55,7 @@ where
} = self.state.borrow().deref()
{
if *cached_bounds == bounds {
- return Geometry::load(geometry);
+ return Cached::load(geometry);
}
}
@@ -64,7 +63,7 @@ where
draw_fn(&mut frame);
let geometry = frame.into_geometry().cache();
- let result = Geometry::load(&geometry);
+ let result = Cached::load(&geometry);
*self.state.borrow_mut() = State::Filled { bounds, geometry };
@@ -99,7 +98,7 @@ where
enum State<Geometry>
where
- Geometry: self::Geometry,
+ Geometry: Cached,
{
Empty,
Filled {
@@ -107,17 +106,3 @@ where
geometry: Geometry::Cache,
},
}
-
-impl<T> Geometry for Primitive<T> {
- type Cache = Arc<Self>;
-
- fn load(cache: &Arc<Self>) -> Self {
- Self::Cache {
- content: cache.clone(),
- }
- }
-
- fn cache(self) -> Arc<Self> {
- Arc::new(self)
- }
-}
diff --git a/graphics/src/geometry/frame.rs b/graphics/src/geometry/frame.rs
index e88c43b0..37e0df38 100644
--- a/graphics/src/geometry/frame.rs
+++ b/graphics/src/geometry/frame.rs
@@ -1,7 +1,10 @@
+//! Draw and generate geometry.
use crate::core::{Point, Radians, Rectangle, Size, Vector};
-use crate::geometry::{self, Geometry};
-use crate::geometry::{Fill, Path, Stroke, Text};
+use crate::geometry::{self, Fill, Path, Stroke, Text};
+use crate::Cached;
+/// The region of a surface that can be used to draw geometry.
+#[allow(missing_debug_implementations)]
pub struct Frame<Renderer>
where
Renderer: geometry::Renderer,
@@ -13,6 +16,7 @@ impl<Renderer> Frame<Renderer>
where
Renderer: geometry::Renderer,
{
+ /// Creates a new [`Frame`] with the given dimensions.
pub fn new(renderer: &Renderer, size: Size) -> Self {
Self {
raw: renderer.new_frame(size),
@@ -164,6 +168,7 @@ where
self.raw.scale_nonuniform(scale);
}
+ /// Turns the [`Frame`] into its underlying geometry.
pub fn into_geometry(self) -> Renderer::Geometry {
self.raw.into_geometry()
}
@@ -175,7 +180,7 @@ where
/// of each method.
#[allow(missing_docs)]
pub trait Backend: Sized {
- type Geometry: Geometry;
+ type Geometry: Cached;
fn width(&self) -> f32;
fn height(&self) -> f32;