Remove get_ prefix from functions to better follow Rust API Guidelines

This commit is contained in:
Emil Ernerfeldt 2022-08-08 12:21:53 +02:00
parent e38955fbac
commit 7c25a9238e
11 changed files with 68 additions and 63 deletions

View file

@ -569,7 +569,7 @@ impl RenderPass {
/// This could be used by custom paint hooks to render images that have been added through with /// This could be used by custom paint hooks to render images that have been added through with
/// [`egui_extras::RetainedImage`](https://docs.rs/egui_extras/latest/egui_extras/image/struct.RetainedImage.html) /// [`egui_extras::RetainedImage`](https://docs.rs/egui_extras/latest/egui_extras/image/struct.RetainedImage.html)
/// or [`egui::Context::load_texture`]. /// or [`egui::Context::load_texture`].
pub fn get_texture( pub fn texture(
&self, &self,
id: &egui::TextureId, id: &egui::TextureId,
) -> Option<&(Option<wgpu::Texture>, wgpu::BindGroup)> { ) -> Option<&(Option<wgpu::Texture>, wgpu::BindGroup)> {

View file

@ -66,7 +66,7 @@ pub struct State {
impl State { impl State {
pub fn new<T>(event_loop: &EventLoopWindowTarget<T>) -> Self { pub fn new<T>(event_loop: &EventLoopWindowTarget<T>) -> Self {
Self::new_with_wayland_display(get_wayland_display(event_loop)) Self::new_with_wayland_display(wayland_display(event_loop))
} }
pub fn new_with_wayland_display(wayland_display: Option<*mut c_void>) -> Self { pub fn new_with_wayland_display(wayland_display: Option<*mut c_void>) -> Self {
@ -712,7 +712,7 @@ fn translate_cursor(cursor_icon: egui::CursorIcon) -> Option<winit::window::Curs
} }
/// Returns a Wayland display handle if the target is running Wayland /// Returns a Wayland display handle if the target is running Wayland
fn get_wayland_display<T>(_event_loop: &EventLoopWindowTarget<T>) -> Option<*mut c_void> { fn wayland_display<T>(_event_loop: &EventLoopWindowTarget<T>) -> Option<*mut c_void> {
#[cfg(any( #[cfg(any(
target_os = "linux", target_os = "linux",
target_os = "dragonfly", target_os = "dragonfly",

View file

@ -532,7 +532,7 @@ impl MenuState {
id: Id, id: Id,
add_contents: impl FnOnce(&mut Ui) -> R, add_contents: impl FnOnce(&mut Ui) -> R,
) -> Option<R> { ) -> Option<R> {
let (sub_response, response) = self.get_submenu(id).map(|sub| { let (sub_response, response) = self.submenu(id).map(|sub| {
let inner_response = Self::show(ctx, sub, id, add_contents); let inner_response = Self::show(ctx, sub, id, add_contents);
(sub.read().response, inner_response.inner) (sub.read().response, inner_response.inner)
})?; })?;
@ -582,7 +582,7 @@ impl MenuState {
if pointer.is_still() { if pointer.is_still() {
return false; return false;
} }
if let Some(sub_menu) = self.get_current_submenu() { if let Some(sub_menu) = self.current_submenu() {
if let Some(pos) = pointer.hover_pos() { if let Some(pos) = pointer.hover_pos() {
return Self::points_at_left_of_rect(pos, pointer.velocity(), sub_menu.read().rect); return Self::points_at_left_of_rect(pos, pointer.velocity(), sub_menu.read().rect);
} }
@ -592,7 +592,7 @@ impl MenuState {
/// Check if pointer is hovering current submenu. /// Check if pointer is hovering current submenu.
fn hovering_current_submenu(&self, pointer: &PointerState) -> bool { fn hovering_current_submenu(&self, pointer: &PointerState) -> bool {
if let Some(sub_menu) = self.get_current_submenu() { if let Some(sub_menu) = self.current_submenu() {
if let Some(pos) = pointer.hover_pos() { if let Some(pos) = pointer.hover_pos() {
return sub_menu.read().area_contains(pos); return sub_menu.read().area_contains(pos);
} }
@ -608,18 +608,18 @@ impl MenuState {
} }
fn is_open(&self, id: Id) -> bool { fn is_open(&self, id: Id) -> bool {
self.get_sub_id() == Some(id) self.sub_id() == Some(id)
} }
fn get_sub_id(&self) -> Option<Id> { fn sub_id(&self) -> Option<Id> {
self.sub_menu.as_ref().map(|(id, _)| *id) self.sub_menu.as_ref().map(|(id, _)| *id)
} }
fn get_current_submenu(&self) -> Option<&Arc<RwLock<MenuState>>> { fn current_submenu(&self) -> Option<&Arc<RwLock<MenuState>>> {
self.sub_menu.as_ref().map(|(_, sub)| sub) self.sub_menu.as_ref().map(|(_, sub)| sub)
} }
fn get_submenu(&mut self, id: Id) -> Option<&Arc<RwLock<MenuState>>> { fn submenu(&mut self, id: Id) -> Option<&Arc<RwLock<MenuState>>> {
self.sub_menu self.sub_menu
.as_ref() .as_ref()
.and_then(|(k, sub)| if id == *k { Some(sub) } else { None }) .and_then(|(k, sub)| if id == *k { Some(sub) } else { None })

View file

@ -99,7 +99,7 @@ impl Ui {
crate::egui_assert!(!max_rect.any_nan()); crate::egui_assert!(!max_rect.any_nan());
let next_auto_id_source = Id::new(self.next_auto_id_source).with("child").value(); let next_auto_id_source = Id::new(self.next_auto_id_source).with("child").value();
self.next_auto_id_source = self.next_auto_id_source.wrapping_add(1); self.next_auto_id_source = self.next_auto_id_source.wrapping_add(1);
let menu_state = self.get_menu_state(); let menu_state = self.menu_state();
Ui { Ui {
id: self.id.with(id_source), id: self.id.with(id_source),
next_auto_id_source, next_auto_id_source,
@ -2096,7 +2096,7 @@ impl Ui {
self.menu_state = None; self.menu_state = None;
} }
pub(crate) fn get_menu_state(&self) -> Option<Arc<RwLock<MenuState>>> { pub(crate) fn menu_state(&self) -> Option<Arc<RwLock<MenuState>>> {
self.menu_state.clone() self.menu_state.clone()
} }

View file

@ -32,7 +32,7 @@ pub(super) struct PlotConfig<'a> {
/// Trait shared by things that can be drawn in the plot. /// Trait shared by things that can be drawn in the plot.
pub(super) trait PlotItem { pub(super) trait PlotItem {
fn get_shapes(&self, ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>); fn shapes(&self, ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>);
fn initialize(&mut self, x_range: RangeInclusive<f64>); fn initialize(&mut self, x_range: RangeInclusive<f64>);
@ -46,7 +46,7 @@ pub(super) trait PlotItem {
fn geometry(&self) -> PlotGeometry<'_>; fn geometry(&self) -> PlotGeometry<'_>;
fn get_bounds(&self) -> PlotBounds; fn bounds(&self) -> PlotBounds;
fn find_closest(&self, point: Pos2, transform: &ScreenTransform) -> Option<ClosestElem> { fn find_closest(&self, point: Pos2, transform: &ScreenTransform) -> Option<ClosestElem> {
match self.geometry() { match self.geometry() {
@ -167,7 +167,7 @@ impl HLine {
} }
impl PlotItem for HLine { impl PlotItem for HLine {
fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) { fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) {
let HLine { let HLine {
y, y,
stroke, stroke,
@ -204,7 +204,7 @@ impl PlotItem for HLine {
PlotGeometry::None PlotGeometry::None
} }
fn get_bounds(&self) -> PlotBounds { fn bounds(&self) -> PlotBounds {
let mut bounds = PlotBounds::NOTHING; let mut bounds = PlotBounds::NOTHING;
bounds.min[1] = self.y; bounds.min[1] = self.y;
bounds.max[1] = self.y; bounds.max[1] = self.y;
@ -277,7 +277,7 @@ impl VLine {
} }
impl PlotItem for VLine { impl PlotItem for VLine {
fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) { fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) {
let VLine { let VLine {
x, x,
stroke, stroke,
@ -314,7 +314,7 @@ impl PlotItem for VLine {
PlotGeometry::None PlotGeometry::None
} }
fn get_bounds(&self) -> PlotBounds { fn bounds(&self) -> PlotBounds {
let mut bounds = PlotBounds::NOTHING; let mut bounds = PlotBounds::NOTHING;
bounds.min[0] = self.x; bounds.min[0] = self.x;
bounds.max[0] = self.x; bounds.max[0] = self.x;
@ -401,7 +401,7 @@ fn y_intersection(p1: &Pos2, p2: &Pos2, y: f32) -> Option<f32> {
} }
impl PlotItem for Line { impl PlotItem for Line {
fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) { fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) {
let Self { let Self {
series, series,
stroke, stroke,
@ -484,8 +484,8 @@ impl PlotItem for Line {
PlotGeometry::Points(self.series.points()) PlotGeometry::Points(self.series.points())
} }
fn get_bounds(&self) -> PlotBounds { fn bounds(&self) -> PlotBounds {
self.series.get_bounds() self.series.bounds()
} }
} }
@ -562,7 +562,7 @@ impl Polygon {
} }
impl PlotItem for Polygon { impl PlotItem for Polygon {
fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) { fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) {
let Self { let Self {
series, series,
stroke, stroke,
@ -614,8 +614,8 @@ impl PlotItem for Polygon {
PlotGeometry::Points(self.series.points()) PlotGeometry::Points(self.series.points())
} }
fn get_bounds(&self) -> PlotBounds { fn bounds(&self) -> PlotBounds {
self.series.get_bounds() self.series.bounds()
} }
} }
@ -674,7 +674,7 @@ impl Text {
} }
impl PlotItem for Text { impl PlotItem for Text {
fn get_shapes(&self, ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) { fn shapes(&self, ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) {
let color = if self.color == Color32::TRANSPARENT { let color = if self.color == Color32::TRANSPARENT {
ui.style().visuals.text_color() ui.style().visuals.text_color()
} else { } else {
@ -728,7 +728,7 @@ impl PlotItem for Text {
PlotGeometry::None PlotGeometry::None
} }
fn get_bounds(&self) -> PlotBounds { fn bounds(&self) -> PlotBounds {
let mut bounds = PlotBounds::NOTHING; let mut bounds = PlotBounds::NOTHING;
bounds.extend_with(&self.position); bounds.extend_with(&self.position);
bounds bounds
@ -814,7 +814,7 @@ impl Points {
} }
impl PlotItem for Points { impl PlotItem for Points {
fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) { fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) {
let sqrt_3 = 3_f32.sqrt(); let sqrt_3 = 3_f32.sqrt();
let frac_sqrt_3_2 = 3_f32.sqrt() / 2.0; let frac_sqrt_3_2 = 3_f32.sqrt() / 2.0;
let frac_1_sqrt_2 = 1.0 / 2_f32.sqrt(); let frac_1_sqrt_2 = 1.0 / 2_f32.sqrt();
@ -965,8 +965,8 @@ impl PlotItem for Points {
PlotGeometry::Points(self.series.points()) PlotGeometry::Points(self.series.points())
} }
fn get_bounds(&self) -> PlotBounds { fn bounds(&self) -> PlotBounds {
self.series.get_bounds() self.series.bounds()
} }
} }
@ -1016,7 +1016,7 @@ impl Arrows {
} }
impl PlotItem for Arrows { impl PlotItem for Arrows {
fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) { fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) {
use crate::emath::*; use crate::emath::*;
let Self { let Self {
origins, origins,
@ -1080,8 +1080,8 @@ impl PlotItem for Arrows {
PlotGeometry::Points(self.origins.points()) PlotGeometry::Points(self.origins.points())
} }
fn get_bounds(&self) -> PlotBounds { fn bounds(&self) -> PlotBounds {
self.origins.get_bounds() self.origins.bounds()
} }
} }
@ -1155,7 +1155,7 @@ impl PlotImage {
} }
impl PlotItem for PlotImage { impl PlotItem for PlotImage {
fn get_shapes(&self, ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) { fn shapes(&self, ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) {
let Self { let Self {
position, position,
texture_id, texture_id,
@ -1215,7 +1215,7 @@ impl PlotItem for PlotImage {
PlotGeometry::None PlotGeometry::None
} }
fn get_bounds(&self) -> PlotBounds { fn bounds(&self) -> PlotBounds {
let mut bounds = PlotBounds::NOTHING; let mut bounds = PlotBounds::NOTHING;
let left_top = PlotPoint::new( let left_top = PlotPoint::new(
self.position.x as f32 - self.size.x / 2.0, self.position.x as f32 - self.size.x / 2.0,
@ -1346,7 +1346,7 @@ impl BarChart {
} }
impl PlotItem for BarChart { impl PlotItem for BarChart {
fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) { fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) {
for b in &self.bars { for b in &self.bars {
b.add_shapes(transform, self.highlight, shapes); b.add_shapes(transform, self.highlight, shapes);
} }
@ -1376,7 +1376,7 @@ impl PlotItem for BarChart {
PlotGeometry::Rects PlotGeometry::Rects
} }
fn get_bounds(&self) -> PlotBounds { fn bounds(&self) -> PlotBounds {
let mut bounds = PlotBounds::NOTHING; let mut bounds = PlotBounds::NOTHING;
for b in &self.bars { for b in &self.bars {
bounds.merge(&b.bounds()); bounds.merge(&b.bounds());
@ -1488,7 +1488,7 @@ impl BoxPlot {
} }
impl PlotItem for BoxPlot { impl PlotItem for BoxPlot {
fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) { fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec<Shape>) {
for b in &self.boxes { for b in &self.boxes {
b.add_shapes(transform, self.highlight, shapes); b.add_shapes(transform, self.highlight, shapes);
} }
@ -1518,7 +1518,7 @@ impl PlotItem for BoxPlot {
PlotGeometry::Rects PlotGeometry::Rects
} }
fn get_bounds(&self) -> PlotBounds { fn bounds(&self) -> PlotBounds {
let mut bounds = PlotBounds::NOTHING; let mut bounds = PlotBounds::NOTHING;
for b in &self.boxes { for b in &self.boxes {
bounds.merge(&b.bounds()); bounds.merge(&b.bounds());

View file

@ -302,7 +302,7 @@ impl PlotPoints {
(start < end).then(|| start..=end) (start < end).then(|| start..=end)
} }
pub(super) fn get_bounds(&self) -> PlotBounds { pub(super) fn bounds(&self) -> PlotBounds {
match self { match self {
PlotPoints::Owned(points) => { PlotPoints::Owned(points) => {
let mut bounds = PlotBounds::NOTHING; let mut bounds = PlotBounds::NOTHING;

View file

@ -199,7 +199,7 @@ impl LegendWidget {
} }
// Get the names of the hidden items. // Get the names of the hidden items.
pub fn get_hidden_items(&self) -> AHashSet<String> { pub fn hidden_items(&self) -> AHashSet<String> {
self.entries self.entries
.iter() .iter()
.filter(|(_, entry)| !entry.checked) .filter(|(_, entry)| !entry.checked)
@ -208,7 +208,7 @@ impl LegendWidget {
} }
// Get the name of the hovered items. // Get the name of the hovered items.
pub fn get_hovered_entry_name(&self) -> Option<String> { pub fn hovered_entry_name(&self) -> Option<String> {
self.entries self.entries
.iter() .iter()
.find(|(_, entry)| entry.hovered) .find(|(_, entry)| entry.hovered)

View file

@ -430,7 +430,7 @@ impl Plot {
/// ///
/// The function has this signature: /// The function has this signature:
/// ```ignore /// ```ignore
/// fn get_step_sizes(input: GridInput) -> Vec<GridMark>; /// fn step_sizes(input: GridInput) -> Vec<GridMark>;
/// ``` /// ```
/// ///
/// This function should return all marks along the visible range of the X axis. /// This function should return all marks along the visible range of the X axis.
@ -697,7 +697,7 @@ impl Plot {
} }
for item in &items { for item in &items {
let item_bounds = item.get_bounds(); let item_bounds = item.bounds();
if auto_bounds.x { if auto_bounds.x {
bounds.merge_x(&item_bounds); bounds.merge_x(&item_bounds);
@ -829,8 +829,8 @@ impl Plot {
if let Some(mut legend) = legend { if let Some(mut legend) = legend {
ui.add(&mut legend); ui.add(&mut legend);
hidden_items = legend.get_hidden_items(); hidden_items = legend.hidden_items();
hovered_entry = legend.get_hovered_entry_name(); hovered_entry = legend.hovered_entry_name();
} }
if let Some(group) = linked_axes.as_ref() { if let Some(group) = linked_axes.as_ref() {
@ -1073,7 +1073,7 @@ pub struct GridMark {
/// 10 is a typical value, others are possible though. /// 10 is a typical value, others are possible though.
pub fn log_grid_spacer(log_base: i64) -> GridSpacer { pub fn log_grid_spacer(log_base: i64) -> GridSpacer {
let log_base = log_base as f64; let log_base = log_base as f64;
let get_step_sizes = move |input: GridInput| -> Vec<GridMark> { let step_sizes = move |input: GridInput| -> Vec<GridMark> {
// The distance between two of the thinnest grid lines is "rounded" up // The distance between two of the thinnest grid lines is "rounded" up
// to the next-bigger power of base // to the next-bigger power of base
let smallest_visible_unit = next_power(input.base_step_size, log_base); let smallest_visible_unit = next_power(input.base_step_size, log_base);
@ -1087,7 +1087,7 @@ pub fn log_grid_spacer(log_base: i64) -> GridSpacer {
generate_marks(step_sizes, input.bounds) generate_marks(step_sizes, input.bounds)
}; };
Box::new(get_step_sizes) Box::new(step_sizes)
} }
/// Splits the grid into uniform-sized spacings (e.g. 100, 25, 1). /// Splits the grid into uniform-sized spacings (e.g. 100, 25, 1).
@ -1136,7 +1136,7 @@ impl PreparedPlot {
let mut plot_ui = ui.child_ui(*transform.frame(), Layout::default()); let mut plot_ui = ui.child_ui(*transform.frame(), Layout::default());
plot_ui.set_clip_rect(*transform.frame()); plot_ui.set_clip_rect(*transform.frame());
for item in &self.items { for item in &self.items {
item.get_shapes(&mut plot_ui, transform, &mut shapes); item.shapes(&mut plot_ui, transform, &mut shapes);
} }
if let Some(pointer) = response.hover_pos() { if let Some(pointer) = response.hover_pos() {

View file

@ -389,19 +389,19 @@ impl CustomAxisDemo {
const MINS_PER_DAY: f64 = CustomAxisDemo::MINS_PER_DAY; const MINS_PER_DAY: f64 = CustomAxisDemo::MINS_PER_DAY;
const MINS_PER_H: f64 = CustomAxisDemo::MINS_PER_H; const MINS_PER_H: f64 = CustomAxisDemo::MINS_PER_H;
fn get_day(x: f64) -> f64 { fn day(x: f64) -> f64 {
(x / MINS_PER_DAY).floor() (x / MINS_PER_DAY).floor()
} }
fn get_hour(x: f64) -> f64 { fn hour(x: f64) -> f64 {
(x.rem_euclid(MINS_PER_DAY) / MINS_PER_H).floor() (x.rem_euclid(MINS_PER_DAY) / MINS_PER_H).floor()
} }
fn get_minute(x: f64) -> f64 { fn minute(x: f64) -> f64 {
x.rem_euclid(MINS_PER_H).floor() x.rem_euclid(MINS_PER_H).floor()
} }
fn get_percent(y: f64) -> f64 { fn percent(y: f64) -> f64 {
100.0 * y 100.0 * y
} }
@ -411,17 +411,17 @@ impl CustomAxisDemo {
String::new() String::new()
} else if is_approx_integer(x / MINS_PER_DAY) { } else if is_approx_integer(x / MINS_PER_DAY) {
// Days // Days
format!("Day {}", get_day(x)) format!("Day {}", day(x))
} else { } else {
// Hours and minutes // Hours and minutes
format!("{h}:{m:02}", h = get_hour(x), m = get_minute(x)) format!("{h}:{m:02}", h = hour(x), m = minute(x))
} }
}; };
let y_fmt = |y, _range: &RangeInclusive<f64>| { let y_fmt = |y, _range: &RangeInclusive<f64>| {
// Display only integer percentages // Display only integer percentages
if !is_approx_zero(y) && is_approx_integer(100.0 * y) { if !is_approx_zero(y) && is_approx_integer(100.0 * y) {
format!("{:.0}%", get_percent(y)) format!("{:.0}%", percent(y))
} else { } else {
String::new() String::new()
} }
@ -430,10 +430,10 @@ impl CustomAxisDemo {
let label_fmt = |_s: &str, val: &PlotPoint| { let label_fmt = |_s: &str, val: &PlotPoint| {
format!( format!(
"Day {d}, {h}:{m:02}\n{p:.2}%", "Day {d}, {h}:{m:02}\n{p:.2}%",
d = get_day(val.x), d = day(val.x),
h = get_hour(val.x), h = hour(val.x),
m = get_minute(val.x), m = minute(val.x),
p = get_percent(val.y) p = percent(val.y)
) )
}; };

View file

@ -145,7 +145,7 @@ impl Painter {
let width_in_points = width_in_pixels as f32 / pixels_per_point; let width_in_points = width_in_pixels as f32 / pixels_per_point;
let height_in_points = height_in_pixels as f32 / pixels_per_point; let height_in_points = height_in_pixels as f32 / pixels_per_point;
if let Some(texture) = self.get_texture(mesh.texture_id) { if let Some(texture) = self.texture(mesh.texture_id) {
// The texture coordinates for text are so that both nearest and linear should work with the egui font texture. // The texture coordinates for text are so that both nearest and linear should work with the egui font texture.
// For user textures linear sampling is more likely to be the right choice. // For user textures linear sampling is more likely to be the right choice.
let filter = MagnifySamplerFilter::Linear; let filter = MagnifySamplerFilter::Linear;
@ -274,7 +274,7 @@ impl Painter {
self.textures.remove(&tex_id); self.textures.remove(&tex_id);
} }
fn get_texture(&self, texture_id: egui::TextureId) -> Option<&SrgbTexture2d> { fn texture(&self, texture_id: egui::TextureId) -> Option<&SrgbTexture2d> {
self.textures.get(&texture_id).map(|rc| rc.as_ref()) self.textures.get(&texture_id).map(|rc| rc.as_ref())
} }

View file

@ -452,7 +452,7 @@ impl Painter {
#[inline(never)] // Easier profiling #[inline(never)] // Easier profiling
fn paint_mesh(&mut self, mesh: &Mesh) { fn paint_mesh(&mut self, mesh: &Mesh) {
debug_assert!(mesh.is_valid()); debug_assert!(mesh.is_valid());
if let Some(texture) = self.get_texture(mesh.texture_id) { if let Some(texture) = self.texture(mesh.texture_id) {
unsafe { unsafe {
self.gl.bind_buffer(glow::ARRAY_BUFFER, Some(self.vbo)); self.gl.bind_buffer(glow::ARRAY_BUFFER, Some(self.vbo));
self.gl.buffer_data_u8_slice( self.gl.buffer_data_u8_slice(
@ -634,10 +634,15 @@ impl Painter {
} }
/// Get the [`glow::Texture`] bound to a [`egui::TextureId`]. /// Get the [`glow::Texture`] bound to a [`egui::TextureId`].
pub fn get_texture(&self, texture_id: egui::TextureId) -> Option<glow::Texture> { pub fn texture(&self, texture_id: egui::TextureId) -> Option<glow::Texture> {
self.textures.get(&texture_id).copied() self.textures.get(&texture_id).copied()
} }
#[deprecated = "renamed 'texture'"]
pub fn get_texture(&self, texture_id: egui::TextureId) -> Option<glow::Texture> {
self.texture(texture_id)
}
#[allow(clippy::needless_pass_by_value)] // False positive #[allow(clippy::needless_pass_by_value)] // False positive
pub fn register_native_texture(&mut self, native: glow::Texture) -> egui::TextureId { pub fn register_native_texture(&mut self, native: glow::Texture) -> egui::TextureId {
self.assert_not_destroyed(); self.assert_not_destroyed();