mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Add some timing info, update rust-azure to fix crash
This commit is contained in:
parent
4303419865
commit
b1c59aba61
2 changed files with 74 additions and 71 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 385867116d04f5d4aa34976bf9794bcb1913f162
|
||||
Subproject commit 55457bba7f6a07728518a7a8f33b140bc72a51d7
|
|
@ -1,6 +1,7 @@
|
|||
use gfx::display_list::DisplayList;
|
||||
use gfx::compositor::{LayerBuffer, LayerBufferSet};
|
||||
use opts::Opts;
|
||||
use util::time;
|
||||
|
||||
use azure::AzFloat;
|
||||
use azure::azure_hl::{B8G8R8A8, DrawTarget};
|
||||
|
@ -38,95 +39,97 @@ pub fn render_layers(layer_ref: *RenderLayer,
|
|||
let new_buffer_ports = dvec::DVec();
|
||||
|
||||
// Divide up the layer into tiles.
|
||||
let layer: &RenderLayer = unsafe { cast::transmute(layer_ref) };
|
||||
let mut y = 0;
|
||||
while y < layer.size.height {
|
||||
let mut x = 0;
|
||||
while x < layer.size.width {
|
||||
// Figure out the dimension of this tile.
|
||||
let right = uint::min(x + TILE_SIZE, layer.size.width);
|
||||
let bottom = uint::min(y + TILE_SIZE, layer.size.height);
|
||||
let width = right - x;
|
||||
let height = bottom - y;
|
||||
do time::time("rendering: preparing buffers") {
|
||||
let layer: &RenderLayer = unsafe { cast::transmute(layer_ref) };
|
||||
let mut y = 0;
|
||||
while y < layer.size.height {
|
||||
let mut x = 0;
|
||||
while x < layer.size.width {
|
||||
// Figure out the dimension of this tile.
|
||||
let right = uint::min(x + TILE_SIZE, layer.size.width);
|
||||
let bottom = uint::min(y + TILE_SIZE, layer.size.height);
|
||||
let width = right - x;
|
||||
let height = bottom - y;
|
||||
|
||||
// Round the width up the nearest 32 pixels for DMA on the Mac.
|
||||
let mut stride = width;
|
||||
if stride % 32 != 0 {
|
||||
stride = (stride & !(32 - 1)) + 32;
|
||||
}
|
||||
assert stride % 32 == 0;
|
||||
assert stride >= width;
|
||||
// Round the width up the nearest 32 pixels for DMA on the Mac.
|
||||
let mut stride = width;
|
||||
if stride % 32 != 0 {
|
||||
stride = (stride & !(32 - 1)) + 32;
|
||||
}
|
||||
assert stride % 32 == 0;
|
||||
assert stride >= width;
|
||||
|
||||
debug!("tile stride %u", stride);
|
||||
debug!("tile stride %u", stride);
|
||||
|
||||
let tile_rect = Rect(Point2D(x, y), Size2D(width, height));
|
||||
let tile_rect = Rect(Point2D(x, y), Size2D(width, height));
|
||||
|
||||
let buffer;
|
||||
// FIXME: Try harder to search for a matching tile.
|
||||
// FIXME: Don't use shift; it's bad for perf. Maybe reverse and pop.
|
||||
/*if buffers.len() != 0 && buffers[0].rect == tile_rect {
|
||||
debug!("reusing tile, (%u, %u)", x, y);
|
||||
buffer = buffers.shift();
|
||||
} else {*/
|
||||
// Create a new buffer.
|
||||
debug!("creating tile, (%u, %u)", x, y);
|
||||
let buffer;
|
||||
// FIXME: Try harder to search for a matching tile.
|
||||
// FIXME: Don't use shift; it's bad for perf. Maybe reverse and pop.
|
||||
/*if buffers.len() != 0 && buffers[0].rect == tile_rect {
|
||||
debug!("reusing tile, (%u, %u)", x, y);
|
||||
buffer = buffers.shift();
|
||||
} else {*/
|
||||
// Create a new buffer.
|
||||
debug!("creating tile, (%u, %u)", x, y);
|
||||
|
||||
let size = Size2D(stride as i32, height as i32);
|
||||
let size = Size2D(stride as i32, height as i32);
|
||||
|
||||
let mut data: ~[u8] = ~[0];
|
||||
let offset;
|
||||
unsafe {
|
||||
// FIXME: Evil black magic to ensure that we don't perform a slow memzero
|
||||
// of this buffer. This should be made safe.
|
||||
let mut data: ~[u8] = ~[0];
|
||||
let offset;
|
||||
unsafe {
|
||||
// FIXME: Evil black magic to ensure that we don't perform a slow memzero
|
||||
// of this buffer. This should be made safe.
|
||||
|
||||
let align = 256;
|
||||
let align = 256;
|
||||
|
||||
let len = ((size.width * size.height * 4) as uint) + align;
|
||||
vec::reserve(&mut data, len);
|
||||
vec::raw::set_len(&mut data, len);
|
||||
let len = ((size.width * size.height * 4) as uint) + align;
|
||||
vec::reserve(&mut data, len);
|
||||
vec::raw::set_len(&mut data, len);
|
||||
|
||||
// Round up to the nearest 32-byte-aligned address for DMA on the Mac.
|
||||
let addr: uint = cast::transmute(ptr::to_unsafe_ptr(&data[0]));
|
||||
if addr % align == 0 {
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = align - addr % align;
|
||||
// Round up to the nearest 32-byte-aligned address for DMA on the Mac.
|
||||
let addr: uint = cast::transmute(ptr::to_unsafe_ptr(&data[0]));
|
||||
if addr % align == 0 {
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = align - addr % align;
|
||||
}
|
||||
|
||||
debug!("tile offset is %u, expected addr is %x", offset, addr + offset);
|
||||
}
|
||||
|
||||
debug!("tile offset is %u, expected addr is %x", offset, addr + offset);
|
||||
}
|
||||
buffer = LayerBuffer {
|
||||
draw_target: DrawTarget::new_with_data(opts.render_backend,
|
||||
move data,
|
||||
offset,
|
||||
size,
|
||||
size.width * 4,
|
||||
B8G8R8A8),
|
||||
rect: tile_rect,
|
||||
stride: stride
|
||||
};
|
||||
//}
|
||||
|
||||
buffer = LayerBuffer {
|
||||
draw_target: DrawTarget::new_with_data(opts.render_backend,
|
||||
move data,
|
||||
offset,
|
||||
size,
|
||||
size.width * 4,
|
||||
B8G8R8A8),
|
||||
rect: tile_rect,
|
||||
stride: stride
|
||||
};
|
||||
//}
|
||||
// Create a port and channel pair to receive the new buffer.
|
||||
let (new_buffer_chan, new_buffer_port) = pipes::stream();
|
||||
|
||||
// Create a port and channel pair to receive the new buffer.
|
||||
let (new_buffer_chan, new_buffer_port) = pipes::stream();
|
||||
// Send the buffer to the child.
|
||||
f(layer_ref, move buffer, move new_buffer_chan);
|
||||
|
||||
// Send the buffer to the child.
|
||||
// FIXME: Don't copy the RenderLayer.
|
||||
f(layer_ref, move buffer, move new_buffer_chan);
|
||||
// Enqueue the port.
|
||||
new_buffer_ports.push(move new_buffer_port);
|
||||
|
||||
// Enqueue the port.
|
||||
new_buffer_ports.push(move new_buffer_port);
|
||||
|
||||
x += TILE_SIZE;
|
||||
x += TILE_SIZE;
|
||||
}
|
||||
y += TILE_SIZE;
|
||||
}
|
||||
y += TILE_SIZE;
|
||||
}
|
||||
|
||||
debug!("servo::gfx::render_layers: waiting on ports...");
|
||||
let new_buffers = dvec::DVec();
|
||||
for new_buffer_ports.each |new_buffer_port| {
|
||||
new_buffers.push(new_buffer_port.recv());
|
||||
do time::time("rendering: waiting on subtasks") {
|
||||
for new_buffer_ports.each |new_buffer_port| {
|
||||
new_buffers.push(new_buffer_port.recv());
|
||||
}
|
||||
}
|
||||
|
||||
return LayerBufferSet { buffers: move dvec::unwrap(move new_buffers) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue