From 8708101c892540ffc966cf7ee9d66ca5cd2e8ca6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 4 Aug 2024 04:33:30 +0200 Subject: Simplify types in `tiny_skia::layer` --- tiny_skia/src/layer.rs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'tiny_skia') diff --git a/tiny_skia/src/layer.rs b/tiny_skia/src/layer.rs index 33df0a86..5d3cb07b 100644 --- a/tiny_skia/src/layer.rs +++ b/tiny_skia/src/layer.rs @@ -1,12 +1,12 @@ use crate::core::renderer::Quad; use crate::core::svg; use crate::core::{ - Background, Color, Image, Point, Radians, Rectangle, Transformation, + self, Background, Color, Point, Radians, Rectangle, Transformation, }; -use crate::graphics; use crate::graphics::damage; use crate::graphics::layer; use crate::graphics::text::{Editor, Paragraph, Text}; +use crate::graphics::{self, Image}; use crate::Primitive; use std::rc::Rc; @@ -19,7 +19,7 @@ pub struct Layer { pub quads: Vec<(Quad, Background)>, pub primitives: Vec>, pub text: Vec>, - pub images: Vec, + pub images: Vec, } impl Layer { @@ -73,7 +73,7 @@ impl Layer { pub fn draw_text( &mut self, - text: crate::core::Text, + text: core::Text, position: Point, color: Color, clip_bounds: Rectangle, @@ -116,16 +116,12 @@ impl Layer { .push(Item::Cached(text, clip_bounds, transformation)); } - pub fn draw_image( - &mut self, - image: graphics::Image, - transformation: Transformation, - ) { + pub fn draw_image(&mut self, image: Image, transformation: Transformation) { match image { - graphics::Image::Raster(raster, bounds) => { + Image::Raster(raster, bounds) => { self.draw_raster(raster.clone(), bounds, transformation); } - graphics::Image::Vector { + Image::Vector { handle, color, bounds, @@ -146,11 +142,11 @@ impl Layer { pub fn draw_raster( &mut self, - image: Image, + image: core::Image, bounds: Rectangle, transformation: Transformation, ) { - let image = graphics::Image::Raster(image, bounds * transformation); + let image = Image::Raster(image, bounds * transformation); self.images.push(image); } @@ -164,7 +160,7 @@ impl Layer { rotation: Radians, opacity: f32, ) { - let svg = graphics::Image::Vector { + let svg = Image::Vector { handle, color, bounds: bounds * transformation, @@ -281,7 +277,7 @@ impl Layer { &previous.images, ¤t.images, |image| vec![image.bounds().expand(1.0)], - graphics::Image::eq, + Image::eq, ); damage.extend(text); @@ -313,7 +309,7 @@ impl graphics::Layer for Layer { fn flush(&mut self) {} - fn resize(&mut self, bounds: graphics::core::Rectangle) { + fn resize(&mut self, bounds: Rectangle) { self.bounds = bounds; } -- cgit