Skip to content
Permalink
Browse files

Fix libsimpleservo build

  • Loading branch information...
ferjm authored and jdm committed Jul 4, 2019
1 parent 208473c commit 728fdff72146663c3fb7da96674f0f9ad85c06ac
Showing with 20 additions and 7 deletions.
  1. +2 −2 ports/libsimpleservo/api/src/lib.rs
  2. +18 −5 ports/libsimpleservo/capi/src/lib.rs
@@ -587,8 +587,8 @@ struct ServoWindowCallbacks {
host_callbacks: Box<dyn HostTrait>,
coordinates: RefCell<Coordinates>,
density: f32,
gl_context_pointer: Option<*const libc::c_void>,
native_display_pointer: Option<*const libc::c_void>,
gl_context_pointer: Option<*const c_void>,
native_display_pointer: Option<*const c_void>,
}

impl EmbedderMethods for ServoEmbedderCallbacks {
@@ -93,16 +93,18 @@ fn init_logger() {
crate::env_logger::init();
}

fn init(
unsafe fn init(
opts: CInitOptions,
gl: gl_glue::ServoGl,
gl_context: Option<*const c_void>,
display: Option<*const c_void>,
wakeup: extern "C" fn(),
callbacks: CHostCallbacks,
) {
init_logger();

let args = if !opts.args.is_null() {
let args = unsafe { CStr::from_ptr(opts.args) };
let args = CStr::from_ptr(opts.args);
args.to_str()
.unwrap_or("")
.split(' ')
@@ -112,7 +114,7 @@ fn init(
vec![]
};

let url = unsafe { CStr::from_ptr(opts.url) };
let url = CStr::from_ptr(opts.url);
let url = url.to_str().map(|s| s.to_string()).ok();

let coordinates = Coordinates::new(0, 0, opts.width, opts.height, opts.width, opts.height);
@@ -128,6 +130,8 @@ fn init(
VRInitOptions::VRExternal(opts.vr_pointer)
},
enable_subpixel_text_antialiasing: opts.enable_subpixel_text_antialiasing,
gl_context_pointer: gl_context,
native_display_pointer: display,
};

let wakeup = Box::new(WakeupCallback::new(wakeup));
@@ -145,7 +149,16 @@ pub extern "C" fn init_with_egl(
) {
init_logger();
let gl = gl_glue::egl::init().unwrap();
init(opts, gl, wakeup, callbacks)
unsafe {
init(
opts,
gl.gl_wrapper,
Some(gl.gl_context),
Some(gl.display),
wakeup,
callbacks,
)
}
}

#[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]
@@ -157,7 +170,7 @@ pub extern "C" fn init_with_gl(
) {
init_logger();
let gl = gl_glue::gl::init().unwrap();
init(opts, gl, wakeup, callbacks)
unsafe { init(opts, gl, None, None, wakeup, callbacks) }
}

#[no_mangle]

0 comments on commit 728fdff

Please sign in to comment.
You can’t perform that action at this time.