mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
gfx: Supply our own buffers to accommodate the Mac DMA requirements
This commit is contained in:
parent
52fddb0b33
commit
76b1344274
2 changed files with 32 additions and 2 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 8402852b2e9efcd041607db03a6a663e58c05370
|
Subproject commit 385867116d04f5d4aa34976bf9794bcb1913f162
|
|
@ -63,9 +63,39 @@ pub fn render_layers(layer: &RenderLayer,
|
||||||
} else {
|
} else {
|
||||||
// Create a new buffer.
|
// Create a new buffer.
|
||||||
debug!("creating tile, (%u, %u)", x, y);
|
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 align = 256;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!("tile offset is %u, expected addr is %x", offset, addr + offset);
|
||||||
|
}
|
||||||
|
|
||||||
buffer = LayerBuffer {
|
buffer = LayerBuffer {
|
||||||
draw_target: DrawTarget::new(opts.render_backend, size, B8G8R8A8),
|
draw_target: DrawTarget::new_with_data(opts.render_backend,
|
||||||
|
move data,
|
||||||
|
offset,
|
||||||
|
size,
|
||||||
|
size.width * 4,
|
||||||
|
B8G8R8A8),
|
||||||
rect: tile_rect,
|
rect: tile_rect,
|
||||||
stride: stride
|
stride: stride
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue