1
0
Fork 0
forked from wry/wry

gfx: add ShmGfxTexture

This commit is contained in:
Julian Orth 2024-09-07 20:22:30 +02:00
parent ed4ef3c8e7
commit c968024905
10 changed files with 51 additions and 22 deletions

View file

@ -1,7 +1,7 @@
use {
crate::{
format::ARGB8888,
gfx_api::{GfxContext, GfxError, GfxTexture},
gfx_api::{GfxContext, GfxError, GfxTexture, ShmGfxTexture},
pango::{
consts::{
CAIRO_FORMAT_ARGB32, CAIRO_OPERATOR_SOURCE, PANGO_ELLIPSIZE_END, PANGO_SCALE,
@ -73,6 +73,7 @@ impl<'a> Config<'a> {
#[derive(Clone)]
pub struct TextTexture {
config: Rc<Config<'static>>,
shm_texture: Rc<dyn ShmGfxTexture>,
pub texture: Rc<dyn GfxTexture>,
}
@ -210,7 +211,7 @@ fn render2(
Ok(d) => d,
Err(e) => return Err(TextError::ImageData(e)),
};
let old = old.map(|o| o.texture);
let old = old.map(|o| o.shm_texture);
match ctx.clone().shmem_texture(
old,
bytes,
@ -222,7 +223,8 @@ fn render2(
) {
Ok(t) => Ok(TextTexture {
config: Rc::new(config.to_static()),
texture: t,
texture: t.clone().into_texture(),
shm_texture: t,
}),
Err(e) => Err(TextError::RenderError(e)),
}