mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Partially upgrade gonk to master's rustc
This commit is contained in:
parent
14ac98849e
commit
7bd9e04fee
5 changed files with 53 additions and 40 deletions
2
ports/gonk/Cargo.lock
generated
2
ports/gonk/Cargo.lock
generated
|
@ -3,9 +3,11 @@ name = "b2s"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"compositing 0.0.1",
|
||||
"devtools 0.0.1",
|
||||
"egl 0.1.0 (git+https://github.com/servo/rust-egl)",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
|
||||
"layout 0.0.1",
|
||||
"msg 0.0.1",
|
||||
"script 0.0.1",
|
||||
"servo 0.0.1",
|
||||
|
|
|
@ -20,6 +20,12 @@ path = "../../components/msg"
|
|||
[dependencies.script]
|
||||
path = "../../components/script"
|
||||
|
||||
[dependencies.layout]
|
||||
path = "../../components/layout"
|
||||
|
||||
[dependencies.devtools]
|
||||
path = "../../components/devtools"
|
||||
|
||||
[dependencies.servo]
|
||||
path = "../../components/servo"
|
||||
default-features = false
|
||||
|
|
|
@ -10,6 +10,8 @@ use std::os::errno;
|
|||
use std::os::unix::AsRawFd;
|
||||
use std::num::Float;
|
||||
use std::io::File;
|
||||
use std::thread::Thread;
|
||||
use std::sync::mpsc::Sender;
|
||||
|
||||
use geom::point::TypedPoint2D;
|
||||
|
||||
|
@ -116,9 +118,9 @@ fn read_input_device(device_path: &Path,
|
|||
println!("xMin: {}, yMin: {}, touchWidth: {}, touchHeight: {}", xInfo.minimum, yInfo.minimum, touchWidth, touchHeight);
|
||||
|
||||
// XXX: Why isn't size_of treated as constant?
|
||||
// let buf: [u8, ..(16 * size_of::<linux_input_event>())];
|
||||
let mut buf: [u8, ..(16 * 16)] = unsafe { zeroed() };
|
||||
let mut slots: [input_slot, ..10] = unsafe { zeroed() };
|
||||
// let buf: [u8; (16 * size_of::<linux_input_event>())];
|
||||
let mut buf: [u8; (16 * 16)] = unsafe { zeroed() };
|
||||
let mut slots: [input_slot; 10] = unsafe { zeroed() };
|
||||
for slot in slots.iter_mut() {
|
||||
slot.tracking_id = -1;
|
||||
}
|
||||
|
@ -234,7 +236,7 @@ fn read_input_device(device_path: &Path,
|
|||
|
||||
pub fn run_input_loop(event_sender: &Sender<WindowEvent>) {
|
||||
let sender = event_sender.clone();
|
||||
spawn(proc () {
|
||||
Thread::spawn(move || {
|
||||
// XXX need to scan all devices and read every one.
|
||||
let touchinputdev = Path::new("/dev/input/event0");
|
||||
read_input_device(&touchinputdev, &sender);
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![feature(macro_rules, phase, thread_local)]
|
||||
#![feature(thread_local)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(int_uint)]
|
||||
|
||||
#![deny(unused_imports)]
|
||||
#![deny(unused_variables)]
|
||||
|
@ -20,7 +22,6 @@ extern crate script;
|
|||
extern crate layout;
|
||||
extern crate gfx;
|
||||
extern crate libc;
|
||||
extern crate rustrt;
|
||||
extern crate url;
|
||||
|
||||
use compositing::CompositorEventListener;
|
||||
|
@ -57,7 +58,9 @@ use std::os;
|
|||
#[cfg(not(test))]
|
||||
use std::rc::Rc;
|
||||
#[cfg(not(test))]
|
||||
use std::task::TaskBuilder;
|
||||
use std::thread::Builder;
|
||||
#[cfg(not(test))]
|
||||
use std::sync::mpsc::channel;
|
||||
|
||||
pub struct Browser<Window> {
|
||||
compositor: Box<CompositorEventListener + 'static>,
|
||||
|
@ -85,8 +88,8 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
|
|||
|
||||
let (result_chan, result_port) = channel();
|
||||
let compositor_proxy_for_constellation = compositor_proxy.clone_compositor_proxy();
|
||||
TaskBuilder::new()
|
||||
.spawn(proc() {
|
||||
Builder::new()
|
||||
.spawn(move || {
|
||||
let opts = &opts_clone;
|
||||
// Create a Servo instance.
|
||||
let resource_task = new_resource_task(opts.user_agent.clone());
|
||||
|
@ -128,7 +131,7 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
|
|||
result_chan.send(constellation_chan);
|
||||
});
|
||||
|
||||
let constellation_chan = result_port.recv();
|
||||
let constellation_chan = result_port.recv().unwrap();
|
||||
|
||||
debug!("preparing to enter main loop");
|
||||
let compositor = CompositorTask::create(window,
|
||||
|
|
|
@ -15,7 +15,7 @@ use msg::compositor_msg::{ReadyState, PaintState};
|
|||
use msg::constellation_msg::{Key, KeyModifiers};
|
||||
use msg::constellation_msg::LoadData;
|
||||
use std::cell::Cell;
|
||||
use std::comm::Receiver;
|
||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||
use std::rc::Rc;
|
||||
use std::mem::transmute;
|
||||
use std::mem::size_of;
|
||||
|
@ -50,7 +50,7 @@ pub struct native_handle {
|
|||
version: c_int,
|
||||
numFds: c_int,
|
||||
numInts: c_int,
|
||||
data: [c_int, ..0],
|
||||
data: [c_int; 0],
|
||||
}
|
||||
|
||||
// system/core/include/system/window.h
|
||||
|
@ -59,7 +59,7 @@ pub struct native_handle {
|
|||
pub struct ANativeBase {
|
||||
magic: u32,
|
||||
version: u32,
|
||||
reserved: [int, ..4],
|
||||
reserved: [int; 4],
|
||||
incRef: extern fn(*mut ANativeBase),
|
||||
decRef: extern fn(*mut ANativeBase),
|
||||
}
|
||||
|
@ -72,9 +72,9 @@ pub struct ANativeWindowBuffer {
|
|||
stride: c_int,
|
||||
format: c_int,
|
||||
usage: c_int,
|
||||
reserved: [*mut c_void, ..2],
|
||||
reserved: [*mut c_void; 2],
|
||||
handle: *const native_handle,
|
||||
reserved_proc: [*mut c_void, ..8],
|
||||
reserved_proc: [*mut c_void; 8],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -85,7 +85,7 @@ pub struct ANativeWindow {
|
|||
maxSwapInterval: c_int,
|
||||
xdpi: f32,
|
||||
ydpi: f32,
|
||||
oem: [int, ..4],
|
||||
oem: [int; 4],
|
||||
setSwapInterval: extern fn(*mut ANativeWindow, c_int) -> c_int,
|
||||
//dequeueBuffer_DEPRECATED: extern fn(*mut ANativeWindow, *mut *mut ANativeWindowBuffer) -> c_int,
|
||||
//lockBuffer_DEPRECATED: extern fn(*mut ANativeWindow, *mut ANativeWindowBuffer) -> c_int,
|
||||
|
@ -119,7 +119,7 @@ pub struct hw_module {
|
|||
author: *const c_char,
|
||||
methods: *mut hw_module_methods,
|
||||
dso: *mut u32,
|
||||
reserved: [u32, ..(32-7)],
|
||||
reserved: [u32; (32-7)],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -127,7 +127,7 @@ pub struct hw_device {
|
|||
tag: u32,
|
||||
version: u32,
|
||||
module: *mut hw_module,
|
||||
reserved: [u32, ..12],
|
||||
reserved: [u32; 12],
|
||||
close: extern fn(*mut hw_device) -> c_int,
|
||||
}
|
||||
|
||||
|
@ -183,8 +183,8 @@ pub struct hwc_layer {
|
|||
acquireFenceFd: c_int,
|
||||
releaseFenceFd: c_int,
|
||||
planeAlpha: u8,
|
||||
pad: [u8, ..3],
|
||||
reserved: [i32, ..(24 - 19)],
|
||||
pad: [u8; 3],
|
||||
reserved: [i32; (24 - 19)],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -195,7 +195,7 @@ pub struct hwc_display_contents {
|
|||
outbufAcquireFenceFd: c_int,
|
||||
flags: u32,
|
||||
numHwLayers: size_t,
|
||||
hwLayers: [hwc_layer, ..2],
|
||||
hwLayers: [hwc_layer; 2],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -224,7 +224,7 @@ pub struct hwc_composer_device {
|
|||
dump: extern fn(*mut hwc_composer_device, *const c_char, c_int),
|
||||
getDisplayConfigs: extern fn(*mut hwc_composer_device, c_int, *mut u32, *mut size_t) -> c_int,
|
||||
getDisplayAttributes: extern fn(*mut hwc_composer_device, c_int, u32, *const u32, *mut i32) -> c_int,
|
||||
reserved: [*mut c_void, ..4],
|
||||
reserved: [*mut c_void; 4],
|
||||
}
|
||||
|
||||
// system/core/include/system/graphics.h
|
||||
|
@ -237,7 +237,7 @@ pub struct android_ycbcr {
|
|||
ystride: size_t,
|
||||
cstride: size_t,
|
||||
chroma_step: size_t,
|
||||
reserved: [u32, ..8],
|
||||
reserved: [u32; 8],
|
||||
}
|
||||
|
||||
// hardware/libhardware/include/hardware/gralloc.h
|
||||
|
@ -251,7 +251,7 @@ pub struct gralloc_module {
|
|||
unlock: extern fn(*const gralloc_module, *const native_handle) -> c_int,
|
||||
perform: extern fn(*const gralloc_module, c_int, ...) -> c_int,
|
||||
lock_ycbcr: extern fn(*const gralloc_module, *const native_handle, c_int, c_int, c_int, c_int, c_int, *mut android_ycbcr) -> c_int,
|
||||
reserved: [*mut c_void, ..6],
|
||||
reserved: [*mut c_void; 6],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -261,7 +261,7 @@ pub struct alloc_device {
|
|||
alloc: extern fn(*mut alloc_device, c_int, c_int, c_int, c_int, *mut *const native_handle, *mut c_int) -> c_int,
|
||||
free: extern fn(*mut alloc_device, *const native_handle) -> c_int,
|
||||
dump: Option<extern fn(*mut alloc_device, *mut c_char, c_int)>,
|
||||
reserved: [*mut c_void, ..7],
|
||||
reserved: [*mut c_void; 7],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -282,13 +282,13 @@ pub struct GonkNativeWindow {
|
|||
usage: c_int,
|
||||
last_fence: c_int,
|
||||
last_idx: i32,
|
||||
bufs: [Option<*mut GonkNativeWindowBuffer>, ..2],
|
||||
fences: [c_int, ..2],
|
||||
bufs: [Option<*mut GonkNativeWindowBuffer>; 2],
|
||||
fences: [c_int; 2],
|
||||
}
|
||||
|
||||
impl ANativeBase {
|
||||
fn magic(a: char, b: char, c: char, d: char) -> u32 {
|
||||
a as u32 << 24 | b as u32 << 16 | c as u32 << 8 | d as u32
|
||||
(a as u32) << 24 | (b as u32) << 16 | (c as u32) << 8 | d as u32
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,7 @@ extern fn gnw_decRef(base: *mut ANativeBase) {
|
|||
|
||||
impl GonkNativeWindow {
|
||||
pub fn new(alloc_dev: *mut alloc_device, hwc_dev: *mut hwc_composer_device, width: i32, height: i32, usage: c_int) -> *mut GonkNativeWindow {
|
||||
let mut win = box GonkNativeWindow {
|
||||
let mut win = Box::new(GonkNativeWindow {
|
||||
window: ANativeWindow {
|
||||
common: ANativeBase {
|
||||
magic: ANativeBase::magic('_', 'w', 'n', 'd'),
|
||||
|
@ -495,7 +495,7 @@ impl GonkNativeWindow {
|
|||
last_idx: -1,
|
||||
bufs: unsafe { zeroed() },
|
||||
fences: [-1, -1],
|
||||
};
|
||||
});
|
||||
|
||||
unsafe { transmute(win) }
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ impl GonkNativeWindow {
|
|||
],
|
||||
};
|
||||
unsafe {
|
||||
let mut displays: [*mut hwc_display_contents, ..3] = [ &mut list, ptr::null_mut(), ptr::null_mut(), ];
|
||||
let mut displays: [*mut hwc_display_contents; 3] = [ &mut list, ptr::null_mut(), ptr::null_mut(), ];
|
||||
let _ = ((*self.hwc_dev).prepare)(self.hwc_dev, displays.len() as size_t, transmute(displays.as_mut_ptr()));
|
||||
let _ = ((*self.hwc_dev).set)(self.hwc_dev, displays.len() as size_t, transmute(displays.as_mut_ptr()));
|
||||
if list.retireFenceFd >= 0 {
|
||||
|
@ -583,7 +583,7 @@ extern fn gnwb_decRef(base: *mut ANativeBase) {
|
|||
|
||||
impl GonkNativeWindowBuffer {
|
||||
pub fn new(dev: *mut alloc_device, width: i32, height: i32, format: c_int, usage: c_int) -> *mut GonkNativeWindowBuffer {
|
||||
let mut buf = box GonkNativeWindowBuffer {
|
||||
let mut buf = Box::new(GonkNativeWindowBuffer {
|
||||
buffer: ANativeWindowBuffer {
|
||||
common: ANativeBase {
|
||||
magic: ANativeBase::magic('_', 'b', 'f', 'r'),
|
||||
|
@ -602,7 +602,7 @@ impl GonkNativeWindowBuffer {
|
|||
reserved_proc: unsafe { zeroed() },
|
||||
},
|
||||
count: 1,
|
||||
};
|
||||
});
|
||||
|
||||
let ret = unsafe { ((*dev).alloc)(dev, width, height, format, usage, &mut buf.buffer.handle, &mut buf.buffer.stride) };
|
||||
assert!(ret == 0, "Failed to allocate gralloc buffer!");
|
||||
|
@ -646,12 +646,12 @@ impl Window {
|
|||
assert!((*hwc_device).common.version > (1 << 8), "HWC too old!");
|
||||
}
|
||||
|
||||
let attrs: [u32, ..4] = [
|
||||
let attrs: [u32; 4] = [
|
||||
HWC_DISPLAY_WIDTH,
|
||||
HWC_DISPLAY_HEIGHT,
|
||||
HWC_DISPLAY_DPI_X,
|
||||
HWC_DISPLAY_NO_ATTRIBUTE];
|
||||
let mut values: [i32, ..4] = [0, 0, 0, 0];
|
||||
let mut values: [i32; 4] = [0, 0, 0, 0];
|
||||
unsafe {
|
||||
// In theory, we should check the return code.
|
||||
// However, there are HALs which implement this wrong.
|
||||
|
@ -818,11 +818,11 @@ impl WindowMethods for Window {
|
|||
fn create_compositor_channel(window: &Option<Rc<Window>>)
|
||||
-> (Box<CompositorProxy+Send>, Box<CompositorReceiver>) {
|
||||
let (sender, receiver) = channel();
|
||||
(box GonkCompositorProxy {
|
||||
(Box::new(GonkCompositorProxy {
|
||||
sender: sender,
|
||||
event_sender: window.as_ref().unwrap().event_send.clone(),
|
||||
} as Box<CompositorProxy+Send>,
|
||||
box receiver as Box<CompositorReceiver>)
|
||||
}) as Box<CompositorProxy+Send>,
|
||||
Box::new(receiver) as Box<CompositorReceiver>)
|
||||
}
|
||||
|
||||
fn set_cursor(&self, _: Cursor) {
|
||||
|
@ -845,10 +845,10 @@ impl CompositorProxy for GonkCompositorProxy {
|
|||
self.event_sender.send(WindowEvent::Idle);
|
||||
}
|
||||
fn clone_compositor_proxy(&self) -> Box<CompositorProxy+Send> {
|
||||
box GonkCompositorProxy {
|
||||
Box::new(GonkCompositorProxy {
|
||||
sender: self.sender.clone(),
|
||||
event_sender: self.event_sender.clone(),
|
||||
} as Box<CompositorProxy+Send>
|
||||
}) as Box<CompositorProxy+Send>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue