Replace texture_store and store with storage

This commit is contained in:
Héctor Ramón Jiménez 2022-11-05 03:39:59 +01:00
parent 0a23f518c7
commit 7a24b4ba69
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 9 additions and 9 deletions

View file

@ -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,
@ -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);
}
@ -126,7 +126,7 @@ 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| {
@ -134,7 +134,7 @@ impl<T: Storage> Cache<T> {
if !retain {
if let Memory::Device(entry) = memory {
store.remove(entry, state);
storage.remove(entry, state);
}
}

View file

@ -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();
@ -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()),
@ -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;
@ -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