Auto merge of #22773 - paulrouget:immersive, r=jdm

Support for ExternalVR implementation

This PR adds the hook necessary for the ExternalVR rust-webvr driver.
Waiting on rust-webvr 0.9.3 to be published before landing.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22773)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-02-07 00:17:26 -05:00 committed by GitHub
commit 6c161e5037
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 66 additions and 13 deletions

View file

@ -21,6 +21,7 @@ use servo::servo_url::ServoUrl;
use servo::{self, gl, webrender_api, BrowserId, Servo};
use std::cell::{Cell, RefCell};
use std::mem;
use std::os::raw::c_void;
use std::path::PathBuf;
use std::rc::Rc;
@ -39,6 +40,7 @@ pub struct InitOptions {
pub width: u32,
pub height: u32,
pub density: f32,
pub vr_pointer: Option<*mut c_void>,
pub enable_subpixel_text_antialiasing: bool,
}
@ -146,6 +148,7 @@ pub fn init(
width: Cell::new(init_opts.width),
height: Cell::new(init_opts.height),
density: init_opts.density,
vr_pointer: init_opts.vr_pointer,
waker,
});
@ -489,6 +492,7 @@ struct ServoCallbacks {
width: Cell<u32>,
height: Cell<u32>,
density: f32,
vr_pointer: Option<*mut c_void>,
}
impl WindowMethods for ServoCallbacks {
@ -530,6 +534,10 @@ impl WindowMethods for ServoCallbacks {
hidpi_factor: TypedScale::new(self.density),
}
}
fn get_vrexternal_pointer(&self) -> Option<*mut c_void> {
self.vr_pointer.clone()
}
}
struct ResourceReaderInstance;

View file

@ -8,7 +8,7 @@ extern crate log;
use simpleservo::{self, gl_glue, EventLoopWaker, HostTrait, InitOptions, ServoGlue, SERVO};
use std::ffi::{CStr, CString};
use std::mem;
use std::os::raw::c_char;
use std::os::raw::{c_char, c_void};
fn call<F>(f: F)
where
@ -49,6 +49,7 @@ pub struct CInitOptions {
pub width: u32,
pub height: u32,
pub density: f32,
pub vr_pointer: *mut c_void,
pub enable_subpixel_text_antialiasing: bool,
}
@ -80,6 +81,11 @@ fn init(
width: opts.width,
height: opts.height,
density: opts.density,
vr_pointer: if opts.vr_pointer.is_null() {
None
} else {
Some(opts.vr_pointer)
},
enable_subpixel_text_antialiasing: opts.enable_subpixel_text_antialiasing,
};

View file

@ -64,7 +64,9 @@ pub fn Java_org_mozilla_servoview_JNIServo_init(
// debug!() will only show in a debug build. Use info!() if logs
// should show up in adb logcat with a release build.
let filters = [
"simpleservo",
"servo",
"simpleservo::api",
"simpleservo::jniapi",
"simpleservo::gl_glue::egl",
// Show JS errors by default.
"script::dom::bindings::error",
@ -650,6 +652,9 @@ fn get_options(env: &JNIEnv, opts: JObject) -> Result<(InitOptions, bool, Option
get_non_null_field(env, opts, "enableSubpixelTextAntialiasing", "Z")?
.z()
.map_err(|_| "enableSubpixelTextAntialiasing not a boolean")?;
let vr_pointer = get_non_null_field(env, opts, "VRExternalContext", "J")?
.j()
.map_err(|_| "VRExternalContext is not a long")? as *mut c_void;
let opts = InitOptions {
args,
url,
@ -657,6 +662,11 @@ fn get_options(env: &JNIEnv, opts: JObject) -> Result<(InitOptions, bool, Option
height,
density,
enable_subpixel_text_antialiasing,
vr_pointer: if vr_pointer.is_null() {
None
} else {
Some(vr_pointer)
},
};
Ok((opts, log, log_str))
}