Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor compositor layer tree design #2748

Merged
merged 1 commit into from Jul 2, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Refactor compositor layer tree design

Instead of having two parallel trees of CompositorLayers and
ContainerLayers, transform CompositorLayer to CompositorData and move
tiling logic to rust-layers.
  • Loading branch information
mrobinson committed Jul 2, 2014
commit 0c2538d06d24a7034d2986b85ffbd8d23697da93
@@ -49,8 +49,7 @@ pub use constellation::Constellation;

mod compositor_task;

mod quadtree;
mod compositor_layer;
mod compositor_data;

mod compositor;
mod headless;

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

@@ -15,7 +15,8 @@ use geom::point::Point2D;
use geom::rect::Rect;
use geom::size::Size2D;
use layers::platform::surface::{NativeCompositingGraphicsContext, NativeGraphicsMetadata};
use servo_msg::compositor_msg::{Epoch, LayerBufferSet, LayerId, LayerMetadata, ReadyState};
use layers::layers::LayerBufferSet;
use servo_msg::compositor_msg::{Epoch, LayerId, LayerMetadata, ReadyState};
use servo_msg::compositor_msg::{RenderListener, RenderState, ScriptListener, ScrollPolicy};
use servo_msg::constellation_msg::{ConstellationChan, PipelineId};
use servo_util::memory::MemoryProfilerChan;

This file was deleted.

@@ -5,7 +5,7 @@
use std::collections::hashmap::HashMap;
use geom::size::Size2D;
use layers::platform::surface::NativePaintingGraphicsContext;
use servo_msg::compositor_msg::Tile;
use layers::quadtree::Tile;
use std::hash::Hash;
use std::hash::sip::SipState;
use std::mem;
@@ -17,11 +17,12 @@ use geom::rect::Rect;
use geom::size::Size2D;
use layers::platform::surface::{NativePaintingGraphicsContext, NativeSurface};
use layers::platform::surface::{NativeSurfaceMethods};
use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet};
use layers;
use native;
use rustrt::task;
use rustrt::task::TaskOpts;
use servo_msg::compositor_msg::{Epoch, IdleRenderState, LayerBuffer, LayerBufferSet, LayerId};
use servo_msg::compositor_msg::{Epoch, IdleRenderState, LayerId};
use servo_msg::compositor_msg::{LayerMetadata, RenderListener, RenderingRenderState, ScrollPolicy};
use servo_msg::constellation_msg::{ConstellationChan, Failure, FailureMsg, PipelineId};
use servo_msg::constellation_msg::{RendererReadyMsg};
@@ -57,23 +58,6 @@ pub enum Msg {
ExitMsg(Option<Sender<()>>),
}

/// A request from the compositor to the renderer for tiles that need to be (re)displayed.
#[deriving(Clone)]
pub struct BufferRequest {
// The rect in pixels that will be drawn to the screen
screen_rect: Rect<uint>,

// The rect in page coordinates that this tile represents
page_rect: Rect<f32>,
}

pub fn BufferRequest(screen_rect: Rect<uint>, page_rect: Rect<f32>) -> BufferRequest {
BufferRequest {
screen_rect: screen_rect,
page_rect: page_rect,
}
}

#[deriving(Clone)]
pub struct RenderChan(Sender<Msg>);

@@ -5,48 +5,14 @@
use azure::azure_hl::Color;
use geom::point::Point2D;
use geom::rect::Rect;
use geom::size::Size2D;
use layers::platform::surface::{NativeGraphicsMetadata, NativePaintingGraphicsContext};
use layers::platform::surface::{NativeSurface, NativeSurfaceMethods};
use layers::platform::surface::NativeGraphicsMetadata;
use layers::layers::LayerBufferSet;
use serialize::{Encoder, Encodable};
use std::fmt::{Formatter, Show};
use std::fmt;

use constellation_msg::PipelineId;

pub struct LayerBuffer {
/// The native surface which can be shared between threads or processes. On Mac this is an
/// `IOSurface`; on Linux this is an X Pixmap; on Android this is an `EGLImageKHR`.
pub native_surface: NativeSurface,

/// The rect in the containing RenderLayer that this represents.
pub rect: Rect<f32>,

/// The rect in pixels that will be drawn to the screen.
pub screen_pos: Rect<uint>,

/// The scale at which this tile is rendered
pub resolution: f32,

/// NB: stride is in pixels, like OpenGL GL_UNPACK_ROW_LENGTH.
pub stride: uint,
}

/// A set of layer buffers. This is an atomic unit used to switch between the front and back
/// buffers.
pub struct LayerBufferSet {
pub buffers: Vec<Box<LayerBuffer>>
}

impl LayerBufferSet {
/// Notes all buffer surfaces will leak if not destroyed via a call to `destroy`.
pub fn mark_will_leak(&mut self) {
for buffer in self.buffers.mut_iter() {
buffer.native_surface.mark_will_leak()
}
}
}

/// The status of the renderer.
#[deriving(PartialEq, Clone)]
pub enum RenderState {
@@ -160,41 +126,3 @@ impl<E, S: Encoder<E>> Encodable<S, E> for Box<ScriptListener> {
Ok(())
}
}

/// The interface used by the quadtree and buffer map to get info about layer buffers.
pub trait Tile {
/// Returns the amount of memory used by the tile
fn get_mem(&self) -> uint;
/// Returns true if the tile is displayable at the given scale
fn is_valid(&self, f32) -> bool;
/// Returns the Size2D of the tile
fn get_size_2d(&self) -> Size2D<uint>;

/// Marks the layer buffer as not leaking. See comments on
/// `NativeSurfaceMethods::mark_wont_leak` for how this is used.
fn mark_wont_leak(&mut self);

/// Destroys the layer buffer. Painting task only.
fn destroy(self, graphics_context: &NativePaintingGraphicsContext);
}

impl Tile for Box<LayerBuffer> {
fn get_mem(&self) -> uint {
// This works for now, but in the future we may want a better heuristic
self.screen_pos.size.width * self.screen_pos.size.height
}
fn is_valid(&self, scale: f32) -> bool {
(self.resolution - scale).abs() < 1.0e-6
}
fn get_size_2d(&self) -> Size2D<uint> {
self.screen_pos.size
}
fn mark_wont_leak(&mut self) {
self.native_surface.mark_wont_leak()
}
fn destroy(self, graphics_context: &NativePaintingGraphicsContext) {
let mut this = self;
this.native_surface.destroy(graphics_context)
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.