Compare commits

..

No commits in common. "0f93d0ca7189ea3beed5855f65f849d9d38d5200" and "5bac9321082112ae20650d59cc748103c2456106" have entirely different histories.

4 changed files with 14 additions and 8 deletions

View file

@ -1,4 +1,4 @@
use crate::{IfModified, text::TextRenderer};
use crate::IfModified;
use std::borrow::Cow;
use glam::{Vec2, Vec4, vec2};
@ -49,13 +49,13 @@ pub struct UiVertex {
pub position: Vec2,
pub color: Vec4,
pub uv: Vec2,
pub bind_texture: Option<BindTexture>,
}
#[derive(Default)]
pub struct UiDrawCall {
pub vertices: Vec<UiVertex>,
pub indices: Vec<u32>,
pub bind_texture: Option<BindTexture>,
}
#[derive(Default)]
@ -64,7 +64,7 @@ pub struct UiDrawPlan {
}
impl UiDrawPlan {
pub fn build(calls: &UiDrawCommands, tr: &mut TextRenderer) -> Self {
pub fn build(calls: &UiDrawCommands) -> Self {
let mut call = UiDrawCall::default();
for command in &calls.commands {
match command {
@ -76,21 +76,25 @@ impl UiDrawPlan {
position: *position,
color: *color,
uv: vec2(0.0, 0.0),
bind_texture: None,
},
UiVertex {
position: *position + Vec2::new(size.x, 0.0),
color: *color,
uv: vec2(1.0, 0.0),
bind_texture: None,
},
UiVertex {
position: *position + *size,
color: *color,
uv: vec2(1.0, 1.0),
bind_texture: None,
},
UiVertex {
position: *position + Vec2::new(0.0, size.y),
color: *color,
uv: vec2(0.0, 1.0),
bind_texture: None,
},
]);
},

View file

@ -72,7 +72,7 @@ impl KubiUi {
if self.draw_commands.commands == self.prev_draw_commands.commands {
return
}
self.draw_plan = UiDrawPlan::build(&self.draw_commands, &mut self.text_renderer);
self.draw_plan = UiDrawPlan::build(&self.draw_commands);
self.draw_plan_modified = true;
}

View file

@ -1,12 +1,12 @@
use std::sync::Arc;
mod font;
mod texman;
mod ftm;
use font::FontManager;
pub use font::FontHandle;
use texman::FontTextureManager;
pub use texman::{FontTextureInfo, GlyphCacheEntry};
use ftm::FontTextureManager;
pub use ftm::{FontTextureInfo, GlyphCacheEntry};
pub struct TextRenderer {
fm: FontManager,

View file

@ -1,5 +1,5 @@
use std::sync::Arc;
use fontdue::Metrics;
use fontdue::{Font, Metrics};
use glam::{IVec2, UVec2, uvec2, ivec2};
use hashbrown::HashMap;
use rect_packer::DensePacker;
@ -8,6 +8,8 @@ use crate::IfModified;
use super::font::{FontHandle, FontManager};
#[derive(PartialEq, Eq, Hash)]
struct GlyphCacheKey {
font_index: usize,