gpu_allocator/visualizer/
mod.rs1use egui::{Color32, Ui};
2
3mod allocation_reports;
4mod memory_chunks;
5
6pub(crate) use allocation_reports::*;
7pub(crate) use memory_chunks::*;
8
9use crate::allocator::AllocationType;
10
11pub const DEFAULT_COLOR_ALLOCATION_TYPE_FREE: Color32 = Color32::from_rgb(159, 159, 159); pub const DEFAULT_COLOR_ALLOCATION_TYPE_LINEAR: Color32 = Color32::from_rgb(91, 206, 250); pub const DEFAULT_COLOR_ALLOCATION_TYPE_NON_LINEAR: Color32 = Color32::from_rgb(250, 169, 184); #[derive(Clone)]
16pub struct ColorScheme {
17 pub free_color: Color32,
18 pub linear_color: Color32,
19 pub non_linear_color: Color32,
20}
21
22impl Default for ColorScheme {
23 fn default() -> Self {
24 Self {
25 free_color: DEFAULT_COLOR_ALLOCATION_TYPE_FREE,
26 linear_color: DEFAULT_COLOR_ALLOCATION_TYPE_LINEAR,
27 non_linear_color: DEFAULT_COLOR_ALLOCATION_TYPE_NON_LINEAR,
28 }
29 }
30}
31
32impl ColorScheme {
33 pub(crate) fn get_allocation_type_color(&self, allocation_type: AllocationType) -> Color32 {
34 match allocation_type {
35 AllocationType::Free => self.free_color,
36 AllocationType::Linear => self.linear_color,
37 AllocationType::NonLinear => self.non_linear_color,
38 }
39 }
40}
41
42pub(crate) trait SubAllocatorVisualizer {
43 fn supports_visualization(&self) -> bool {
44 false
45 }
46 fn draw_base_info(&self, ui: &mut Ui) {
47 ui.label("No sub allocator information available");
48 }
49 fn draw_visualization(
50 &self,
51 _color_scheme: &ColorScheme,
52 _ui: &mut Ui,
53 _settings: &MemoryChunksVisualizationSettings,
54 ) {
55 }
56}