Move core::Image::clip_bounds to graphics::Image
This commit is contained in:
parent
3cc5bd5dbc
commit
7c11ccb046
16 changed files with 189 additions and 88 deletions
|
|
@ -431,8 +431,14 @@ impl geometry::frame::Backend for Frame {
|
|||
self.transforms.current.transform_rectangle(bounds);
|
||||
|
||||
image.rotation += external_rotation;
|
||||
image.border_radius =
|
||||
image.border_radius * self.transforms.current.scale().0;
|
||||
|
||||
self.images.push(Image::Raster(image, bounds));
|
||||
self.images.push(Image::Raster {
|
||||
image,
|
||||
bounds,
|
||||
clip_bounds: self.clip_bounds,
|
||||
});
|
||||
}
|
||||
|
||||
fn draw_svg(&mut self, bounds: Rectangle, svg: impl Into<Svg>) {
|
||||
|
|
@ -443,7 +449,11 @@ impl geometry::frame::Backend for Frame {
|
|||
|
||||
svg.rotation += external_rotation;
|
||||
|
||||
self.images.push(Image::Vector(svg, bounds));
|
||||
self.images.push(Image::Vector {
|
||||
svg,
|
||||
bounds,
|
||||
clip_bounds: self.clip_bounds,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -261,7 +261,11 @@ impl State {
|
|||
for image in images {
|
||||
match &image {
|
||||
#[cfg(feature = "image")]
|
||||
Image::Raster(image, bounds) => {
|
||||
Image::Raster {
|
||||
image,
|
||||
bounds,
|
||||
clip_bounds,
|
||||
} => {
|
||||
if let Some((atlas_entry, bind_group)) = cache
|
||||
.upload_raster(device, encoder, belt, &image.handle)
|
||||
{
|
||||
|
|
@ -283,7 +287,7 @@ impl State {
|
|||
|
||||
add_instances(
|
||||
*bounds,
|
||||
image.clip_bounds,
|
||||
*clip_bounds,
|
||||
image.border_radius,
|
||||
f32::from(image.rotation),
|
||||
image.opacity,
|
||||
|
|
@ -304,7 +308,11 @@ impl State {
|
|||
Image::Raster { .. } => continue,
|
||||
|
||||
#[cfg(feature = "svg")]
|
||||
Image::Vector(svg, bounds) => {
|
||||
Image::Vector {
|
||||
svg,
|
||||
bounds,
|
||||
clip_bounds,
|
||||
} => {
|
||||
if let Some((atlas_entry, bind_group)) = cache
|
||||
.upload_vector(
|
||||
device,
|
||||
|
|
@ -334,7 +342,7 @@ impl State {
|
|||
|
||||
add_instances(
|
||||
*bounds,
|
||||
Rectangle::INFINITE,
|
||||
*clip_bounds,
|
||||
border::radius(0),
|
||||
f32::from(svg.rotation),
|
||||
svg.opacity,
|
||||
|
|
|
|||
|
|
@ -128,11 +128,19 @@ impl Layer {
|
|||
|
||||
pub fn draw_image(&mut self, image: Image, transformation: Transformation) {
|
||||
match image {
|
||||
Image::Raster(image, bounds) => {
|
||||
self.draw_raster(image, bounds, transformation);
|
||||
Image::Raster {
|
||||
image,
|
||||
bounds,
|
||||
clip_bounds,
|
||||
} => {
|
||||
self.draw_raster(image, bounds, clip_bounds, transformation);
|
||||
}
|
||||
Image::Vector(svg, bounds) => {
|
||||
self.draw_svg(svg, bounds, transformation);
|
||||
Image::Vector {
|
||||
svg,
|
||||
bounds,
|
||||
clip_bounds,
|
||||
} => {
|
||||
self.draw_svg(svg, bounds, clip_bounds, transformation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -141,17 +149,18 @@ impl Layer {
|
|||
&mut self,
|
||||
image: core::Image,
|
||||
bounds: Rectangle,
|
||||
clip_bounds: Rectangle,
|
||||
transformation: Transformation,
|
||||
) {
|
||||
let image = Image::Raster(
|
||||
core::Image {
|
||||
clip_bounds: image.clip_bounds * transformation,
|
||||
let image = Image::Raster {
|
||||
image: core::Image {
|
||||
border_radius: image.border_radius
|
||||
* transformation.scale_factor(),
|
||||
..image
|
||||
},
|
||||
bounds * transformation,
|
||||
);
|
||||
bounds: bounds * transformation,
|
||||
clip_bounds: clip_bounds * transformation,
|
||||
};
|
||||
|
||||
self.images.push(image);
|
||||
}
|
||||
|
|
@ -160,9 +169,14 @@ impl Layer {
|
|||
&mut self,
|
||||
svg: Svg,
|
||||
bounds: Rectangle,
|
||||
clip_bounds: Rectangle,
|
||||
transformation: Transformation,
|
||||
) {
|
||||
let svg = Image::Vector(svg, bounds * transformation);
|
||||
let svg = Image::Vector {
|
||||
svg,
|
||||
bounds: bounds * transformation,
|
||||
clip_bounds: clip_bounds * transformation,
|
||||
};
|
||||
|
||||
self.images.push(svg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -777,9 +777,14 @@ impl core::image::Renderer for Renderer {
|
|||
self.image_cache.borrow_mut().measure_image(handle)
|
||||
}
|
||||
|
||||
fn draw_image(&mut self, image: core::Image, bounds: Rectangle) {
|
||||
fn draw_image(
|
||||
&mut self,
|
||||
image: core::Image,
|
||||
bounds: Rectangle,
|
||||
clip_bounds: Rectangle,
|
||||
) {
|
||||
let (layer, transformation) = self.layers.current_mut();
|
||||
layer.draw_raster(image, bounds, transformation);
|
||||
layer.draw_raster(image, bounds, clip_bounds, transformation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -789,9 +794,14 @@ impl core::svg::Renderer for Renderer {
|
|||
self.image_cache.borrow_mut().measure_svg(handle)
|
||||
}
|
||||
|
||||
fn draw_svg(&mut self, svg: core::Svg, bounds: Rectangle) {
|
||||
fn draw_svg(
|
||||
&mut self,
|
||||
svg: core::Svg,
|
||||
bounds: Rectangle,
|
||||
clip_bounds: Rectangle,
|
||||
) {
|
||||
let (layer, transformation) = self.layers.current_mut();
|
||||
layer.draw_svg(svg, bounds, transformation);
|
||||
layer.draw_svg(svg, bounds, clip_bounds, transformation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue