Skip to content

Commit

Permalink
Rename begin/end_frame -> begin/end_pass
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Sep 12, 2024
1 parent 6a06c98 commit 43b1808
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 31 deletions.
6 changes: 3 additions & 3 deletions crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,7 @@ impl Context {
#[cfg(debug_assertions)]
self.debug_painting();

self.write(|ctx| ctx.end_frame())
self.write(|ctx| ctx.end_pass())
}

/// Called at the end of the pass.
Expand Down Expand Up @@ -2185,14 +2185,14 @@ impl Context {
}

impl ContextImpl {
fn end_frame(&mut self) -> FullOutput {
fn end_pass(&mut self) -> FullOutput {
let ended_viewport_id = self.viewport_id();
let viewport = self.viewports.entry(ended_viewport_id).or_default();
let pixels_per_point = viewport.input.pixels_per_point;

viewport.repaint.pass_nr += 1;

self.memory.end_frame(&viewport.this_pass.used_ids);
self.memory.end_pass(&viewport.this_pass.used_ids);

if let Some(fonts) = self.fonts.get(&pixels_per_point.into()) {
let tex_mngr = &mut self.tex_manager.0.write();
Expand Down
4 changes: 2 additions & 2 deletions crates/egui/src/drag_and_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ pub struct DragAndDrop {

impl DragAndDrop {
pub(crate) fn register(ctx: &Context) {
ctx.on_end_pass("debug_text", std::sync::Arc::new(Self::end_frame));
ctx.on_end_pass("debug_text", std::sync::Arc::new(Self::end_pass));
}

fn end_frame(ctx: &Context) {
fn end_pass(ctx: &Context) {
let abort_dnd =
ctx.input(|i| i.pointer.any_released() || i.key_pressed(crate::Key::Escape));

Expand Down
6 changes: 3 additions & 3 deletions crates/egui/src/input_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ impl InputState {
let screen_rect = new.screen_rect.unwrap_or(self.screen_rect);
self.create_touch_states_for_new_devices(&new.events);
for touch_state in self.touch_states.values_mut() {
touch_state.begin_frame(time, &new, self.pointer.interact_pos);
touch_state.begin_pass(time, &new, self.pointer.interact_pos);
}
let pointer = self.pointer.begin_frame(time, &new, options);
let pointer = self.pointer.begin_pass(time, &new, options);

let mut keys_down = self.keys_down;
let mut zoom_factor_delta = 1.0; // TODO(emilk): smoothing for zoom factor
Expand Down Expand Up @@ -900,7 +900,7 @@ impl Default for PointerState {

impl PointerState {
#[must_use]
pub(crate) fn begin_frame(
pub(crate) fn begin_pass(
mut self,
time: f64,
new: &RawInput,
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/input_state/touch_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl TouchState {
}
}

pub fn begin_frame(&mut self, time: f64, new: &RawInput, pointer_pos: Option<Pos2>) {
pub fn begin_pass(&mut self, time: f64, new: &RawInput, pointer_pos: Option<Pos2>) {
let mut added_or_removed_touches = false;
for event in &new.events {
match *event {
Expand Down
10 changes: 5 additions & 5 deletions crates/egui/src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ pub trait BytesLoader {

/// Implementations may use this to perform work at the end of a frame,
/// such as evicting unused entries from a cache.
fn end_frame(&self, frame_index: usize) {
fn end_pass(&self, frame_index: usize) {
let _ = frame_index;
}

Expand Down Expand Up @@ -367,9 +367,9 @@ pub trait ImageLoader {
/// so that all of them may be fully reloaded.
fn forget_all(&self);

/// Implementations may use this to perform work at the end of a frame,
/// Implementations may use this to perform work at the end of a pass,
/// such as evicting unused entries from a cache.
fn end_frame(&self, frame_index: usize) {
fn end_pass(&self, frame_index: usize) {
let _ = frame_index;
}

Expand Down Expand Up @@ -505,9 +505,9 @@ pub trait TextureLoader {
/// so that all of them may be fully reloaded.
fn forget_all(&self);

/// Implementations may use this to perform work at the end of a frame,
/// Implementations may use this to perform work at the end of a pass,
/// such as evicting unused entries from a cache.
fn end_frame(&self, frame_index: usize) {
fn end_pass(&self, frame_index: usize) {
let _ = frame_index;
}

Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/load/texture_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl TextureLoader for DefaultTextureLoader {
self.cache.lock().clear();
}

fn end_frame(&self, _: usize) {}
fn end_pass(&self, _: usize) {}

fn byte_size(&self) -> usize {
self.cache
Expand Down
18 changes: 9 additions & 9 deletions crates/egui/src/memory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl Default for Options {
}

impl Options {
pub(crate) fn begin_frame(&mut self, new_raw_input: &RawInput) {
pub(crate) fn begin_pass(&mut self, new_raw_input: &RawInput) {
self.system_theme = new_raw_input.system_theme;
}

Expand Down Expand Up @@ -541,7 +541,7 @@ impl Focus {
self.focused_widget.as_ref().map(|w| w.id)
}

fn begin_frame(&mut self, new_input: &crate::data::input::RawInput) {
fn begin_pass(&mut self, new_input: &crate::data::input::RawInput) {
self.id_previous_frame = self.focused();
if let Some(id) = self.id_next_frame.take() {
self.focused_widget = Some(FocusWidget::new(id));
Expand Down Expand Up @@ -602,7 +602,7 @@ impl Focus {
}
}

pub(crate) fn end_frame(&mut self, used_ids: &IdMap<Rect>) {
pub(crate) fn end_pass(&mut self, used_ids: &IdMap<Rect>) {
if self.focus_direction.is_cardinal() {
if let Some(found_widget) = self.find_widget_in_direction(used_ids) {
self.focused_widget = Some(FocusWidget::new(found_widget));
Expand Down Expand Up @@ -765,18 +765,18 @@ impl Memory {

// self.interactions is handled elsewhere

self.options.begin_frame(new_raw_input);
self.options.begin_pass(new_raw_input);

self.focus
.entry(self.viewport_id)
.or_default()
.begin_frame(new_raw_input);
.begin_pass(new_raw_input);
}

pub(crate) fn end_frame(&mut self, used_ids: &IdMap<Rect>) {
pub(crate) fn end_pass(&mut self, used_ids: &IdMap<Rect>) {
self.caches.update();
self.areas_mut().end_frame();
self.focus_mut().end_frame(used_ids);
self.areas_mut().end_pass();
self.focus_mut().end_pass(used_ids);
}

pub(crate) fn set_viewport_id(&mut self, viewport_id: ViewportId) {
Expand Down Expand Up @@ -1175,7 +1175,7 @@ impl Areas {
.any(|(_, children)| children.contains(layer))
}

pub(crate) fn end_frame(&mut self) {
pub(crate) fn end_pass(&mut self) {
let Self {
visible_last_frame,
visible_current_frame,
Expand Down
11 changes: 4 additions & 7 deletions crates/egui/src/text_selection/label_text_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,8 @@ impl Default for LabelSelectionState {

impl LabelSelectionState {
pub(crate) fn register(ctx: &Context) {
ctx.on_begin_pass(
"LabelSelectionState",
std::sync::Arc::new(Self::begin_frame),
);
ctx.on_end_pass("LabelSelectionState", std::sync::Arc::new(Self::end_frame));
ctx.on_begin_pass("LabelSelectionState", std::sync::Arc::new(Self::begin_pass));
ctx.on_end_pass("LabelSelectionState", std::sync::Arc::new(Self::end_pass));
}

pub fn load(ctx: &Context) -> Self {
Expand All @@ -138,7 +135,7 @@ impl LabelSelectionState {
});
}

fn begin_frame(ctx: &Context) {
fn begin_pass(ctx: &Context) {
let mut state = Self::load(ctx);

if ctx.input(|i| i.pointer.any_pressed() && !i.modifiers.shift) {
Expand All @@ -159,7 +156,7 @@ impl LabelSelectionState {
state.store(ctx);
}

fn end_frame(ctx: &Context) {
fn end_pass(ctx: &Context) {
let mut state = Self::load(ctx);

if state.is_dragging {
Expand Down

0 comments on commit 43b1808

Please sign in to comment.