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
49 changes: 16 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ members = [
"proc-macros",
]
default-members = [
"desktop",
"desktop/wrapper",
"editor",
"frontend/wasm",
"libraries/dyn-any",
Expand Down
8 changes: 4 additions & 4 deletions desktop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ gpu = ["graphite-desktop-wrapper/gpu"]
accelerated_paint = ["accelerated_paint_dmabuf", "accelerated_paint_d3d11", "accelerated_paint_iosurface"]
accelerated_paint_dmabuf = ["libc", "ash"]
accelerated_paint_d3d11 = ["windows", "ash"]
accelerated_paint_iosurface = ["objc2-io-surface", "objc2-metal", "core-foundation"]
accelerated_paint_iosurface = ["metal", "objc", "core-foundation"]

[dependencies]
# Local dependencies
Expand Down Expand Up @@ -66,9 +66,9 @@ windows = { version = "0.58.0", features = [

# macOS-specific dependencies
[target.'cfg(target_os = "macos")'.dependencies]
objc2-io-surface = { version = "0.3", optional = true }
objc2-metal = { version = "0.3", optional = true }
core-foundation = { version = "0.9", optional = true }
metal = { version = "0.31.0", optional = true }
objc = { version = "0.2", optional = true }
core-foundation = { version = "0.10", optional = true }

# Linux-specific dependencies
[target.'cfg(target_os = "linux")'.dependencies]
Expand Down
1 change: 1 addition & 0 deletions desktop/src/cef/context.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(not(target_os = "macos"))]
mod multithreaded;
mod singlethreaded;

Expand Down
40 changes: 30 additions & 10 deletions desktop/src/cef/context/builder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::PathBuf;
use std::path::{Path, PathBuf};

use cef::args::Args;
use cef::sys::{CEF_API_VERSION_LAST, cef_resultcode_t};
Expand All @@ -25,12 +25,23 @@ unsafe impl<H: CefEventHandler> Send for CefContextBuilder<H> {}

impl<H: CefEventHandler> CefContextBuilder<H> {
pub(crate) fn new() -> Self {
Self::new_inner(false)
}

pub(crate) fn new_helper() -> Self {
Self::new_inner(true)
}

fn new_inner(helper: bool) -> Self {
#[cfg(target_os = "macos")]
let _loader = {
let loader = library_loader::LibraryLoader::new(&std::env::current_exe().unwrap(), false);
let loader = cef::library_loader::LibraryLoader::new(&std::env::current_exe().unwrap(), helper);
assert!(loader.load());
loader
};
#[cfg(not(target_os = "macos"))]
let _ = helper;

let _ = api_hash(CEF_API_VERSION_LAST, 0);

let args = Args::new();
Expand Down Expand Up @@ -62,17 +73,29 @@ impl<H: CefEventHandler> CefContextBuilder<H> {
}
}

fn common_settings(instance_dir: &Path) -> Settings {
Settings {
windowless_rendering_enabled: 1,
root_cache_path: instance_dir.to_str().map(CefString::from).unwrap(),
cache_path: CefString::from(""),
disable_signal_handlers: 1,
..Default::default()
}
}

#[cfg(target_os = "macos")]
pub(crate) fn initialize(self, event_handler: H, disable_gpu_acceleration: bool) -> Result<impl CefContext, InitError> {
let instance_dir = create_instance_dir();

let exe = std::env::current_exe().expect("cannot get current exe path");
let app_root = exe.parent().and_then(|p| p.parent()).expect("bad path structure").parent().expect("bad path structure");

let settings = Settings {
windowless_rendering_enabled: 1,
main_bundle_path: CefString::from(app_root.to_str().unwrap()),
multi_threaded_message_loop: 0,
external_message_pump: 1,
root_cache_path: instance_dir.to_str().map(CefString::from).unwrap(),
cache_path: CefString::from(""),
..Default::default()
no_sandbox: 1, // GPU helper crashes when running with sandbox
..Self::common_settings(&instance_dir)
};

self.initialize_inner(&event_handler, settings)?;
Expand All @@ -85,11 +108,8 @@ impl<H: CefEventHandler> CefContextBuilder<H> {
let instance_dir = create_instance_dir();

let settings = Settings {
windowless_rendering_enabled: 1,
multi_threaded_message_loop: 1,
root_cache_path: instance_dir.to_str().map(CefString::from).unwrap(),
cache_path: CefString::from(""),
..Default::default()
..Self::common_settings(&instance_dir)
};

self.initialize_inner(&event_handler, settings)?;
Expand Down
2 changes: 2 additions & 0 deletions desktop/src/cef/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ mod scheme_handler_factory;
mod display_handler;

pub(super) mod render_handler;

#[cfg(not(target_os = "macos"))]
pub(super) mod task;

pub(super) use browser_process_app::BrowserProcessAppImpl;
Expand Down
6 changes: 6 additions & 0 deletions desktop/src/cef/internal/browser_process_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ impl<H: CefEventHandler + Clone> ImplApp for BrowserProcessAppImpl<H> {
cmd.append_switch_with_value(Some(&CefString::from("ozone-platform")), Some(&CefString::from("wayland")));
}
}

#[cfg(target_os = "macos")]
{
// Hide user prompt asking for keychain access
cmd.append_switch(Some(&CefString::from("use-mock-keychain")));
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion desktop/src/cef/internal/display_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ impl<H: CefEventHandler> DisplayHandlerImpl<H> {
}
}

#[cfg(not(target_os = "macos"))]
type CefCursorHandle = cef::CursorHandle;
#[cfg(target_os = "macos")]
type CefCursorHandle = *mut u8;

impl<H: CefEventHandler> ImplDisplayHandler for DisplayHandlerImpl<H> {
fn on_cursor_change(&self, _browser: Option<&mut cef::Browser>, _cursor: cef::CursorHandle, cursor_type: cef::CursorType, _custom_cursor_info: Option<&cef::CursorInfo>) -> ::std::os::raw::c_int {
fn on_cursor_change(&self, _browser: Option<&mut cef::Browser>, _cursor: CefCursorHandle, cursor_type: cef::CursorType, _custom_cursor_info: Option<&cef::CursorInfo>) -> ::std::os::raw::c_int {
let cursor = match cursor_type.into() {
CT_POINTER => CursorIcon::Default,
CT_CROSS => CursorIcon::Crosshair,
Expand Down
10 changes: 5 additions & 5 deletions desktop/src/cef/texture_import/common.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Common utilities and traits for texture import across platforms

use crate::cef::texture_import::*;
use ash::vk;
use cef::sys::cef_color_type_t;
use wgpu::Device;

Expand All @@ -20,10 +19,10 @@ pub mod format {

#[cfg(not(target_os = "macos"))]
/// Convert CEF color type to Vulkan format
pub fn cef_to_vulkan(format: cef_color_type_t) -> Result<vk::Format, TextureImportError> {
pub fn cef_to_vulkan(format: cef_color_type_t) -> Result<ash::vk::Format, TextureImportError> {
match format {
cef_color_type_t::CEF_COLOR_TYPE_BGRA_8888 => Ok(vk::Format::B8G8R8A8_UNORM),
cef_color_type_t::CEF_COLOR_TYPE_RGBA_8888 => Ok(vk::Format::R8G8B8A8_UNORM),
cef_color_type_t::CEF_COLOR_TYPE_BGRA_8888 => Ok(ash::vk::Format::B8G8R8A8_UNORM),
cef_color_type_t::CEF_COLOR_TYPE_RGBA_8888 => Ok(ash::vk::Format::R8G8B8A8_UNORM),
_ => Err(TextureImportError::UnsupportedFormat { format }),
}
}
Expand Down Expand Up @@ -63,16 +62,17 @@ pub mod texture {
}

/// Common Vulkan utilities
#[cfg(not(target_os = "macos"))]
pub mod vulkan {
use super::*;
use ash::vk;

/// Find a suitable memory type index for Vulkan allocation
pub fn find_memory_type_index(type_filter: u32, properties: vk::MemoryPropertyFlags, mem_properties: &vk::PhysicalDeviceMemoryProperties) -> Option<u32> {
(0..mem_properties.memory_type_count).find(|&i| (type_filter & (1 << i)) != 0 && mem_properties.memory_types[i as usize].property_flags.contains(properties))
}

/// Check if the wgpu device is using Vulkan backend
#[cfg(not(target_os = "macos"))]
pub fn is_vulkan_backend(device: &Device) -> bool {
use wgpu::hal::api;
let mut is_vulkan = false;
Expand Down
Loading