Some small debug changes

This commit is contained in:
Malte Veerman 2020-01-11 21:50:42 +01:00 committed by Héctor Ramón Jiménez
parent 743637ebda
commit 82e0675c07
2 changed files with 12 additions and 12 deletions

View File

@ -8,7 +8,10 @@ use debug_stub_derive::*;
#[derive(DebugStub)] #[derive(DebugStub)]
pub enum Memory { pub enum Memory {
Host(::image::ImageBuffer<::image::Bgra<u8>, Vec<u8>>), Host(::image::ImageBuffer<::image::Bgra<u8>, Vec<u8>>),
Device(#[debug_stub="ReplacementValue"]Allocation), Device(
#[debug_stub="ReplacementValue"]
Allocation
),
NotFound, NotFound,
Invalid, Invalid,
} }

View File

@ -1,20 +1,23 @@
use iced_native::svg; use iced_native::svg;
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
fmt,
}; };
use guillotiere::{Allocation, AtlasAllocator, Size}; use guillotiere::{Allocation, AtlasAllocator, Size};
use debug_stub_derive::*; use debug_stub_derive::*;
#[derive(DebugStub)]
pub enum Svg { pub enum Svg {
Loaded { tree: resvg::usvg::Tree }, Loaded(
#[debug_stub="ReplacementValue"]
resvg::usvg::Tree
),
NotFound, NotFound,
} }
impl Svg { impl Svg {
pub fn viewport_dimensions(&self) -> (u32, u32) { pub fn viewport_dimensions(&self) -> (u32, u32) {
match self { match self {
Svg::Loaded { tree } => { Svg::Loaded(tree) => {
let size = tree.svg_node().size; let size = tree.svg_node().size;
(size.width() as u32, size.height() as u32) (size.width() as u32, size.height() as u32)
@ -24,12 +27,6 @@ impl Svg {
} }
} }
impl fmt::Debug for Svg {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Svg")
}
}
#[derive(DebugStub)] #[derive(DebugStub)]
pub struct Cache { pub struct Cache {
svgs: HashMap<u64, Svg>, svgs: HashMap<u64, Svg>,
@ -57,7 +54,7 @@ impl Cache {
let opt = resvg::Options::default(); let opt = resvg::Options::default();
let svg = match resvg::usvg::Tree::from_file(handle.path(), &opt.usvg) { let svg = match resvg::usvg::Tree::from_file(handle.path(), &opt.usvg) {
Ok(tree) => Svg::Loaded { tree }, Ok(tree) => Svg::Loaded(tree),
Err(_) => Svg::NotFound, Err(_) => Svg::NotFound,
}; };
@ -96,7 +93,7 @@ impl Cache {
let _ = self.load(handle); let _ = self.load(handle);
match self.svgs.get(&handle.id()).unwrap() { match self.svgs.get(&handle.id()).unwrap() {
Svg::Loaded { tree } => { Svg::Loaded(tree) => {
if width == 0 || height == 0 { if width == 0 || height == 0 {
return None; return None;
} }