Support sharing Pipeline state between TextAtlas (#95)

* Support sharing `Pipeline` state between `TextAtlas`

* Keep using `Vec` for pipeline cache

* Use `OnceCell` to keep `Pipeline` private

* Revert "Use `OnceCell` to keep `Pipeline` private"

This reverts commit 4112732b1734a3bb6b915d2103e699ef549b77c1.

* Rename `Pipeline` type to `Cache`
This commit is contained in:
Héctor Ramón 2024-05-08 15:39:19 +02:00 committed by GitHub
parent 670140e2a1
commit 5aed9e1477
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 295 additions and 237 deletions

View file

@ -1,6 +1,6 @@
use glyphon::{
Attrs, Buffer, Color, Family, FontSystem, Metrics, Resolution, Shaping, SwashCache, TextArea,
TextAtlas, TextBounds, TextRenderer,
Attrs, Buffer, Cache, Color, Family, FontSystem, Metrics, Resolution, Shaping, SwashCache,
TextArea, TextAtlas, TextBounds, TextRenderer,
};
use wgpu::{
CommandEncoderDescriptor, CompositeAlphaMode, DeviceDescriptor, Features, Instance,
@ -71,8 +71,9 @@ async fn run() {
// Set up text renderer
let mut font_system = FontSystem::new();
let mut cache = SwashCache::new();
let mut atlas = TextAtlas::new(&device, &queue, swapchain_format);
let mut swash_cache = SwashCache::new();
let cache = Cache::new(&device);
let mut atlas = TextAtlas::new(&device, &queue, &cache, swapchain_format);
let mut text_renderer =
TextRenderer::new(&mut atlas, &device, MultisampleState::default(), None);
let mut buffer = Buffer::new(&mut font_system, Metrics::new(30.0, 42.0));
@ -122,7 +123,7 @@ async fn run() {
},
default_color: Color::rgb(255, 255, 255),
}],
&mut cache,
&mut swash_cache,
)
.unwrap();