♻️ Create an ImageStore type

This commit is contained in:
Belén Albeza 2024-12-10 15:41:50 +01:00
parent 967bc75a1c
commit 7b1934dcb6
4 changed files with 48 additions and 26 deletions

View file

@ -1,10 +1,8 @@
use skia_safe as skia;
use std::collections::HashMap;
use uuid::Uuid;
use super::{draw_image_in_container, Fill, Image, Kind, Shape};
use super::{draw_image_in_container, Fill, Kind, Shape};
use crate::math::Rect;
use crate::render::Renderable;
use crate::render::{ImageStore, Renderable};
impl Renderable for Shape {
fn blend_mode(&self) -> crate::render::BlendMode {
@ -15,11 +13,7 @@ impl Renderable for Shape {
self.opacity
}
fn render(
&self,
surface: &mut skia_safe::Surface,
images: &HashMap<Uuid, Image>,
) -> Result<(), String> {
fn render(&self, surface: &mut skia_safe::Surface, images: &ImageStore) -> Result<(), String> {
let mut transform = skia::Matrix::new_identity();
let (translate_x, translate_y) = self.translation();
let (scale_x, scale_y) = self.scale();
@ -59,7 +53,7 @@ impl Renderable for Shape {
fn render_fill(
surface: &mut skia::Surface,
images: &HashMap<Uuid, Image>,
images: &ImageStore,
fill: &Fill,
selrect: Rect,
kind: &Kind,