Skip to content

Commit

Permalink
Replace texture_store and store with storage
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Nov 5, 2022
1 parent 0a23f51 commit 7a24b4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions graphics/src/image/raster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::collections::{HashMap, HashSet};
pub enum Memory<T: Storage> {
/// Image data on host
Host(::image_rs::ImageBuffer<::image_rs::Rgba<u8>, Vec<u8>>),
/// Texture store entry
/// Storage entry
Device(T::Entry),
/// Image not found
NotFound,
Expand Down Expand Up @@ -106,14 +106,14 @@ impl<T: Storage> Cache<T> {
&mut self,
handle: &image::Handle,
state: &mut T::State<'_>,
store: &mut T,
storage: &mut T,
) -> Option<&T::Entry> {
let memory = self.load(handle);

if let Memory::Host(image) = memory {
let (width, height) = image.dimensions();

let entry = store.upload(width, height, image, state)?;
let entry = storage.upload(width, height, image, state)?;

*memory = Memory::Device(entry);
}
Expand All @@ -126,15 +126,15 @@ impl<T: Storage> Cache<T> {
}

/// Trim cache misses from cache
pub fn trim(&mut self, store: &mut T, state: &mut T::State<'_>) {
pub fn trim(&mut self, storage: &mut T, state: &mut T::State<'_>) {
let hits = &self.hits;

self.map.retain(|k, memory| {
let retain = hits.contains(k);

if !retain {
if let Memory::Device(entry) = memory {
store.remove(entry, state);
storage.remove(entry, state);
}
}

Expand Down
8 changes: 4 additions & 4 deletions graphics/src/image/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<T: Storage> Cache<T> {
[width, height]: [f32; 2],
scale: f32,
state: &mut T::State<'_>,
texture_store: &mut T,
storage: &mut T,
) -> Option<&T::Entry> {
let id = handle.id();

Expand Down Expand Up @@ -124,7 +124,7 @@ impl<T: Storage> Cache<T> {
let mut rgba = img.take();
rgba.chunks_exact_mut(4).for_each(|rgba| rgba.swap(0, 2));

let allocation = texture_store.upload(
let allocation = storage.upload(
width,
height,
bytemuck::cast_slice(rgba.as_slice()),
Expand All @@ -143,7 +143,7 @@ impl<T: Storage> Cache<T> {
}

/// Load svg and upload raster data
pub fn trim(&mut self, texture_store: &mut T, state: &mut T::State<'_>) {
pub fn trim(&mut self, storage: &mut T, state: &mut T::State<'_>) {
let svg_hits = &self.svg_hits;
let rasterized_hits = &self.rasterized_hits;

Expand All @@ -152,7 +152,7 @@ impl<T: Storage> Cache<T> {
let retain = rasterized_hits.contains(k);

if !retain {
texture_store.remove(entry, state);
storage.remove(entry, state);
}

retain
Expand Down

0 comments on commit 7a24b4b

Please sign in to comment.