| 1 |
use egui::{Color32, Ui}; |
| 2 |
|
| 3 |
mod allocation_reports; |
| 4 |
mod memory_chunks; |
| 5 |
|
| 6 |
pub(crate) use allocation_reports::*; |
| 7 |
pub(crate) use memory_chunks::*; |
| 8 |
|
| 9 |
use crate::allocator::AllocationType; |
| 10 |
|
| 11 |
pub const DEFAULT_COLOR_ALLOCATION_TYPE_FREE: Color32 = Color32::from_rgb(159, 159, 159); // gray |
| 12 |
pub const DEFAULT_COLOR_ALLOCATION_TYPE_LINEAR: Color32 = Color32::from_rgb(91, 206, 250); // blue |
| 13 |
pub const DEFAULT_COLOR_ALLOCATION_TYPE_NON_LINEAR: Color32 = Color32::from_rgb(250, 169, 184); // pink |
| 14 |
|
| 15 |
#[derive(Clone)] |
| 16 |
pub struct ColorScheme { |
| 17 |
pub free_color: Color32, |
| 18 |
pub linear_color: Color32, |
| 19 |
pub non_linear_color: Color32, |
| 20 |
} |
| 21 |
|
| 22 |
impl 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 |
|
| 32 |
impl 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 |
|
| 42 |
pub(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 |
} |