use super::geometry::{PaintClip, PaintTranslation};
use super::paths::{RenderedPathClip, RenderedPathFillRule};
use super::shapes::RenderedRoundedRect;
#[derive(Debug, Clone, PartialEq)]
pub(crate) struct ResolvedBoxContentClip {
pub(crate) bounds: PaintClip,
pub(crate) contour: BoxContentContour,
}
impl ResolvedBoxContentClip {
pub(crate) fn translated(mut self, offset: PaintTranslation) -> Self {
self.bounds = self.bounds.translated(offset);
self.contour = self.contour.translated(offset);
self
}
pub(crate) fn path_clip(&self) -> Option<RenderedPathClip> {
match &self.contour {
BoxContentContour::Rect => Some(RenderedPathClip::new(
super::paths::paint_rect_path_commands(self.bounds.paint_rect()),
RenderedPathFillRule::NonZero,
Vec::new(),
)),
BoxContentContour::Rounded(rounded) => Some(RenderedPathClip::new(
crate::layout::shaped_rect_path_commands(
rounded.paint_rect(),
rounded.radii,
rounded.corner_shapes,
),
RenderedPathFillRule::NonZero,
Vec::new(),
)),
BoxContentContour::Path(path) => Some(path.clone()),
BoxContentContour::Empty => None,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub(crate) enum BoxContentContour {
Rect,
Rounded(RenderedRoundedRect),
Path(RenderedPathClip),
Empty,
}
impl BoxContentContour {
fn translated(self, offset: PaintTranslation) -> Self {
match self {
Self::Rect => Self::Rect,
Self::Rounded(rounded) => Self::Rounded(rounded.translated(offset)),
Self::Path(path) => Self::Path(path.translated(offset)),
Self::Empty => Self::Empty,
}
}
}
#[allow(dead_code)] #[derive(Debug, Clone, PartialEq)]
pub(crate) enum OverflowClipEffect {
Rect(PaintClip),
AxisSelective(super::geometry::AxisSelectivePaintClip),
Union(super::geometry::PaintClipUnion),
Contoured(ResolvedBoxContentClip),
}