mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Partial font texture update (#1149)
This commit is contained in:
@@ -70,8 +70,8 @@ pub fn run(app: Box<dyn epi::App>, native_options: &epi::NativeOptions) -> ! {
|
||||
integration.update(display.gl_window().window());
|
||||
let clipped_meshes = integration.egui_ctx.tessellate(shapes);
|
||||
|
||||
for (id, image) in textures_delta.set {
|
||||
painter.set_texture(&display, id, &image);
|
||||
for (id, image_delta) in textures_delta.set {
|
||||
painter.set_texture(&display, id, &image_delta);
|
||||
}
|
||||
|
||||
// paint:
|
||||
|
||||
@@ -155,8 +155,8 @@ impl EguiGlium {
|
||||
let shapes = std::mem::take(&mut self.shapes);
|
||||
let mut textures_delta = std::mem::take(&mut self.textures_delta);
|
||||
|
||||
for (id, image) in textures_delta.set {
|
||||
self.painter.set_texture(display, id, &image);
|
||||
for (id, image_delta) in textures_delta.set {
|
||||
self.painter.set_texture(display, id, &image_delta);
|
||||
}
|
||||
|
||||
let clipped_meshes = self.egui_ctx.tessellate(shapes);
|
||||
|
||||
@@ -185,9 +185,9 @@ impl Painter {
|
||||
&mut self,
|
||||
facade: &dyn glium::backend::Facade,
|
||||
tex_id: egui::TextureId,
|
||||
image: &egui::ImageData,
|
||||
delta: &egui::epaint::ImageDelta,
|
||||
) {
|
||||
let pixels: Vec<(u8, u8, u8, u8)> = match image {
|
||||
let pixels: Vec<(u8, u8, u8, u8)> = match &delta.image {
|
||||
egui::ImageData::Color(image) => {
|
||||
assert_eq!(
|
||||
image.width() * image.height(),
|
||||
@@ -206,15 +206,29 @@ impl Painter {
|
||||
};
|
||||
let glium_image = glium::texture::RawImage2d {
|
||||
data: std::borrow::Cow::Owned(pixels),
|
||||
width: image.width() as _,
|
||||
height: image.height() as _,
|
||||
width: delta.image.width() as _,
|
||||
height: delta.image.height() as _,
|
||||
format: glium::texture::ClientFormat::U8U8U8U8,
|
||||
};
|
||||
let format = texture::SrgbFormat::U8U8U8U8;
|
||||
let mipmaps = texture::MipmapsOption::NoMipmap;
|
||||
let gl_texture = SrgbTexture2d::with_format(facade, glium_image, format, mipmaps).unwrap();
|
||||
|
||||
self.textures.insert(tex_id, gl_texture.into());
|
||||
if let Some(pos) = delta.pos {
|
||||
// update a sub-region
|
||||
if let Some(gl_texture) = self.textures.get(&tex_id) {
|
||||
let rect = glium::Rect {
|
||||
left: pos[0] as _,
|
||||
bottom: pos[1] as _,
|
||||
width: glium_image.width,
|
||||
height: glium_image.height,
|
||||
};
|
||||
gl_texture.main_level().write(rect, glium_image);
|
||||
}
|
||||
} else {
|
||||
let gl_texture =
|
||||
SrgbTexture2d::with_format(facade, glium_image, format, mipmaps).unwrap();
|
||||
self.textures.insert(tex_id, gl_texture.into());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn free_texture(&mut self, tex_id: egui::TextureId) {
|
||||
|
||||
Reference in New Issue
Block a user