1
0
Fork 0
forked from wry/wry

text: re-use textures if possible

This commit is contained in:
Julian Orth 2023-11-05 15:54:19 +01:00
parent bf90204db6
commit a04870388f
10 changed files with 153 additions and 45 deletions

View file

@ -3,13 +3,12 @@ use {
client::Client,
cursor::KnownCursor,
fixed::Fixed,
gfx_api::GfxTexture,
ifs::wl_seat::{NodeSeatState, WlSeatGlobal},
rect::Rect,
renderer::Renderer,
scale::Scale,
state::State,
text,
text::{self, TextTexture},
tree::{
Direction, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData,
ToplevelNode,
@ -25,7 +24,7 @@ pub struct PlaceholderNode {
id: PlaceholderNodeId,
toplevel: ToplevelData,
destroyed: Cell<bool>,
pub textures: SmallMap<Scale, Rc<dyn GfxTexture>, 2>,
pub textures: SmallMap<Scale, TextTexture, 2>,
}
impl PlaceholderNode {
@ -47,11 +46,11 @@ impl PlaceholderNode {
}
pub fn update_texture(&self) {
self.textures.clear();
if let Some(ctx) = self.toplevel.state.render_ctx.get() {
let scales = self.toplevel.state.scales.lock();
let rect = self.toplevel.pos.get();
for (scale, _) in scales.iter() {
let old_tex = self.textures.remove(scale);
let mut width = rect.width();
let mut height = rect.height();
if *scale != 1 {
@ -63,6 +62,7 @@ impl PlaceholderNode {
let font = format!("monospace {}", width / 10);
match text::render_fitting(
&ctx,
old_tex,
Some(height),
&font,
"Fullscreen",