Skip to content

Commit

Permalink
Fix libsimpleservo build
Browse files Browse the repository at this point in the history
  • Loading branch information
ferjm authored and jdm committed Jul 5, 2019
1 parent 208473c commit 728fdff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ports/libsimpleservo/api/src/lib.rs
Expand Up @@ -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 {
Expand Down
23 changes: 18 additions & 5 deletions ports/libsimpleservo/capi/src/lib.rs
Expand Up @@ -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(' ')
Expand All @@ -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);
Expand All @@ -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));
Expand All @@ -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"))]
Expand All @@ -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]
Expand Down

0 comments on commit 728fdff

Please sign in to comment.