Skip to content

Commit

Permalink
refactor: ♻️ Rename atlas cache to atlas loader
Browse files Browse the repository at this point in the history
  • Loading branch information
melody-rs committed Dec 2, 2023
1 parent 0358b0a commit 15cb4a6
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion crates/components/src/map_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl MapView {
|x, y, passage| passages[(x, y)] = passage,
);

let atlas = update_state.graphics.atlas_cache.load_atlas(
let atlas = update_state.graphics.atlas_loader.load_atlas(
&update_state.graphics,
update_state.filesystem,
tileset,
Expand Down
2 changes: 1 addition & 1 deletion crates/components/src/tilepicker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Tilepicker {
let tilesets = update_state.data.tilesets();
let tileset = &tilesets[map.tileset_id];

let atlas = update_state.graphics.atlas_cache.load_atlas(
let atlas = update_state.graphics.atlas_loader.load_atlas(
&update_state.graphics,
update_state.filesystem,
tileset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
use crate::{tiles::Atlas, GraphicsState};

#[derive(Default)]
pub struct Cache {
pub struct Loader {
atlases: dashmap::DashMap<usize, Atlas>,
}

impl Cache {
impl Loader {
pub fn load_atlas(
&self,
graphics_state: &GraphicsState,
Expand Down
16 changes: 7 additions & 9 deletions crates/graphics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,19 @@ pub mod event;
pub mod map;
pub mod plane;

pub mod atlas_cache;
pub mod atlas_loader;

pub mod texture_loader;

use std::sync::Arc;

pub use event::Event;
pub use map::Map;
pub use plane::Plane;

pub use texture_loader::{Texture, TextureLoader};
pub use texture_loader::Texture;

pub struct GraphicsState {
pub texture_loader: Arc<TextureLoader>,
pub atlas_cache: atlas_cache::Cache,
pub texture_loader: texture_loader::Loader,
pub atlas_loader: atlas_loader::Loader,
pub render_state: egui_wgpu::RenderState,

pub nearest_sampler: wgpu::Sampler,
Expand Down Expand Up @@ -81,8 +79,8 @@ impl GraphicsState {
),
};

let texture_loader = Arc::new(TextureLoader::new(render_state.clone()));
let atlas_cache = atlas_cache::Cache::default();
let texture_loader = texture_loader::Loader::new(render_state.clone());
let atlas_cache = atlas_loader::Loader::default();

let nearest_sampler = render_state
.device
Expand All @@ -97,7 +95,7 @@ impl GraphicsState {

Self {
texture_loader,
atlas_cache,
atlas_loader: atlas_cache,
render_state,

nearest_sampler,
Expand Down
2 changes: 1 addition & 1 deletion crates/graphics/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl Map {
passages: &luminol_data::Table2,
) -> anyhow::Result<Self> {
let atlas = graphics_state
.atlas_cache
.atlas_loader
.load_atlas(graphics_state, filesystem, tileset)?;

let viewport = Arc::new(Viewport::new(
Expand Down
4 changes: 2 additions & 2 deletions crates/graphics/src/texture_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::sync::Arc;

use wgpu::util::DeviceExt;

pub struct TextureLoader {
pub struct Loader {
loaded_textures: DashMap<camino::Utf8PathBuf, Arc<Texture>>,

render_state: egui_wgpu::RenderState,
Expand Down Expand Up @@ -98,7 +98,7 @@ impl Texture {
}
}

impl TextureLoader {
impl Loader {
pub fn new(render_state: egui_wgpu::RenderState) -> Self {
Self {
loaded_textures: DashMap::with_capacity(64),
Expand Down
2 changes: 1 addition & 1 deletion crates/ui/src/windows/appearance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl luminol_core::Window for Window {
.clicked()
{
update_state.graphics.texture_loader.clear();
update_state.graphics.atlas_cache.clear();
update_state.graphics.atlas_loader.clear();
update_state.bytes_loader.forget_all();
}
});
Expand Down

0 comments on commit 15cb4a6

Please sign in to comment.