cached image loading

This commit is contained in:
galister
2025-12-27 22:06:28 +09:00
parent f4545241df
commit 8747487beb
8 changed files with 126 additions and 41 deletions

View File

@@ -4,7 +4,7 @@ use wgui::{
globals::WguiGlobals,
i18n::Translation,
layout::{Layout, WidgetID},
renderer_vk::text::custom_glyph::{CustomGlyphContent, CustomGlyphData},
renderer_vk::text::custom_glyph::CustomGlyphData,
taffy::{self, prelude::length},
widget::{
label::{WidgetLabel, WidgetLabelParams},
@@ -62,7 +62,7 @@ pub fn mount_simple_sprite_square(
layout.add_child(
parent_id,
WidgetSprite::create(WidgetSpriteParams {
glyph_data: Some(CustomGlyphData::new(CustomGlyphContent::from_assets(globals, path)?)),
glyph_data: Some(CustomGlyphData::from_assets(globals, path)?),
..Default::default()
}),
taffy::Style {

View File

@@ -14,7 +14,7 @@ use wgui::{
parser::{Fetchable, ParseDocumentParams, ParserState},
renderer_vk::text::{
FontWeight, HorizontalAlign, TextShadow, TextStyle,
custom_glyph::{CustomGlyphContent, CustomGlyphData},
custom_glyph::{ CustomGlyphData},
},
taffy::{
self, AlignItems, AlignSelf, JustifyContent, JustifySelf,
@@ -413,10 +413,10 @@ impl View {
fn get_placeholder_image(&mut self) -> anyhow::Result<&CustomGlyphData> {
if self.img_placeholder.is_none() {
let c = CustomGlyphData::new(CustomGlyphContent::from_assets(
let c = CustomGlyphData::from_assets(
&self.globals,
AssetPath::BuiltIn("dashboard/placeholder_cover.png"),
)?);
)?;
self.img_placeholder = Some(c);
}
@@ -515,7 +515,8 @@ impl View {
return Ok(());
};
let glyph = match CustomGlyphContent::from_bin_raster(&cover_art.compressed_image_data) {
let path = format!("app:{app_id:?}");
let glyph = match CustomGlyphData::from_bytes_raster(&self.globals, &path ,&cover_art.compressed_image_data) {
Ok(c) => c,
Err(e) => {
log::warn!(
@@ -526,7 +527,7 @@ impl View {
return Ok(());
}
};
View::mount_image(layout, cell, &CustomGlyphData::new(glyph))?;
View::mount_image(layout, cell, &glyph)?;
}
Ok(())