2021-01-16 00:30:00 +00:00
|
|
|
use wasm_bindgen::prelude::JsValue;
|
|
|
|
|
|
|
|
pub trait Painter {
|
2022-01-24 13:32:36 +00:00
|
|
|
/// Max size of one side of a texture.
|
|
|
|
fn max_texture_side(&self) -> usize;
|
|
|
|
|
2022-01-22 10:23:12 +00:00
|
|
|
fn set_texture(&mut self, tex_id: egui::TextureId, delta: &egui::epaint::ImageDelta);
|
2021-12-26 20:21:28 +00:00
|
|
|
|
2022-01-15 12:59:52 +00:00
|
|
|
fn free_texture(&mut self, tex_id: egui::TextureId);
|
2021-01-16 00:30:00 +00:00
|
|
|
|
|
|
|
fn debug_info(&self) -> String;
|
|
|
|
|
|
|
|
/// id of the canvas html element containing the rendering
|
|
|
|
fn canvas_id(&self) -> &str;
|
|
|
|
|
2021-01-25 20:43:17 +00:00
|
|
|
fn clear(&mut self, clear_color: egui::Rgba);
|
2021-01-16 00:30:00 +00:00
|
|
|
|
2021-01-25 20:43:17 +00:00
|
|
|
fn paint_meshes(
|
|
|
|
&mut self,
|
|
|
|
clipped_meshes: Vec<egui::ClippedMesh>,
|
|
|
|
pixels_per_point: f32,
|
|
|
|
) -> Result<(), JsValue>;
|
2021-11-03 18:17:07 +00:00
|
|
|
|
|
|
|
fn name(&self) -> &'static str;
|
2022-02-21 20:49:52 +00:00
|
|
|
|
|
|
|
fn paint_and_update_textures(
|
|
|
|
&mut self,
|
|
|
|
clipped_meshes: Vec<egui::ClippedMesh>,
|
|
|
|
pixels_per_point: f32,
|
|
|
|
textures_delta: &egui::TexturesDelta,
|
|
|
|
) -> Result<(), JsValue> {
|
|
|
|
for (id, image_delta) in &textures_delta.set {
|
|
|
|
self.set_texture(*id, image_delta);
|
|
|
|
}
|
|
|
|
|
|
|
|
self.paint_meshes(clipped_meshes, pixels_per_point)?;
|
|
|
|
|
|
|
|
for &id in &textures_delta.free {
|
|
|
|
self.free_texture(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
2021-01-16 00:30:00 +00:00
|
|
|
}
|