cache logo svg

This commit is contained in:
Dongdong Zhou 2021-10-12 10:05:05 +01:00
parent 9d3005d9d4
commit 43e5266562
2 changed files with 13 additions and 3 deletions

View File

@ -15,7 +15,7 @@
use crate::signature::SignatureState;
use crate::split::LapceSplitNew;
use crate::state::LapceWorkspace;
use crate::svg::{file_svg_new, get_svg};
use crate::svg::{file_svg_new, get_svg, logo_svg};
use crate::theme::OldLapceTheme;
use crate::{buffer::get_word_property, state::LapceFocus};
use crate::{buffer::matching_char, data::LapceEditorViewData};
@ -4166,7 +4166,7 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
);
}
LapceEditorViewContent::None => {
let svg = Svg::from_str(LOGO).unwrap();
let svg = logo_svg();
let size = ctx.size();
let svg_size = 100.0;
let rect = Size::ZERO

View File

@ -13,7 +13,7 @@
use parking_lot::Mutex;
use usvg;
use crate::config::Config;
use crate::config::{Config, LOGO};
pub const ICONS_DIR: Dir = include_dir!("../icons");
lazy_static! {
@ -41,6 +41,16 @@ fn get_svg(&self, name: &str) -> Option<Svg> {
}
}
pub fn logo_svg() -> Svg {
let name = "lapce_logo";
let mut svgs = SVG_STORE.svgs.lock();
if !svgs.contains_key(name) {
let svg = Svg::from_str(LOGO).ok();
svgs.insert(name.to_string(), svg);
}
svgs.get(name).map(|s| s.clone()).unwrap().unwrap()
}
pub fn get_svg(name: &str) -> Option<Svg> {
SVG_STORE.get_svg(name)
}