mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Expose non-widget rendering to embedders.
This commit is contained in:
parent
1e3d72dc82
commit
cb2b2abdee
2 changed files with 25 additions and 8 deletions
|
@ -63,10 +63,18 @@ pub struct InitOptions {
|
|||
pub xr_discovery: Option<webxr::Discovery>,
|
||||
pub gl_context_pointer: Option<*const c_void>,
|
||||
pub native_display_pointer: Option<*const c_void>,
|
||||
pub native_widget: *mut c_void,
|
||||
pub surfman_integration: SurfmanIntegration,
|
||||
pub prefs: Option<HashMap<String, PrefValue>>,
|
||||
}
|
||||
|
||||
/// Controls how this embedding's rendering will integrate with the embedder.
|
||||
pub enum SurfmanIntegration {
|
||||
/// Render directly to a provided native widget (see surfman::NativeWidget).
|
||||
Widget(*mut c_void),
|
||||
/// Render to an offscreen surface.
|
||||
Surface,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Coordinates {
|
||||
pub viewport: Rect<i32, DevicePixel>,
|
||||
|
@ -253,13 +261,21 @@ pub fn init(
|
|||
.create_adapter()
|
||||
.or(Err("Failed to create adapter"))?,
|
||||
};
|
||||
let native_widget = unsafe {
|
||||
connection.create_native_widget_from_ptr(
|
||||
init_opts.native_widget,
|
||||
init_opts.coordinates.framebuffer.to_untyped(),
|
||||
)
|
||||
let surface_type = match init_opts.surfman_integration {
|
||||
SurfmanIntegration::Widget(native_widget) => {
|
||||
let native_widget = unsafe {
|
||||
connection.create_native_widget_from_ptr(
|
||||
native_widget,
|
||||
init_opts.coordinates.framebuffer.to_untyped(),
|
||||
)
|
||||
};
|
||||
SurfaceType::Widget { native_widget }
|
||||
},
|
||||
SurfmanIntegration::Surface => {
|
||||
let size = init_opts.coordinates.framebuffer.to_untyped();
|
||||
SurfaceType::Generic { size }
|
||||
},
|
||||
};
|
||||
let surface_type = SurfaceType::Widget { native_widget };
|
||||
let webrender_surfman = WebrenderSurfman::create(&connection, &adapter, surface_type)
|
||||
.or(Err("Failed to create surface manager"))?;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ use simpleservo::{self, gl_glue, ServoGlue, SERVO};
|
|||
use simpleservo::{
|
||||
ContextMenuResult, Coordinates, DeviceIntRect, EventLoopWaker, HostTrait, InitOptions,
|
||||
InputMethodType, MediaSessionActionType, MediaSessionPlaybackState, MouseButton, PromptResult,
|
||||
SurfmanIntegration,
|
||||
};
|
||||
use std::ffi::{CStr, CString};
|
||||
#[cfg(target_os = "windows")]
|
||||
|
@ -463,7 +464,7 @@ unsafe fn init(
|
|||
xr_discovery: None,
|
||||
gl_context_pointer: gl_context,
|
||||
native_display_pointer: display,
|
||||
native_widget: opts.native_widget,
|
||||
surfman_integration: SurfmanIntegration::Widget(opts.native_widget),
|
||||
};
|
||||
|
||||
let wakeup = Box::new(WakeupCallback::new(wakeup));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue