diff options
| author | 2023-04-08 04:47:05 +0200 | |
|---|---|---|
| committer | 2023-04-08 04:47:05 +0200 | |
| commit | c0431aedd3bbef4161456f2fa5f29866e8f17fc5 (patch) | |
| tree | 37f5af689b91818e04f3bc58e523aa24858f056a | |
| parent | 6fae8bf6cbe7155bcee42eaeba68e31564df057c (diff) | |
| download | iced-c0431aedd3bbef4161456f2fa5f29866e8f17fc5.tar.gz iced-c0431aedd3bbef4161456f2fa5f29866e8f17fc5.tar.bz2 iced-c0431aedd3bbef4161456f2fa5f29866e8f17fc5.zip | |
Update `wgpu` and `cosmic-text`
| -rw-r--r-- | examples/integration/src/main.rs | 27 | ||||
| -rw-r--r-- | tiny_skia/Cargo.toml | 6 | ||||
| -rw-r--r-- | tiny_skia/src/text.rs | 9 | ||||
| -rw-r--r-- | wgpu/Cargo.toml | 4 | ||||
| -rw-r--r-- | wgpu/src/image/atlas.rs | 2 | ||||
| -rw-r--r-- | wgpu/src/text.rs | 17 | ||||
| -rw-r--r-- | wgpu/src/triangle/msaa.rs | 2 | ||||
| -rw-r--r-- | wgpu/src/window/compositor.rs | 13 | 
8 files changed, 39 insertions, 41 deletions
| diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs index 9707eda7..949a726a 100644 --- a/examples/integration/src/main.rs +++ b/examples/integration/src/main.rs @@ -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![],                          },                      ); diff --git a/tiny_skia/Cargo.toml b/tiny_skia/Cargo.toml index 349f6903..7a5f5b17 100644 --- a/tiny_skia/Cargo.toml +++ b/tiny_skia/Cargo.toml @@ -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 diff --git a/tiny_skia/src/text.rs b/tiny_skia/src/text.rs index 865132b4..e0e893bd 100644 --- a/tiny_skia/src/text.rs +++ b/tiny_skia/src/text.rs @@ -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); diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 3aef4ff4..36c891bb 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -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" diff --git a/wgpu/src/image/atlas.rs b/wgpu/src/image/atlas.rs index c00b8cef..39b6e5d2 100644 --- a/wgpu/src/image/atlas.rs +++ b/wgpu/src/image/atlas.rs @@ -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; diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index dd674279..f01e0b42 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -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); diff --git a/wgpu/src/triangle/msaa.rs b/wgpu/src/triangle/msaa.rs index 7144125c..14522c89 100644 --- a/wgpu/src/triangle/msaa.rs +++ b/wgpu/src/triangle/msaa.rs @@ -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 = diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index a67ac3c0..025cd43a 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -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![],              },          );      } | 
