Update to latest rust-layers

The compositing context, painting context and display metadata have all
been collapsed into a single NativeDisplay class.
This commit is contained in:
Martin Robinson 2015-06-27 09:00:51 -07:00
parent b7923547a7
commit 0f27bd6c4b
13 changed files with 71 additions and 108 deletions

View file

@ -4,7 +4,7 @@
use compositor_layer::{CompositorData, CompositorLayer, WantsScrollEventsFlag};
use compositor_task::{CompositorEventListener, CompositorProxy, CompositorReceiver};
use compositor_task::{CompositorTask, Msg};
use compositor_task::Msg;
use constellation::SendableFrameTree;
use pipeline::CompositionPipeline;
use scrolling::ScrollingTimerProxy;
@ -23,6 +23,7 @@ use gleam::gl::types::{GLint, GLsizei};
use gleam::gl;
use layers::geometry::{DevicePixel, LayerPixel};
use layers::layers::{BufferRequest, Layer, LayerBuffer, LayerBufferSet};
use layers::platform::surface::NativeDisplay;
use layers::rendergl::RenderContext;
use layers::rendergl;
use layers::scene::Scene;
@ -64,6 +65,9 @@ pub struct IOCompositor<Window: WindowMethods> {
/// The application window.
window: Rc<Window>,
/// The display this compositor targets.
native_display: NativeDisplay,
/// The port on which we receive messages.
port: Box<CompositorReceiver>,
@ -251,8 +255,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {
Some(_) => CompositeTarget::PngFile,
None => CompositeTarget::Window
};
let native_display = window.native_display();
IOCompositor {
window: window,
native_display: native_display,
port: receiver,
context: None,
root_pipeline: None,
@ -361,8 +367,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.send_buffer_requests_for_all_layers();
}
(Msg::GetGraphicsMetadata(chan), ShutdownState::NotShuttingDown) => {
chan.send(Some(self.window.native_metadata())).unwrap();
(Msg::GetNativeDisplay(chan), ShutdownState::NotShuttingDown) => {
chan.send(Some(self.native_display.clone())).unwrap();
}
(Msg::SetLayerRect(pipeline_id, layer_id, rect),
@ -1436,9 +1442,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
fn initialize_compositing(&mut self) {
let context = CompositorTask::create_graphics_context(&self.window.native_metadata());
let show_debug_borders = opts::get().show_debug_borders;
self.context = Some(rendergl::RenderContext::new(context,
self.context = Some(rendergl::RenderContext::new(self.native_display.clone(),
show_debug_borders,
opts::get().output_file.is_some()))
}

View file

@ -13,7 +13,7 @@ use windowing::{WindowEvent, WindowMethods};
use euclid::point::Point2D;
use euclid::rect::Rect;
use layers::platform::surface::{NativeCompositingGraphicsContext, NativeGraphicsMetadata};
use layers::platform::surface::NativeDisplay;
use layers::layers::LayerBufferSet;
use msg::compositor_msg::{Epoch, LayerId, LayerProperties, FrameTreeId};
use msg::compositor_msg::{PaintListener, ScriptListener};
@ -91,9 +91,9 @@ impl ScriptListener for Box<CompositorProxy+'static+Send> {
/// Implementation of the abstract `PaintListener` interface.
impl PaintListener for Box<CompositorProxy+'static+Send> {
fn graphics_metadata(&mut self) -> Option<NativeGraphicsMetadata> {
fn native_display(&mut self) -> Option<NativeDisplay> {
let (chan, port) = channel();
self.send(Msg::GetGraphicsMetadata(chan));
self.send(Msg::GetNativeDisplay(chan));
// If the compositor is shutting down when a paint task
// is being created, the compositor won't respond to
// this message, resulting in an eventual panic. Instead,
@ -141,7 +141,7 @@ pub enum Msg {
/// is the pixel format.
///
/// The headless compositor returns `None`.
GetGraphicsMetadata(Sender<Option<NativeGraphicsMetadata>>),
GetNativeDisplay(Sender<Option<NativeDisplay>>),
/// Tells the compositor to create or update the layers for a pipeline if necessary
/// (i.e. if no layer with that ID exists).
@ -191,7 +191,7 @@ impl Debug for Msg {
match *self {
Msg::Exit(..) => write!(f, "Exit"),
Msg::ShutdownComplete(..) => write!(f, "ShutdownComplete"),
Msg::GetGraphicsMetadata(..) => write!(f, "GetGraphicsMetadata"),
Msg::GetNativeDisplay(..) => write!(f, "GetNativeDisplay"),
Msg::InitializeLayersForPipeline(..) => write!(f, "InitializeLayersForPipeline"),
Msg::SetLayerRect(..) => write!(f, "SetLayerRect"),
Msg::ScrollFragmentPoint(..) => write!(f, "ScrollFragmentPoint"),
@ -219,20 +219,6 @@ impl Debug for Msg {
pub struct CompositorTask;
impl CompositorTask {
/// Creates a graphics context. Platform-specific.
///
/// FIXME(pcwalton): Probably could be less platform-specific, using the metadata abstraction.
#[cfg(target_os="linux")]
pub fn create_graphics_context(native_metadata: &NativeGraphicsMetadata)
-> NativeCompositingGraphicsContext {
NativeCompositingGraphicsContext::from_display(native_metadata.display)
}
#[cfg(not(target_os="linux"))]
pub fn create_graphics_context(_: &NativeGraphicsMetadata)
-> NativeCompositingGraphicsContext {
NativeCompositingGraphicsContext::new()
}
pub fn create<Window>(window: Option<Rc<Window>>,
sender: Box<CompositorProxy+Send>,
receiver: Box<CompositorReceiver>,

View file

@ -80,7 +80,7 @@ impl CompositorEventListener for NullCompositor {
return false
}
Msg::GetGraphicsMetadata(chan) => {
Msg::GetNativeDisplay(chan) => {
chan.send(None).unwrap();
}

View file

@ -10,7 +10,7 @@ use euclid::point::TypedPoint2D;
use euclid::scale_factor::ScaleFactor;
use euclid::size::TypedSize2D;
use layers::geometry::DevicePixel;
use layers::platform::surface::NativeGraphicsMetadata;
use layers::platform::surface::NativeDisplay;
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
use net::net_error_list::NetError;
use script_traits::MouseButton;
@ -116,8 +116,8 @@ pub trait WindowMethods {
/// Returns the hidpi factor of the monitor.
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32>;
/// Gets the OS native graphics information for this window.
fn native_metadata(&self) -> NativeGraphicsMetadata;
/// Gets the OS native graphics display for this window.
fn native_display(&self) -> NativeDisplay;
/// Creates a channel to the compositor. The dummy parameter is needed because we don't have
/// UFCS in Rust yet.