mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-02 21:03:00 +00:00
C++: Make the platform support work without the "std" feature
Add a experimental-platform feature that doesn't include skia
This commit is contained in:
parent
03bca95bef
commit
4a505c6788
3 changed files with 152 additions and 143 deletions
|
|
@ -38,7 +38,8 @@ renderer-winit-software = ["i-slint-backend-selector/renderer-winit-software"]
|
||||||
gettext = ["i-slint-core/gettext-rs"]
|
gettext = ["i-slint-core/gettext-rs"]
|
||||||
accessibility = ["i-slint-backend-selector/accessibility"]
|
accessibility = ["i-slint-backend-selector/accessibility"]
|
||||||
|
|
||||||
experimental = ["i-slint-renderer-skia", "raw-window-handle", "std"]
|
experimental = ["i-slint-renderer-skia", "raw-window-handle", "experimental-platform"]
|
||||||
|
experimental-platform = []
|
||||||
|
|
||||||
std = ["image", "i-slint-core/default", "i-slint-backend-selector"]
|
std = ["image", "i-slint-core/default", "i-slint-backend-selector"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use alloc::rc::Rc;
|
||||||
use core::ffi::c_void;
|
use core::ffi::c_void;
|
||||||
use i_slint_core::window::{ffi::WindowAdapterRcOpaque, WindowAdapter};
|
use i_slint_core::window::{ffi::WindowAdapterRcOpaque, WindowAdapter};
|
||||||
|
|
||||||
#[cfg(feature = "experimental")]
|
#[cfg(feature = "experimental-platform")]
|
||||||
pub mod platform;
|
pub mod platform;
|
||||||
|
|
||||||
#[cfg(feature = "i-slint-backend-selector")]
|
#[cfg(feature = "i-slint-backend-selector")]
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ use i_slint_core::renderer::Renderer;
|
||||||
use i_slint_core::software_renderer::{RepaintBufferType, SoftwareRenderer};
|
use i_slint_core::software_renderer::{RepaintBufferType, SoftwareRenderer};
|
||||||
use i_slint_core::window::ffi::WindowAdapterRcOpaque;
|
use i_slint_core::window::ffi::WindowAdapterRcOpaque;
|
||||||
use i_slint_core::window::{WindowAdapter, WindowAdapterInternal};
|
use i_slint_core::window::{WindowAdapter, WindowAdapterInternal};
|
||||||
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};
|
|
||||||
|
|
||||||
type WindowAdapterUserData = *mut c_void;
|
type WindowAdapterUserData = *mut c_void;
|
||||||
|
|
||||||
|
|
@ -214,8 +213,10 @@ pub unsafe extern "C" fn slint_software_renderer_handle(r: SoftwareRendererOpaqu
|
||||||
core::mem::transmute(r)
|
core::mem::transmute(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
type SkiaRendererOpaque = *const c_void;
|
#[cfg(all(feature = "i-slint-renderer-skia", feature = "raw-window-handle"))]
|
||||||
type SkiaRenderer = i_slint_renderer_skia::SkiaRenderer;
|
pub mod skia {
|
||||||
|
use super::*;
|
||||||
|
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};
|
||||||
|
|
||||||
struct CppRawHandle(RawWindowHandle, RawDisplayHandle);
|
struct CppRawHandle(RawWindowHandle, RawDisplayHandle);
|
||||||
|
|
||||||
|
|
@ -238,7 +239,10 @@ pub unsafe extern "C" fn slint_new_raw_window_handle_win32(
|
||||||
hinstance: *mut c_void,
|
hinstance: *mut c_void,
|
||||||
) -> CppRawHandleOpaque {
|
) -> CppRawHandleOpaque {
|
||||||
let handle = CppRawHandle(
|
let handle = CppRawHandle(
|
||||||
RawWindowHandle::Win32(init_raw!(raw_window_handle::Win32WindowHandle { hwnd, hinstance })),
|
RawWindowHandle::Win32(init_raw!(raw_window_handle::Win32WindowHandle {
|
||||||
|
hwnd,
|
||||||
|
hinstance
|
||||||
|
})),
|
||||||
RawDisplayHandle::Windows(raw_window_handle::WindowsDisplayHandle::empty()),
|
RawDisplayHandle::Windows(raw_window_handle::WindowsDisplayHandle::empty()),
|
||||||
);
|
);
|
||||||
Box::into_raw(Box::new(handle)) as CppRawHandleOpaque
|
Box::into_raw(Box::new(handle)) as CppRawHandleOpaque
|
||||||
|
|
@ -290,6 +294,9 @@ pub unsafe extern "C" fn slint_raw_window_handle_drop(handle: CppRawHandleOpaque
|
||||||
drop(Box::from_raw(handle as *mut CppRawHandle))
|
drop(Box::from_raw(handle as *mut CppRawHandle))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SkiaRendererOpaque = *const c_void;
|
||||||
|
type SkiaRenderer = i_slint_renderer_skia::SkiaRenderer;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn slint_skia_renderer_new(
|
pub unsafe extern "C" fn slint_skia_renderer_new(
|
||||||
handle_opaque: CppRawHandleOpaque,
|
handle_opaque: CppRawHandleOpaque,
|
||||||
|
|
@ -357,3 +364,4 @@ pub unsafe extern "C" fn slint_skia_renderer_handle(r: SkiaRendererOpaque) -> Re
|
||||||
let r = (r as *const SkiaRenderer) as *const dyn Renderer;
|
let r = (r as *const SkiaRenderer) as *const dyn Renderer;
|
||||||
core::mem::transmute(r)
|
core::mem::transmute(r)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue