mirror of
https://github.com/servo/servo.git
synced 2025-10-01 00:59:15 +01:00
Get the right pixel density on Android
This commit is contained in:
parent
7287ea4c85
commit
96cf1e2da3
7 changed files with 27 additions and 12 deletions
|
@ -101,6 +101,7 @@ pub fn init(
|
|||
callbacks: Box<HostTrait>,
|
||||
width: u32,
|
||||
height: u32,
|
||||
density: f32,
|
||||
) -> Result<(), &'static str> {
|
||||
resources::set(Box::new(ResourceReader(readfile)));
|
||||
|
||||
|
@ -136,6 +137,7 @@ pub fn init(
|
|||
host_callbacks: callbacks,
|
||||
width: Cell::new(width),
|
||||
height: Cell::new(height),
|
||||
density,
|
||||
waker,
|
||||
});
|
||||
|
||||
|
@ -419,6 +421,7 @@ struct ServoCallbacks {
|
|||
host_callbacks: Box<HostTrait>,
|
||||
width: Cell<u32>,
|
||||
height: Cell<u32>,
|
||||
density: f32,
|
||||
}
|
||||
|
||||
impl WindowMethods for ServoCallbacks {
|
||||
|
@ -460,7 +463,7 @@ impl WindowMethods for ServoCallbacks {
|
|||
window: (size, TypedPoint2D::new(0, 0)),
|
||||
screen: size,
|
||||
screen_avail: size,
|
||||
hidpi_factor: TypedScale::new(2.0),
|
||||
hidpi_factor: TypedScale::new(self.density),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,8 @@ fn init(
|
|||
readfile: extern fn(*const c_char) -> *const c_char,
|
||||
callbacks: CHostCallbacks,
|
||||
width: u32,
|
||||
height: u32) {
|
||||
height: u32,
|
||||
density: f32) {
|
||||
let args = unsafe { CStr::from_ptr(args) };
|
||||
let args = args.to_str().expect("Can't read string").to_string();
|
||||
|
||||
|
@ -75,6 +76,7 @@ fn init(
|
|||
callbacks,
|
||||
width,
|
||||
height,
|
||||
density,
|
||||
).unwrap();
|
||||
}
|
||||
|
||||
|
@ -87,9 +89,10 @@ pub extern "C" fn init_with_egl(
|
|||
readfile: extern fn(*const c_char) -> *const c_char,
|
||||
callbacks: CHostCallbacks,
|
||||
width: u32,
|
||||
height: u32) {
|
||||
height: u32,
|
||||
density: f32) {
|
||||
let gl = gl_glue::egl::init().unwrap();
|
||||
init(gl, args, url, wakeup, readfile, callbacks, width, height)
|
||||
init(gl, args, url, wakeup, readfile, callbacks, width, height, density)
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]
|
||||
|
@ -101,9 +104,10 @@ pub extern "C" fn init_with_gl(
|
|||
readfile: extern fn(*const c_char) -> *const c_char,
|
||||
callbacks: CHostCallbacks,
|
||||
width: u32,
|
||||
height: u32) {
|
||||
height: u32,
|
||||
density: f32) {
|
||||
let gl = gl_glue::gl::init().unwrap();
|
||||
init(gl, args, url, wakeup, readfile, callbacks, width, height)
|
||||
init(gl, args, url, wakeup, readfile, callbacks, width, height, density)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
|
|
@ -54,6 +54,7 @@ pub fn Java_com_mozilla_servoview_JNIServo_init(
|
|||
callbacks_obj: JObject,
|
||||
width: jint,
|
||||
height: jint,
|
||||
density: jfloat,
|
||||
log: jboolean,
|
||||
) {
|
||||
if log == JNI_TRUE {
|
||||
|
@ -102,7 +103,8 @@ pub fn Java_com_mozilla_servoview_JNIServo_init(
|
|||
readfile,
|
||||
callbacks,
|
||||
width as u32,
|
||||
height as u32)
|
||||
height as u32,
|
||||
density as f32)
|
||||
}).or_else(|err| {
|
||||
env.throw(("java/lang/Exception", err))
|
||||
}).unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue