1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 21:00:03 -04:00

[refactor] rename 'PaintBatches' to 'PaintJobs'

This commit is contained in:
Emil Ernerfeldt
2020-07-19 00:01:13 +02:00
parent 7565210b2d
commit fccd135254
7 changed files with 45 additions and 43 deletions

View File

@@ -74,27 +74,27 @@ impl Backend {
self.ctx.begin_frame(raw_input)
}
pub fn end_frame(&mut self) -> Result<(egui::Output, egui::PaintBatches), JsValue> {
pub fn end_frame(&mut self) -> Result<(egui::Output, egui::PaintJobs), JsValue> {
let frame_start = self
.frame_start
.take()
.expect("unmatched calls to begin_frame/end_frame");
let (output, batches) = self.ctx.end_frame();
let (output, paint_jobs) = self.ctx.end_frame();
self.auto_save();
let now = now_sec();
self.frame_times.add(now, (now - frame_start) as f32);
Ok((output, batches))
Ok((output, paint_jobs))
}
pub fn paint(&mut self, batches: egui::PaintBatches) -> Result<(), JsValue> {
pub fn paint(&mut self, paint_jobs: egui::PaintJobs) -> Result<(), JsValue> {
let bg_color = egui::color::TRANSPARENT; // Use background css color.
self.painter.paint_batches(
self.painter.paint_jobs(
bg_color,
batches,
paint_jobs,
self.ctx.texture(),
self.ctx.pixels_per_point(),
)
@@ -175,7 +175,7 @@ impl AppRunner {
self.backend.canvas_id()
}
pub fn logic(&mut self) -> Result<(egui::Output, egui::PaintBatches), JsValue> {
pub fn logic(&mut self) -> Result<(egui::Output, egui::PaintJobs), JsValue> {
resize_to_screen_size(self.backend.canvas_id());
let raw_input = self.web_input.new_frame();
@@ -186,13 +186,13 @@ impl AppRunner {
let mut ui = self.backend.begin_frame(raw_input);
self.app.ui(&mut ui, &mut self.backend, &info);
let (output, batches) = self.backend.end_frame()?;
let (output, paint_jobs) = self.backend.end_frame()?;
handle_output(&output);
Ok((output, batches))
Ok((output, paint_jobs))
}
pub fn paint(&mut self, batches: egui::PaintBatches) -> Result<(), JsValue> {
self.backend.paint(batches)
pub fn paint(&mut self, paint_jobs: egui::PaintJobs) -> Result<(), JsValue> {
self.backend.paint(paint_jobs)
}
}
@@ -414,8 +414,8 @@ fn paint_and_schedule(runner_ref: AppRunnerRef) -> Result<(), JsValue> {
let mut runner_lock = runner_ref.0.lock();
if runner_lock.backend.run_mode() == RunMode::Continuous || runner_lock.needs_repaint {
runner_lock.needs_repaint = false;
let (output, batches) = runner_lock.logic()?;
runner_lock.paint(batches)?;
let (output, paint_jobs) = runner_lock.logic()?;
runner_lock.paint(paint_jobs)?;
runner_lock.needs_repaint = output.needs_repaint;
}
Ok(())

View File

@@ -6,7 +6,7 @@ use {
use egui::{
math::clamp,
paint::{Color, PaintBatches, Texture, Triangles},
paint::{Color, PaintJobs, Texture, Triangles},
vec2,
};
@@ -149,10 +149,10 @@ impl Painter {
self.current_texture_id = Some(texture.id);
}
pub fn paint_batches(
pub fn paint_jobs(
&mut self,
bg_color: Color,
batches: PaintBatches,
jobs: PaintJobs,
texture: &Texture,
pixels_per_point: f32,
) -> Result<(), JsValue> {
@@ -205,7 +205,7 @@ impl Painter {
);
gl.clear(Gl::COLOR_BUFFER_BIT);
for (clip_rect, triangles) in batches {
for (clip_rect, triangles) in jobs {
let clip_min_x = pixels_per_point * clip_rect.min.x;
let clip_min_y = pixels_per_point * clip_rect.min.y;
let clip_max_x = pixels_per_point * clip_rect.max.x;