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)]
pub enum Memory {
Host(::image::ImageBuffer<::image::Bgra<u8>, Vec<u8>>),
Device(#[debug_stub="ReplacementValue"]Allocation),
Device(
#[debug_stub="ReplacementValue"]
Allocation
),
NotFound,
Invalid,
}

View File

@ -1,20 +1,23 @@
use iced_native::svg;
use std::{
collections::{HashMap, HashSet},
fmt,
};
use guillotiere::{Allocation, AtlasAllocator, Size};
use debug_stub_derive::*;
#[derive(DebugStub)]
pub enum Svg {
Loaded { tree: resvg::usvg::Tree },
Loaded(
#[debug_stub="ReplacementValue"]
resvg::usvg::Tree
),
NotFound,
}
impl Svg {
pub fn viewport_dimensions(&self) -> (u32, u32) {
match self {
Svg::Loaded { tree } => {
Svg::Loaded(tree) => {
let size = tree.svg_node().size;
(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)]
pub struct Cache {
svgs: HashMap<u64, Svg>,
@ -57,7 +54,7 @@ impl Cache {
let opt = resvg::Options::default();
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,
};
@ -96,7 +93,7 @@ impl Cache {
let _ = self.load(handle);
match self.svgs.get(&handle.id()).unwrap() {
Svg::Loaded { tree } => {
Svg::Loaded(tree) => {
if width == 0 || height == 0 {
return None;
}