mirror of
https://github.com/servo/servo.git
synced 2025-06-19 22:59:03 +01:00
Fix corrupted textures when resizing.
This commit is contained in:
parent
d97f002111
commit
02c57728c5
4 changed files with 16 additions and 17 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use azure::azure_hl::{DrawTarget};
|
use azure::azure_hl::{DrawTarget};
|
||||||
use geom::rect::Rect;
|
use geom::rect::Rect;
|
||||||
|
use geom::size::Size2D;
|
||||||
|
|
||||||
pub struct LayerBuffer {
|
pub struct LayerBuffer {
|
||||||
draw_target: DrawTarget,
|
draw_target: DrawTarget,
|
||||||
|
@ -24,6 +25,6 @@ pub struct LayerBufferSet {
|
||||||
/// The interface used to by the renderer to acquire draw targets for each rendered frame and
|
/// The interface used to by the renderer to acquire draw targets for each rendered frame and
|
||||||
/// submit them to be drawn to the display.
|
/// submit them to be drawn to the display.
|
||||||
pub trait Compositor {
|
pub trait Compositor {
|
||||||
fn paint(&self, layer_buffer_set: LayerBufferSet);
|
fn paint(&self, layer_buffer_set: LayerBufferSet, new_size: Size2D<uint>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,6 @@ pub fn render_layers(layer_ref: *RenderLayer,
|
||||||
let width = right - x;
|
let width = right - x;
|
||||||
let height = bottom - y;
|
let height = bottom - y;
|
||||||
|
|
||||||
let tile_rect = Rect(Point2D(x, y), Size2D(width, height));
|
|
||||||
|
|
||||||
// Round the width up the nearest 32 pixels for DMA on the Mac.
|
// Round the width up the nearest 32 pixels for DMA on the Mac.
|
||||||
let aligned_width = if width % 32 == 0 {
|
let aligned_width = if width % 32 == 0 {
|
||||||
width
|
width
|
||||||
|
@ -63,6 +61,8 @@ pub fn render_layers(layer_ref: *RenderLayer,
|
||||||
|
|
||||||
debug!("tile aligned_width %u", aligned_width);
|
debug!("tile aligned_width %u", aligned_width);
|
||||||
|
|
||||||
|
let tile_rect = Rect(Point2D(x, y), Size2D(aligned_width, height));
|
||||||
|
|
||||||
let buffer;
|
let buffer;
|
||||||
// FIXME: Try harder to search for a matching tile.
|
// FIXME: Try harder to search for a matching tile.
|
||||||
// FIXME: Don't use shift; it's bad for perf. Maybe reverse and pop.
|
// FIXME: Don't use shift; it's bad for perf. Maybe reverse and pop.
|
||||||
|
@ -75,7 +75,7 @@ pub fn render_layers(layer_ref: *RenderLayer,
|
||||||
|
|
||||||
let size = Size2D(aligned_width as i32, height as i32);
|
let size = Size2D(aligned_width as i32, height as i32);
|
||||||
// FIXME: This may not be always true.
|
// FIXME: This may not be always true.
|
||||||
let stride = size.width * 4;
|
let stride = (aligned_width as i32) * 4;
|
||||||
|
|
||||||
let mut data: ~[u8] = ~[0];
|
let mut data: ~[u8] = ~[0];
|
||||||
let offset;
|
let offset;
|
||||||
|
|
|
@ -162,7 +162,7 @@ impl<C: Compositor + Owned> Renderer<C> {
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("renderer: returning surface");
|
debug!("renderer: returning surface");
|
||||||
self.compositor.paint(layer_buffer_set);
|
self.compositor.paint(layer_buffer_set, render_layer.size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,10 @@ impl CompositorTask {
|
||||||
|
|
||||||
/// Messages to the compositor.
|
/// Messages to the compositor.
|
||||||
pub enum Msg {
|
pub enum Msg {
|
||||||
Paint(LayerBufferSet),
|
/// Requests that the compositor paint the given layer buffer set for the given page size.
|
||||||
Exit
|
Paint(LayerBufferSet, Size2D<uint>),
|
||||||
|
/// Requests that the compositor shut down.
|
||||||
|
Exit,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Azure surface wrapping to work with the layers infrastructure.
|
/// Azure surface wrapping to work with the layers infrastructure.
|
||||||
|
@ -132,8 +134,11 @@ fn run_main_loop(port: Port<Msg>,
|
||||||
match port.recv() {
|
match port.recv() {
|
||||||
Exit => *done = true,
|
Exit => *done = true,
|
||||||
|
|
||||||
Paint(new_layer_buffer_set) => {
|
Paint(new_layer_buffer_set, new_size) => {
|
||||||
debug!("osmain: received new frame");
|
debug!("osmain: received new frame");
|
||||||
|
|
||||||
|
*page_size = Size2D(new_size.width as f32, new_size.height as f32);
|
||||||
|
|
||||||
let mut new_layer_buffer_set = new_layer_buffer_set;
|
let mut new_layer_buffer_set = new_layer_buffer_set;
|
||||||
|
|
||||||
// Iterate over the children of the container layer.
|
// Iterate over the children of the container layer.
|
||||||
|
@ -142,7 +147,6 @@ fn run_main_loop(port: Port<Msg>,
|
||||||
// Replace the image layer data with the buffer data. Also compute the page
|
// Replace the image layer data with the buffer data. Also compute the page
|
||||||
// size here.
|
// size here.
|
||||||
let buffers = util::replace(&mut new_layer_buffer_set.buffers, ~[]);
|
let buffers = util::replace(&mut new_layer_buffer_set.buffers, ~[]);
|
||||||
let mut (page_width, page_height) = (0.0f32, 0.0f32);
|
|
||||||
|
|
||||||
for buffers.each |buffer| {
|
for buffers.each |buffer| {
|
||||||
let width = buffer.rect.size.width as uint;
|
let width = buffer.rect.size.width as uint;
|
||||||
|
@ -181,10 +185,6 @@ fn run_main_loop(port: Port<Msg>,
|
||||||
let origin = buffer.rect.origin;
|
let origin = buffer.rect.origin;
|
||||||
let origin = Point2D(origin.x as f32, origin.y as f32);
|
let origin = Point2D(origin.x as f32, origin.y as f32);
|
||||||
|
|
||||||
// Update the page width and height calculations.
|
|
||||||
page_width = page_width.max(&(origin.x + (width as f32)));
|
|
||||||
page_height = page_height.max(&(origin.y + (height as f32)));
|
|
||||||
|
|
||||||
// Set the layer's transform.
|
// Set the layer's transform.
|
||||||
let transform = original_layer_transform.translate(origin.x,
|
let transform = original_layer_transform.translate(origin.x,
|
||||||
origin.y,
|
origin.y,
|
||||||
|
@ -193,8 +193,6 @@ fn run_main_loop(port: Port<Msg>,
|
||||||
image_layer.common.set_transform(transform)
|
image_layer.common.set_transform(transform)
|
||||||
}
|
}
|
||||||
|
|
||||||
*page_size = Size2D(page_width, page_height);
|
|
||||||
|
|
||||||
// TODO: Recycle the old buffers; send them back to the renderer to reuse if
|
// TODO: Recycle the old buffers; send them back to the renderer to reuse if
|
||||||
// it wishes.
|
// it wishes.
|
||||||
|
|
||||||
|
@ -265,8 +263,8 @@ fn run_main_loop(port: Port<Msg>,
|
||||||
|
|
||||||
/// Implementation of the abstract `Compositor` interface.
|
/// Implementation of the abstract `Compositor` interface.
|
||||||
impl Compositor for CompositorTask {
|
impl Compositor for CompositorTask {
|
||||||
fn paint(&self, layer_buffer_set: LayerBufferSet) {
|
fn paint(&self, layer_buffer_set: LayerBufferSet, new_size: Size2D<uint>) {
|
||||||
self.chan.send(Paint(layer_buffer_set))
|
self.chan.send(Paint(layer_buffer_set, new_size))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue