Update wgpu and cosmic-text
This commit is contained in:
parent
6fae8bf6cb
commit
c0431aedd3
8 changed files with 39 additions and 41 deletions
|
|
@ -26,18 +26,16 @@ use web_sys::HtmlCanvasElement;
|
|||
#[cfg(target_arch = "wasm32")]
|
||||
use winit::platform::web::WindowBuilderExtWebSys;
|
||||
|
||||
pub fn main() {
|
||||
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let canvas_element = {
|
||||
console_log::init_with_level(log::Level::Debug)
|
||||
.expect("could not initialize logger");
|
||||
console_log::init_with_level(log::Level::Debug)?;
|
||||
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
|
||||
|
||||
web_sys::window()
|
||||
.and_then(|win| win.document())
|
||||
.and_then(|doc| doc.get_element_by_id("iced_canvas"))
|
||||
.and_then(|element| element.dyn_into::<HtmlCanvasElement>().ok())
|
||||
.expect("Canvas with id `iced_canvas` is missing")
|
||||
.and_then(|element| element.dyn_into::<HtmlCanvasElement>().ok())?
|
||||
};
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
env_logger::init();
|
||||
|
|
@ -48,8 +46,7 @@ pub fn main() {
|
|||
#[cfg(target_arch = "wasm32")]
|
||||
let window = winit::window::WindowBuilder::new()
|
||||
.with_canvas(Some(canvas_element))
|
||||
.build(&event_loop)
|
||||
.expect("Failed to build winit window");
|
||||
.build(&event_loop)?;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let window = winit::window::Window::new(&event_loop).unwrap();
|
||||
|
|
@ -73,8 +70,11 @@ pub fn main() {
|
|||
let backend =
|
||||
wgpu::util::backend_bits_from_env().unwrap_or(default_backend);
|
||||
|
||||
let instance = wgpu::Instance::new(backend);
|
||||
let surface = unsafe { instance.create_surface(&window) };
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
backends: backend,
|
||||
..Default::default()
|
||||
});
|
||||
let surface = unsafe { instance.create_surface(&window) }?;
|
||||
|
||||
let (format, (device, queue)) =
|
||||
futures::futures::executor::block_on(async {
|
||||
|
|
@ -84,7 +84,7 @@ pub fn main() {
|
|||
Some(&surface),
|
||||
)
|
||||
.await
|
||||
.expect("No suitable GPU adapters found on the system!");
|
||||
.expect("Create adapter");
|
||||
|
||||
let adapter_features = adapter.features();
|
||||
|
||||
|
|
@ -97,7 +97,8 @@ pub fn main() {
|
|||
|
||||
(
|
||||
surface
|
||||
.get_supported_formats(&adapter)
|
||||
.get_capabilities(&adapter)
|
||||
.formats
|
||||
.first()
|
||||
.copied()
|
||||
.expect("Get preferred format"),
|
||||
|
|
@ -125,6 +126,7 @@ pub fn main() {
|
|||
height: physical_size.height,
|
||||
present_mode: wgpu::PresentMode::AutoVsync,
|
||||
alpha_mode: wgpu::CompositeAlphaMode::Auto,
|
||||
view_formats: vec![],
|
||||
},
|
||||
);
|
||||
|
||||
|
|
@ -220,7 +222,8 @@ pub fn main() {
|
|||
width: size.width,
|
||||
height: size.height,
|
||||
present_mode: wgpu::PresentMode::AutoVsync,
|
||||
alpha_mode: wgpu::CompositeAlphaMode::Auto
|
||||
alpha_mode: wgpu::CompositeAlphaMode::Auto,
|
||||
view_formats: vec![],
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ geometry = ["iced_graphics/geometry"]
|
|||
raw-window-handle = "0.5"
|
||||
softbuffer = "0.2"
|
||||
tiny-skia = "0.8"
|
||||
cosmic-text = "0.8"
|
||||
bytemuck = "1"
|
||||
rustc-hash = "1.1"
|
||||
kurbo = "0.9"
|
||||
|
|
@ -22,11 +23,6 @@ version = "0.7"
|
|||
path = "../graphics"
|
||||
features = ["tiny-skia"]
|
||||
|
||||
[dependencies.cosmic-text]
|
||||
features = ["std", "swash"]
|
||||
git = "https://github.com/pop-os/cosmic-text"
|
||||
rev = "e788c175ec31094b04dcacbc0537dba4433afcfc"
|
||||
|
||||
[dependencies.twox-hash]
|
||||
version = "1.6"
|
||||
default-features = false
|
||||
|
|
|
|||
|
|
@ -385,14 +385,7 @@ impl Cache {
|
|||
cosmic_text::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);
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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![],
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue