Skip to content

Commit

Permalink
Updated shaders and removed debug_stub_derive dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Maldela committed Jan 17, 2020
1 parent 8ea5b7f commit b9e14c1
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 19 deletions.
1 change: 0 additions & 1 deletion wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ font-kit = "0.4"
log = "0.4"
resvg = { version = "0.8", features = ["raqote-backend"], optional = true }
guillotiere = "0.4"
debug_stub_derive = "0.3"
32 changes: 24 additions & 8 deletions wgpu/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use iced_native::{image, svg, Rectangle};
use std::{cell::RefCell, mem};

use guillotiere::{Allocation, AtlasAllocator, Size};
use debug_stub_derive::*;

#[derive(Debug)]
pub struct Pipeline {
Expand Down Expand Up @@ -461,11 +460,9 @@ impl ImageAllocation {
}
}

#[derive(DebugStub)]
pub enum ArrayAllocation {
AtlasAllocation {
layer: usize,
#[debug_stub = "Allocation"]
allocation: Allocation,
},
WholeLayer {
Expand Down Expand Up @@ -502,16 +499,35 @@ impl ArrayAllocation {
}
}

#[derive(DebugStub)]
impl std::fmt::Debug for ArrayAllocation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ArrayAllocation::AtlasAllocation { layer, .. } => {
write!(f, "ArrayAllocation::AtlasAllocation {{ layer: {} }}", layer)
},
ArrayAllocation::WholeLayer { layer } => {
write!(f, "ArrayAllocation::WholeLayer {{ layer: {} }}", layer)
}
}
}
}

pub enum TextureLayer {
Whole,
Atlas(
#[debug_stub="AtlasAllocator"]
AtlasAllocator
),
Atlas(AtlasAllocator),
Empty,
}

impl std::fmt::Debug for TextureLayer {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TextureLayer::Whole => write!(f, "TextureLayer::Whole"),
TextureLayer::Atlas(_) => write!(f, "TextureLayer::Atlas"),
TextureLayer::Empty => write!(f, "TextureLayer::Empty"),
}
}
}

#[derive(Debug)]
pub struct TextureArray {
texture: wgpu::Texture,
Expand Down
13 changes: 11 additions & 2 deletions wgpu/src/image/raster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use iced_native::image;
use std::{
collections::{HashMap, HashSet},
};
use debug_stub_derive::*;

#[derive(DebugStub)]
pub enum Memory {
Host(::image::ImageBuffer<::image::Bgra<u8>, Vec<u8>>),
Device(ImageAllocation),
Expand All @@ -24,6 +22,17 @@ impl Memory {
}
}

impl std::fmt::Debug for Memory {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Memory::Host(_) => write!(f, "Memory::Host"),
Memory::Device(_) => write!(f, "Memory::Device"),
Memory::NotFound => write!(f, "Memory::NotFound"),
Memory::Invalid => write!(f, "Memory::Invalid"),
}
}
}

#[derive(Debug)]
pub struct Cache {
map: HashMap<u64, Memory>,
Expand Down
24 changes: 16 additions & 8 deletions wgpu/src/image/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ use iced_native::svg;
use std::{
collections::{HashMap, HashSet},
};
use debug_stub_derive::*;

#[derive(DebugStub)]
pub enum Svg {
Loaded(
#[debug_stub="ReplacementValue"]
resvg::usvg::Tree
),
Loaded(resvg::usvg::Tree),
NotFound,
}

Expand All @@ -27,10 +22,17 @@ impl Svg {
}
}

#[derive(DebugStub)]
impl std::fmt::Debug for Svg {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Svg::Loaded(_) => write!(f, "Svg::Loaded"),
Svg::NotFound => write!(f, "Svg::NotFound"),
}
}
}

pub struct Cache {
svgs: HashMap<u64, Svg>,
#[debug_stub="ReplacementValue"]
rasterized: HashMap<(u64, u32, u32), ImageAllocation>,
svg_hits: HashSet<u64>,
rasterized_hits: HashSet<(u64, u32, u32)>,
Expand Down Expand Up @@ -144,3 +146,9 @@ impl Cache {
self.rasterized_hits.clear();
}
}

impl std::fmt::Debug for Cache {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "vector::Cache")
}
}
Binary file modified wgpu/src/shader/image.frag.spv
Binary file not shown.
Binary file modified wgpu/src/shader/image.vert.spv
Binary file not shown.

0 comments on commit b9e14c1

Please sign in to comment.