Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions examples/servo/src/delegate.rs

This file was deleted.

85 changes: 41 additions & 44 deletions examples/servo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: MIT

mod adapter;
mod delegate;
mod on_events;
mod rendering_context;
mod servo_util;
mod waker;
pub mod webview;

#[cfg(target_os = "linux")]
mod gl_bindings {
Expand All @@ -17,54 +12,21 @@ mod gl_bindings {

use slint::ComponentHandle;

use crate::servo_util::init_servo;
#[cfg(not(target_os = "android"))]
use crate::webview::WebView;

slint::include_modules!();

pub fn main() {
#[cfg(not(target_os = "android"))]
let (device, queue) = {
let backends = wgpu::Backends::from_env().unwrap_or_default();

let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
backends,
flags: Default::default(),
backend_options: Default::default(),
memory_budget_thresholds: Default::default(),
});

let adapter = spin_on::spin_on(async {
instance
.request_adapter(&Default::default())
.await
.expect("Failed to find an appropriate WGPU adapter")
});

let (device, queue) = spin_on::spin_on(async {
adapter.request_device(&Default::default()).await.expect("Failed to create WGPU device")
});

slint::BackendSelector::new()
.require_wgpu_27(slint::wgpu_27::WGPUConfiguration::Manual {
instance,
adapter,
device: device.clone(),
queue: queue.clone()
})
.select()
.expect("Failed to create Slint backend with WGPU based renderer - ensure your system supports WGPU");

(device, queue)
};
let (device, queue) = setup_wgpu();

let app = MyApp::new().expect("Failed to create Slint application - check UI resources");

let url = "https://slint.dev";

#[cfg(not(target_os = "android"))]
let _adapter = init_servo(
WebView::new(
app.clone_strong(),
url.into(),
"https://slint.dev".into(),
#[cfg(not(target_os = "android"))]
device,
#[cfg(not(target_os = "android"))]
Expand All @@ -80,3 +42,38 @@ pub fn android_main(android_app: slint::android::AndroidApp) {
slint::android::init(android_app).unwrap();
main();
}

#[cfg(not(target_os = "android"))]
fn setup_wgpu() -> (wgpu::Device, wgpu::Queue) {
let backends = wgpu::Backends::from_env().unwrap_or_default();

let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
backends,
flags: Default::default(),
backend_options: Default::default(),
memory_budget_thresholds: Default::default(),
});

let adapter = spin_on::spin_on(async {
instance
.request_adapter(&Default::default())
.await
.expect("Failed to find an appropriate WGPU adapter")
});

let (device, queue) = spin_on::spin_on(async {
adapter.request_device(&Default::default()).await.expect("Failed to create WGPU device")
});

slint::BackendSelector::new()
.require_wgpu_27(slint::wgpu_27::WGPUConfiguration::Manual {
instance,
adapter,
device: device.clone(),
queue: queue.clone()
})
.select()
.expect("Failed to create Slint backend with WGPU based renderer - ensure your system supports WGPU");

(device, queue)
}
194 changes: 0 additions & 194 deletions examples/servo/src/on_events.rs

This file was deleted.

Loading
Loading