Minor cleanup following https://github.com/emilk/egui/pull/999
This commit is contained in:
parent
f919b0cc05
commit
cda4c8ba13
6 changed files with 14 additions and 13 deletions
|
@ -25,8 +25,8 @@ pub struct Painter {
|
||||||
/// Index is the same as in [`egui::TextureId::User`].
|
/// Index is the same as in [`egui::TextureId::User`].
|
||||||
user_textures: HashMap<u64, Rc<SrgbTexture2d>>,
|
user_textures: HashMap<u64, Rc<SrgbTexture2d>>,
|
||||||
|
|
||||||
// TODO: 128-bit texture space?
|
#[cfg(feature = "epi")]
|
||||||
next_native_tex_id: u64,
|
next_native_tex_id: u64, // TODO: 128-bit texture space?
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Painter {
|
impl Painter {
|
||||||
|
@ -57,6 +57,7 @@ impl Painter {
|
||||||
egui_texture: None,
|
egui_texture: None,
|
||||||
egui_texture_version: None,
|
egui_texture_version: None,
|
||||||
user_textures: Default::default(),
|
user_textures: Default::default(),
|
||||||
|
#[cfg(feature = "epi")]
|
||||||
next_native_tex_id: 1 << 32,
|
next_native_tex_id: 1 << 32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,6 +223,7 @@ impl Painter {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[cfg(feature = "epi")]
|
||||||
pub fn set_texture(
|
pub fn set_texture(
|
||||||
&mut self,
|
&mut self,
|
||||||
facade: &dyn glium::backend::Facade,
|
facade: &dyn glium::backend::Facade,
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#![allow(unsafe_code)]
|
#![allow(unsafe_code)]
|
||||||
use glow::HasContext;
|
use glow::HasContext;
|
||||||
use std::option::Option::Some;
|
use std::option::Option::Some;
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
use wasm_bindgen::JsValue;
|
|
||||||
|
|
||||||
pub(crate) fn srgbtexture2d(
|
pub(crate) fn srgbtexture2d(
|
||||||
gl: &glow::Context,
|
gl: &glow::Context,
|
||||||
|
|
|
@ -41,8 +41,10 @@ pub struct Painter {
|
||||||
|
|
||||||
/// Index is the same as in [`egui::TextureId::User`].
|
/// Index is the same as in [`egui::TextureId::User`].
|
||||||
user_textures: HashMap<u64, glow::Texture>,
|
user_textures: HashMap<u64, glow::Texture>,
|
||||||
// TODO: 128-bit texture space?
|
|
||||||
next_native_tex_id: u64,
|
#[cfg(feature = "epi")]
|
||||||
|
next_native_tex_id: u64, // TODO: 128-bit texture space?
|
||||||
|
|
||||||
/// Stores outdated OpenGL textures that are yet to be deleted
|
/// Stores outdated OpenGL textures that are yet to be deleted
|
||||||
textures_to_destroy: Vec<glow::Texture>,
|
textures_to_destroy: Vec<glow::Texture>,
|
||||||
|
|
||||||
|
@ -192,6 +194,7 @@ impl Painter {
|
||||||
vertex_buffer,
|
vertex_buffer,
|
||||||
element_array_buffer,
|
element_array_buffer,
|
||||||
user_textures: Default::default(),
|
user_textures: Default::default(),
|
||||||
|
#[cfg(feature = "epi")]
|
||||||
next_native_tex_id: 1 << 32,
|
next_native_tex_id: 1 << 32,
|
||||||
textures_to_destroy: Vec::new(),
|
textures_to_destroy: Vec::new(),
|
||||||
destroyed: false,
|
destroyed: false,
|
||||||
|
@ -386,6 +389,7 @@ impl Painter {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[cfg(feature = "epi")]
|
||||||
pub fn set_texture(&mut self, gl: &glow::Context, tex_id: u64, image: &epi::Image) {
|
pub fn set_texture(&mut self, gl: &glow::Context, tex_id: u64, image: &epi::Image) {
|
||||||
self.assert_not_destroyed();
|
self.assert_not_destroyed();
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,7 @@ pub struct WebGlPainter {
|
||||||
/// Index is the same as in [`egui::TextureId::User`].
|
/// Index is the same as in [`egui::TextureId::User`].
|
||||||
user_textures: HashMap<u64, WebGlTexture>,
|
user_textures: HashMap<u64, WebGlTexture>,
|
||||||
|
|
||||||
// TODO: 128-bit texture space?
|
next_native_tex_id: u64, // TODO: 128-bit texture space?
|
||||||
next_native_tex_id: u64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebGlPainter {
|
impl WebGlPainter {
|
||||||
|
|
|
@ -34,8 +34,7 @@ pub struct WebGl2Painter {
|
||||||
/// Index is the same as in [`egui::TextureId::User`].
|
/// Index is the same as in [`egui::TextureId::User`].
|
||||||
user_textures: HashMap<u64, WebGlTexture>,
|
user_textures: HashMap<u64, WebGlTexture>,
|
||||||
|
|
||||||
// TODO: 128-bit texture space?
|
next_native_tex_id: u64, // TODO: 128-bit texture space?
|
||||||
next_native_tex_id: u64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebGl2Painter {
|
impl WebGl2Painter {
|
||||||
|
|
|
@ -419,11 +419,10 @@ pub trait NativeTexture {
|
||||||
/// The native texture type.
|
/// The native texture type.
|
||||||
type Texture;
|
type Texture;
|
||||||
|
|
||||||
/// Bind native texture to egui texture
|
/// Bind native texture to an egui texture id.
|
||||||
fn register_native_texture(&mut self, native: Self::Texture) -> egui::TextureId;
|
fn register_native_texture(&mut self, native: Self::Texture) -> egui::TextureId;
|
||||||
|
|
||||||
/// Change id's actual pointing texture
|
/// Change what texture the given id refers to.
|
||||||
/// only for user texture
|
|
||||||
fn replace_native_texture(&mut self, id: egui::TextureId, replacing: Self::Texture);
|
fn replace_native_texture(&mut self, id: egui::TextureId, replacing: Self::Texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue