mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
Support for ExternalVR implementation
This commit is contained in:
parent
b7e9bab267
commit
c055b74e13
11 changed files with 66 additions and 13 deletions
|
@ -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,
|
||||
}
|
||||
|
||||
|
@ -152,6 +154,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,
|
||||
});
|
||||
|
||||
|
@ -495,6 +498,7 @@ struct ServoCallbacks {
|
|||
width: Cell<u32>,
|
||||
height: Cell<u32>,
|
||||
density: f32,
|
||||
vr_pointer: Option<*mut c_void>,
|
||||
}
|
||||
|
||||
impl WindowMethods for ServoCallbacks {
|
||||
|
@ -536,6 +540,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 ResourceReader(Box<dyn ReadFileTrait + Send + Sync>);
|
||||
|
|
|
@ -10,7 +10,7 @@ use simpleservo::{
|
|||
};
|
||||
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
|
||||
|
@ -51,6 +51,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,
|
||||
}
|
||||
|
||||
|
@ -83,6 +84,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,
|
||||
};
|
||||
|
||||
|
|
|
@ -66,7 +66,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",
|
||||
|
@ -686,6 +688,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,
|
||||
|
@ -693,6 +698,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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue