Update wgpu and cosmic-text

This commit is contained in:
Héctor Ramón Jiménez 2023-04-08 04:47:05 +02:00
parent 6fae8bf6cb
commit c0431aedd3
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
8 changed files with 39 additions and 41 deletions

View file

@ -13,7 +13,7 @@ image = ["iced_graphics/image"]
svg = ["resvg"]
[dependencies]
wgpu = "0.14"
wgpu = "0.15"
raw-window-handle = "0.5"
log = "0.4"
guillotiere = "0.6"
@ -44,7 +44,7 @@ path = "../graphics"
[dependencies.glyphon]
version = "0.2"
git = "https://github.com/hecrj/glyphon.git"
rev = "47050174841a4f58fc8d85c943a2117f72f19e8e"
rev = "6601deec1c7595f8fd5f83f929b2497104905400"
[dependencies.encase]
version = "0.3.0"

View file

@ -41,6 +41,7 @@ impl Atlas {
usage: wgpu::TextureUsages::COPY_DST
| wgpu::TextureUsages::COPY_SRC
| wgpu::TextureUsages::TEXTURE_BINDING,
view_formats: &[],
});
let texture_view = texture.create_view(&wgpu::TextureViewDescriptor {
@ -338,6 +339,7 @@ impl Atlas {
usage: wgpu::TextureUsages::COPY_DST
| wgpu::TextureUsages::COPY_SRC
| wgpu::TextureUsages::TEXTURE_BINDING,
view_formats: &[],
});
let amount_to_copy = self.layers.len() - amount;

View file

@ -58,8 +58,12 @@ impl Pipeline {
target_size: Size<u32>,
) -> bool {
if self.renderers.len() <= self.prepare_layer {
self.renderers
.push(glyphon::TextRenderer::new(device, queue));
self.renderers.push(glyphon::TextRenderer::new(
&mut self.atlas,
device,
Default::default(),
None,
));
}
let font_system = self.font_system.get_mut();
@ -359,14 +363,7 @@ impl Cache {
glyphon::Attrs::new()
.family(to_family(key.font.family))
.weight(to_weight(key.font.weight))
.stretch(to_stretch(key.font.stretch))
.monospaced(
key.font.monospaced
|| matches!(
key.font.family,
font::Family::Monospace
),
),
.stretch(to_stretch(key.font.stretch)),
);
let _ = entry.insert(buffer);

View file

@ -223,6 +223,7 @@ impl Targets {
dimension: wgpu::TextureDimension::D2,
format,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
view_formats: &[],
});
let resolve = device.create_texture(&wgpu::TextureDescriptor {
@ -234,6 +235,7 @@ impl Targets {
format,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT
| wgpu::TextureUsages::TEXTURE_BINDING,
view_formats: &[],
});
let attachment =

View file

@ -31,7 +31,10 @@ impl<Theme> Compositor<Theme> {
settings: Settings,
compatible_window: Option<&W>,
) -> Option<Self> {
let instance = wgpu::Instance::new(settings.internal_backend);
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: settings.internal_backend,
..Default::default()
});
log::info!("{:#?}", settings);
@ -46,7 +49,7 @@ impl<Theme> Compositor<Theme> {
#[allow(unsafe_code)]
let compatible_surface = compatible_window
.map(|window| unsafe { instance.create_surface(window) });
.and_then(|window| unsafe { instance.create_surface(window).ok() });
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
@ -63,7 +66,7 @@ impl<Theme> Compositor<Theme> {
log::info!("Selected: {:#?}", adapter.get_info());
let format = compatible_surface.as_ref().and_then(|surface| {
surface.get_supported_formats(&adapter).first().copied()
surface.get_capabilities(&adapter).formats.first().copied()
})?;
log::info!("Selected format: {:?}", format);
@ -207,7 +210,8 @@ impl<Theme> graphics::Compositor for Compositor<Theme> {
height: u32,
) -> wgpu::Surface {
#[allow(unsafe_code)]
let mut surface = unsafe { self.instance.create_surface(window) };
let mut surface = unsafe { self.instance.create_surface(window) }
.expect("Create surface");
self.configure_surface(&mut surface, width, height);
@ -229,6 +233,7 @@ impl<Theme> graphics::Compositor for Compositor<Theme> {
width,
height,
alpha_mode: wgpu::CompositeAlphaMode::Auto,
view_formats: vec![],
},
);
}