mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
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:
parent
b7923547a7
commit
0f27bd6c4b
13 changed files with 71 additions and 108 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use compositor_layer::{CompositorData, CompositorLayer, WantsScrollEventsFlag};
|
use compositor_layer::{CompositorData, CompositorLayer, WantsScrollEventsFlag};
|
||||||
use compositor_task::{CompositorEventListener, CompositorProxy, CompositorReceiver};
|
use compositor_task::{CompositorEventListener, CompositorProxy, CompositorReceiver};
|
||||||
use compositor_task::{CompositorTask, Msg};
|
use compositor_task::Msg;
|
||||||
use constellation::SendableFrameTree;
|
use constellation::SendableFrameTree;
|
||||||
use pipeline::CompositionPipeline;
|
use pipeline::CompositionPipeline;
|
||||||
use scrolling::ScrollingTimerProxy;
|
use scrolling::ScrollingTimerProxy;
|
||||||
|
@ -23,6 +23,7 @@ use gleam::gl::types::{GLint, GLsizei};
|
||||||
use gleam::gl;
|
use gleam::gl;
|
||||||
use layers::geometry::{DevicePixel, LayerPixel};
|
use layers::geometry::{DevicePixel, LayerPixel};
|
||||||
use layers::layers::{BufferRequest, Layer, LayerBuffer, LayerBufferSet};
|
use layers::layers::{BufferRequest, Layer, LayerBuffer, LayerBufferSet};
|
||||||
|
use layers::platform::surface::NativeDisplay;
|
||||||
use layers::rendergl::RenderContext;
|
use layers::rendergl::RenderContext;
|
||||||
use layers::rendergl;
|
use layers::rendergl;
|
||||||
use layers::scene::Scene;
|
use layers::scene::Scene;
|
||||||
|
@ -64,6 +65,9 @@ pub struct IOCompositor<Window: WindowMethods> {
|
||||||
/// The application window.
|
/// The application window.
|
||||||
window: Rc<Window>,
|
window: Rc<Window>,
|
||||||
|
|
||||||
|
/// The display this compositor targets.
|
||||||
|
native_display: NativeDisplay,
|
||||||
|
|
||||||
/// The port on which we receive messages.
|
/// The port on which we receive messages.
|
||||||
port: Box<CompositorReceiver>,
|
port: Box<CompositorReceiver>,
|
||||||
|
|
||||||
|
@ -251,8 +255,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
Some(_) => CompositeTarget::PngFile,
|
Some(_) => CompositeTarget::PngFile,
|
||||||
None => CompositeTarget::Window
|
None => CompositeTarget::Window
|
||||||
};
|
};
|
||||||
|
let native_display = window.native_display();
|
||||||
IOCompositor {
|
IOCompositor {
|
||||||
window: window,
|
window: window,
|
||||||
|
native_display: native_display,
|
||||||
port: receiver,
|
port: receiver,
|
||||||
context: None,
|
context: None,
|
||||||
root_pipeline: None,
|
root_pipeline: None,
|
||||||
|
@ -361,8 +367,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
self.send_buffer_requests_for_all_layers();
|
self.send_buffer_requests_for_all_layers();
|
||||||
}
|
}
|
||||||
|
|
||||||
(Msg::GetGraphicsMetadata(chan), ShutdownState::NotShuttingDown) => {
|
(Msg::GetNativeDisplay(chan), ShutdownState::NotShuttingDown) => {
|
||||||
chan.send(Some(self.window.native_metadata())).unwrap();
|
chan.send(Some(self.native_display.clone())).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
(Msg::SetLayerRect(pipeline_id, layer_id, rect),
|
(Msg::SetLayerRect(pipeline_id, layer_id, rect),
|
||||||
|
@ -1436,9 +1442,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize_compositing(&mut self) {
|
fn initialize_compositing(&mut self) {
|
||||||
let context = CompositorTask::create_graphics_context(&self.window.native_metadata());
|
|
||||||
let show_debug_borders = opts::get().show_debug_borders;
|
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,
|
show_debug_borders,
|
||||||
opts::get().output_file.is_some()))
|
opts::get().output_file.is_some()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use windowing::{WindowEvent, WindowMethods};
|
||||||
|
|
||||||
use euclid::point::Point2D;
|
use euclid::point::Point2D;
|
||||||
use euclid::rect::Rect;
|
use euclid::rect::Rect;
|
||||||
use layers::platform::surface::{NativeCompositingGraphicsContext, NativeGraphicsMetadata};
|
use layers::platform::surface::NativeDisplay;
|
||||||
use layers::layers::LayerBufferSet;
|
use layers::layers::LayerBufferSet;
|
||||||
use msg::compositor_msg::{Epoch, LayerId, LayerProperties, FrameTreeId};
|
use msg::compositor_msg::{Epoch, LayerId, LayerProperties, FrameTreeId};
|
||||||
use msg::compositor_msg::{PaintListener, ScriptListener};
|
use msg::compositor_msg::{PaintListener, ScriptListener};
|
||||||
|
@ -91,9 +91,9 @@ impl ScriptListener for Box<CompositorProxy+'static+Send> {
|
||||||
|
|
||||||
/// Implementation of the abstract `PaintListener` interface.
|
/// Implementation of the abstract `PaintListener` interface.
|
||||||
impl PaintListener for Box<CompositorProxy+'static+Send> {
|
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();
|
let (chan, port) = channel();
|
||||||
self.send(Msg::GetGraphicsMetadata(chan));
|
self.send(Msg::GetNativeDisplay(chan));
|
||||||
// If the compositor is shutting down when a paint task
|
// If the compositor is shutting down when a paint task
|
||||||
// is being created, the compositor won't respond to
|
// is being created, the compositor won't respond to
|
||||||
// this message, resulting in an eventual panic. Instead,
|
// this message, resulting in an eventual panic. Instead,
|
||||||
|
@ -141,7 +141,7 @@ pub enum Msg {
|
||||||
/// is the pixel format.
|
/// is the pixel format.
|
||||||
///
|
///
|
||||||
/// The headless compositor returns `None`.
|
/// 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
|
/// Tells the compositor to create or update the layers for a pipeline if necessary
|
||||||
/// (i.e. if no layer with that ID exists).
|
/// (i.e. if no layer with that ID exists).
|
||||||
|
@ -191,7 +191,7 @@ impl Debug for Msg {
|
||||||
match *self {
|
match *self {
|
||||||
Msg::Exit(..) => write!(f, "Exit"),
|
Msg::Exit(..) => write!(f, "Exit"),
|
||||||
Msg::ShutdownComplete(..) => write!(f, "ShutdownComplete"),
|
Msg::ShutdownComplete(..) => write!(f, "ShutdownComplete"),
|
||||||
Msg::GetGraphicsMetadata(..) => write!(f, "GetGraphicsMetadata"),
|
Msg::GetNativeDisplay(..) => write!(f, "GetNativeDisplay"),
|
||||||
Msg::InitializeLayersForPipeline(..) => write!(f, "InitializeLayersForPipeline"),
|
Msg::InitializeLayersForPipeline(..) => write!(f, "InitializeLayersForPipeline"),
|
||||||
Msg::SetLayerRect(..) => write!(f, "SetLayerRect"),
|
Msg::SetLayerRect(..) => write!(f, "SetLayerRect"),
|
||||||
Msg::ScrollFragmentPoint(..) => write!(f, "ScrollFragmentPoint"),
|
Msg::ScrollFragmentPoint(..) => write!(f, "ScrollFragmentPoint"),
|
||||||
|
@ -219,20 +219,6 @@ impl Debug for Msg {
|
||||||
pub struct CompositorTask;
|
pub struct CompositorTask;
|
||||||
|
|
||||||
impl 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>>,
|
pub fn create<Window>(window: Option<Rc<Window>>,
|
||||||
sender: Box<CompositorProxy+Send>,
|
sender: Box<CompositorProxy+Send>,
|
||||||
receiver: Box<CompositorReceiver>,
|
receiver: Box<CompositorReceiver>,
|
||||||
|
|
|
@ -80,7 +80,7 @@ impl CompositorEventListener for NullCompositor {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg::GetGraphicsMetadata(chan) => {
|
Msg::GetNativeDisplay(chan) => {
|
||||||
chan.send(None).unwrap();
|
chan.send(None).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use euclid::point::TypedPoint2D;
|
||||||
use euclid::scale_factor::ScaleFactor;
|
use euclid::scale_factor::ScaleFactor;
|
||||||
use euclid::size::TypedSize2D;
|
use euclid::size::TypedSize2D;
|
||||||
use layers::geometry::DevicePixel;
|
use layers::geometry::DevicePixel;
|
||||||
use layers::platform::surface::NativeGraphicsMetadata;
|
use layers::platform::surface::NativeDisplay;
|
||||||
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
||||||
use net::net_error_list::NetError;
|
use net::net_error_list::NetError;
|
||||||
use script_traits::MouseButton;
|
use script_traits::MouseButton;
|
||||||
|
@ -116,8 +116,8 @@ pub trait WindowMethods {
|
||||||
/// Returns the hidpi factor of the monitor.
|
/// Returns the hidpi factor of the monitor.
|
||||||
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32>;
|
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32>;
|
||||||
|
|
||||||
/// Gets the OS native graphics information for this window.
|
/// Gets the OS native graphics display for this window.
|
||||||
fn native_metadata(&self) -> NativeGraphicsMetadata;
|
fn native_display(&self) -> NativeDisplay;
|
||||||
|
|
||||||
/// Creates a channel to the compositor. The dummy parameter is needed because we don't have
|
/// Creates a channel to the compositor. The dummy parameter is needed because we don't have
|
||||||
/// UFCS in Rust yet.
|
/// UFCS in Rust yet.
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||||
use euclid::size::Size2D;
|
use euclid::size::Size2D;
|
||||||
use layers::platform::surface::NativePaintingGraphicsContext;
|
use layers::platform::surface::NativeDisplay;
|
||||||
use layers::layers::LayerBuffer;
|
use layers::layers::LayerBuffer;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -71,14 +71,14 @@ impl BufferMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Insert a new buffer into the map.
|
/// Insert a new buffer into the map.
|
||||||
pub fn insert(&mut self, graphics_context: &NativePaintingGraphicsContext, new_buffer: Box<LayerBuffer>) {
|
pub fn insert(&mut self, display: &NativeDisplay, new_buffer: Box<LayerBuffer>) {
|
||||||
let new_key = BufferKey::get(new_buffer.get_size_2d());
|
let new_key = BufferKey::get(new_buffer.get_size_2d());
|
||||||
|
|
||||||
// If all our buffers are the same size and we're already at our
|
// If all our buffers are the same size and we're already at our
|
||||||
// memory limit, no need to store this new buffer; just let it drop.
|
// memory limit, no need to store this new buffer; just let it drop.
|
||||||
if self.mem + new_buffer.get_mem() > self.max_mem && self.map.len() == 1 &&
|
if self.mem + new_buffer.get_mem() > self.max_mem && self.map.len() == 1 &&
|
||||||
self.map.contains_key(&new_key) {
|
self.map.contains_key(&new_key) {
|
||||||
new_buffer.destroy(graphics_context);
|
new_buffer.destroy(display);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ impl BufferMap {
|
||||||
let list = &mut self.map.get_mut(&old_key).unwrap().buffers;
|
let list = &mut self.map.get_mut(&old_key).unwrap().buffers;
|
||||||
let condemned_buffer = list.pop().take().unwrap();
|
let condemned_buffer = list.pop().take().unwrap();
|
||||||
self.mem -= condemned_buffer.get_mem();
|
self.mem -= condemned_buffer.get_mem();
|
||||||
condemned_buffer.destroy(graphics_context);
|
condemned_buffer.destroy(display);
|
||||||
list.is_empty()
|
list.is_empty()
|
||||||
}
|
}
|
||||||
{ // then
|
{ // then
|
||||||
|
@ -151,11 +151,11 @@ impl BufferMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destroys all buffers.
|
/// Destroys all buffers.
|
||||||
pub fn clear(&mut self, graphics_context: &NativePaintingGraphicsContext) {
|
pub fn clear(&mut self, display: &NativeDisplay) {
|
||||||
let map = mem::replace(&mut self.map, HashMap::new());
|
let map = mem::replace(&mut self.map, HashMap::new());
|
||||||
for (_, value) in map.into_iter() {
|
for (_, value) in map.into_iter() {
|
||||||
for tile in value.buffers.into_iter() {
|
for tile in value.buffers.into_iter() {
|
||||||
tile.destroy(graphics_context)
|
tile.destroy(display)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.mem = 0
|
self.mem = 0
|
||||||
|
|
|
@ -16,8 +16,7 @@ use euclid::Matrix4;
|
||||||
use euclid::point::Point2D;
|
use euclid::point::Point2D;
|
||||||
use euclid::rect::Rect;
|
use euclid::rect::Rect;
|
||||||
use euclid::size::Size2D;
|
use euclid::size::Size2D;
|
||||||
use layers::platform::surface::{NativeGraphicsMetadata, NativePaintingGraphicsContext};
|
use layers::platform::surface::{NativeDisplay, NativeSurface};
|
||||||
use layers::platform::surface::NativeSurface;
|
|
||||||
use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet};
|
use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet};
|
||||||
use layers;
|
use layers;
|
||||||
use canvas_traits::CanvasMsg;
|
use canvas_traits::CanvasMsg;
|
||||||
|
@ -127,7 +126,7 @@ pub struct PaintTask<C> {
|
||||||
pub reporter_name: String,
|
pub reporter_name: String,
|
||||||
|
|
||||||
/// The native graphics context.
|
/// The native graphics context.
|
||||||
native_graphics_context: Option<NativePaintingGraphicsContext>,
|
native_display: Option<NativeDisplay>,
|
||||||
|
|
||||||
/// The root stacking context sent to us by the layout thread.
|
/// The root stacking context sent to us by the layout thread.
|
||||||
root_stacking_context: Option<Arc<StackingContext>>,
|
root_stacking_context: Option<Arc<StackingContext>>,
|
||||||
|
@ -154,9 +153,9 @@ pub struct PaintTask<C> {
|
||||||
|
|
||||||
// If we implement this as a function, we get borrowck errors from borrowing
|
// If we implement this as a function, we get borrowck errors from borrowing
|
||||||
// the whole PaintTask struct.
|
// the whole PaintTask struct.
|
||||||
macro_rules! native_graphics_context(
|
macro_rules! native_display(
|
||||||
($task:expr) => (
|
($task:expr) => (
|
||||||
$task.native_graphics_context.as_ref().expect("Need a graphics context to do painting")
|
$task.native_display.as_ref().expect("Need a graphics context to do painting")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -178,9 +177,9 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||||
// Ensures that the paint task and graphics context are destroyed before the
|
// Ensures that the paint task and graphics context are destroyed before the
|
||||||
// shutdown message.
|
// shutdown message.
|
||||||
let mut compositor = compositor;
|
let mut compositor = compositor;
|
||||||
let native_graphics_context = compositor.graphics_metadata().map(
|
let native_display = compositor.native_display().map(
|
||||||
|md| NativePaintingGraphicsContext::from_metadata(&md));
|
|display| display);
|
||||||
let worker_threads = WorkerThreadProxy::spawn(compositor.graphics_metadata(),
|
let worker_threads = WorkerThreadProxy::spawn(native_display.clone(),
|
||||||
font_cache_task,
|
font_cache_task,
|
||||||
time_profiler_chan.clone());
|
time_profiler_chan.clone());
|
||||||
|
|
||||||
|
@ -200,7 +199,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
mem_profiler_chan: mem_profiler_chan,
|
mem_profiler_chan: mem_profiler_chan,
|
||||||
reporter_name: reporter_name,
|
reporter_name: reporter_name,
|
||||||
native_graphics_context: native_graphics_context,
|
native_display: native_display,
|
||||||
root_stacking_context: None,
|
root_stacking_context: None,
|
||||||
paint_permission: false,
|
paint_permission: false,
|
||||||
current_epoch: None,
|
current_epoch: None,
|
||||||
|
@ -213,7 +212,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||||
paint_task.start();
|
paint_task.start();
|
||||||
|
|
||||||
// Destroy all the buffers.
|
// Destroy all the buffers.
|
||||||
match paint_task.native_graphics_context.as_ref() {
|
match paint_task.native_display.as_ref() {
|
||||||
Some(ctx) => paint_task.buffer_map.clear(ctx),
|
Some(ctx) => paint_task.buffer_map.clear(ctx),
|
||||||
None => (),
|
None => (),
|
||||||
}
|
}
|
||||||
|
@ -298,7 +297,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||||
self.used_buffer_count -= unused_buffers.len();
|
self.used_buffer_count -= unused_buffers.len();
|
||||||
|
|
||||||
for buffer in unused_buffers.into_iter().rev() {
|
for buffer in unused_buffers.into_iter().rev() {
|
||||||
self.buffer_map.insert(native_graphics_context!(self), buffer);
|
self.buffer_map.insert(native_display!(self), buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if waiting_for_compositor_buffers_to_exit && self.used_buffer_count == 0 {
|
if waiting_for_compositor_buffers_to_exit && self.used_buffer_count == 0 {
|
||||||
|
@ -385,7 +384,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||||
// Create an empty native surface. We mark it as not leaking
|
// Create an empty native surface. We mark it as not leaking
|
||||||
// in case it dies in transit to the compositor task.
|
// in case it dies in transit to the compositor task.
|
||||||
let mut native_surface: NativeSurface =
|
let mut native_surface: NativeSurface =
|
||||||
layers::platform::surface::NativeSurface::new(native_graphics_context!(self),
|
layers::platform::surface::NativeSurface::new(native_display!(self),
|
||||||
Size2D::new(width as i32, height as i32));
|
Size2D::new(width as i32, height as i32));
|
||||||
native_surface.mark_wont_leak();
|
native_surface.mark_wont_leak();
|
||||||
|
|
||||||
|
@ -528,7 +527,7 @@ struct WorkerThreadProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WorkerThreadProxy {
|
impl WorkerThreadProxy {
|
||||||
fn spawn(native_graphics_metadata: Option<NativeGraphicsMetadata>,
|
fn spawn(native_display: Option<NativeDisplay>,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
time_profiler_chan: time::ProfilerChan)
|
time_profiler_chan: time::ProfilerChan)
|
||||||
-> Vec<WorkerThreadProxy> {
|
-> Vec<WorkerThreadProxy> {
|
||||||
|
@ -540,13 +539,12 @@ impl WorkerThreadProxy {
|
||||||
(0..thread_count).map(|_| {
|
(0..thread_count).map(|_| {
|
||||||
let (from_worker_sender, from_worker_receiver) = channel();
|
let (from_worker_sender, from_worker_receiver) = channel();
|
||||||
let (to_worker_sender, to_worker_receiver) = channel();
|
let (to_worker_sender, to_worker_receiver) = channel();
|
||||||
let native_graphics_metadata = native_graphics_metadata.clone();
|
|
||||||
let font_cache_task = font_cache_task.clone();
|
let font_cache_task = font_cache_task.clone();
|
||||||
let time_profiler_chan = time_profiler_chan.clone();
|
let time_profiler_chan = time_profiler_chan.clone();
|
||||||
spawn_named("PaintWorker".to_owned(), move || {
|
spawn_named("PaintWorker".to_owned(), move || {
|
||||||
let mut worker_thread = WorkerThread::new(from_worker_sender,
|
let mut worker_thread = WorkerThread::new(from_worker_sender,
|
||||||
to_worker_receiver,
|
to_worker_receiver,
|
||||||
native_graphics_metadata,
|
native_display,
|
||||||
font_cache_task,
|
font_cache_task,
|
||||||
time_profiler_chan);
|
time_profiler_chan);
|
||||||
worker_thread.main();
|
worker_thread.main();
|
||||||
|
@ -588,7 +586,7 @@ impl WorkerThreadProxy {
|
||||||
struct WorkerThread {
|
struct WorkerThread {
|
||||||
sender: Sender<MsgFromWorkerThread>,
|
sender: Sender<MsgFromWorkerThread>,
|
||||||
receiver: Receiver<MsgToWorkerThread>,
|
receiver: Receiver<MsgToWorkerThread>,
|
||||||
native_graphics_context: Option<NativePaintingGraphicsContext>,
|
native_display: Option<NativeDisplay>,
|
||||||
font_context: Box<FontContext>,
|
font_context: Box<FontContext>,
|
||||||
time_profiler_sender: time::ProfilerChan,
|
time_profiler_sender: time::ProfilerChan,
|
||||||
}
|
}
|
||||||
|
@ -596,15 +594,15 @@ struct WorkerThread {
|
||||||
impl WorkerThread {
|
impl WorkerThread {
|
||||||
fn new(sender: Sender<MsgFromWorkerThread>,
|
fn new(sender: Sender<MsgFromWorkerThread>,
|
||||||
receiver: Receiver<MsgToWorkerThread>,
|
receiver: Receiver<MsgToWorkerThread>,
|
||||||
native_graphics_metadata: Option<NativeGraphicsMetadata>,
|
native_display: Option<NativeDisplay>,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
time_profiler_sender: time::ProfilerChan)
|
time_profiler_sender: time::ProfilerChan)
|
||||||
-> WorkerThread {
|
-> WorkerThread {
|
||||||
WorkerThread {
|
WorkerThread {
|
||||||
sender: sender,
|
sender: sender,
|
||||||
receiver: receiver,
|
receiver: receiver,
|
||||||
native_graphics_context: native_graphics_metadata.map(|metadata| {
|
native_display: native_display.map(|display| {
|
||||||
NativePaintingGraphicsContext::from_metadata(&metadata)
|
display
|
||||||
}),
|
}),
|
||||||
font_context: box FontContext::new(font_cache_task.clone()),
|
font_context: box FontContext::new(font_cache_task.clone()),
|
||||||
time_profiler_sender: time_profiler_sender,
|
time_profiler_sender: time_profiler_sender,
|
||||||
|
@ -645,7 +643,7 @@ impl WorkerThread {
|
||||||
// FIXME(pcwalton): Cache the components of draw targets (texture color buffer,
|
// FIXME(pcwalton): Cache the components of draw targets (texture color buffer,
|
||||||
// paintbuffers) instead of recreating them.
|
// paintbuffers) instead of recreating them.
|
||||||
let native_graphics_context =
|
let native_graphics_context =
|
||||||
native_graphics_context!(self) as *const _ as SkiaGrGLNativeContextRef;
|
native_display!(self) as *const _ as SkiaGrGLNativeContextRef;
|
||||||
let draw_target = DrawTarget::new_with_fbo(BackendType::Skia,
|
let draw_target = DrawTarget::new_with_fbo(BackendType::Skia,
|
||||||
native_graphics_context,
|
native_graphics_context,
|
||||||
size,
|
size,
|
||||||
|
@ -731,7 +729,7 @@ impl WorkerThread {
|
||||||
if !opts::get().gpu_painting {
|
if !opts::get().gpu_painting {
|
||||||
let mut buffer = layer_buffer.unwrap();
|
let mut buffer = layer_buffer.unwrap();
|
||||||
draw_target.snapshot().get_data_surface().with_data(|data| {
|
draw_target.snapshot().get_data_surface().with_data(|data| {
|
||||||
buffer.native_surface.upload(native_graphics_context!(self), data);
|
buffer.native_surface.upload(native_display!(self), data);
|
||||||
debug!("painting worker thread uploading to native surface {}",
|
debug!("painting worker thread uploading to native surface {}",
|
||||||
buffer.native_surface.get_id());
|
buffer.native_surface.get_id());
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,7 +7,7 @@ use constellation_msg::{Key, KeyState, KeyModifiers};
|
||||||
use euclid::point::Point2D;
|
use euclid::point::Point2D;
|
||||||
use euclid::rect::Rect;
|
use euclid::rect::Rect;
|
||||||
use euclid::Matrix4;
|
use euclid::Matrix4;
|
||||||
use layers::platform::surface::NativeGraphicsMetadata;
|
use layers::platform::surface::NativeDisplay;
|
||||||
use layers::layers::LayerBufferSet;
|
use layers::layers::LayerBufferSet;
|
||||||
use std::fmt::{Formatter, Debug};
|
use std::fmt::{Formatter, Debug};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -92,7 +92,7 @@ pub struct LayerProperties {
|
||||||
/// The interface used by the painter to acquire draw targets for each paint frame and
|
/// The interface used by the painter to acquire draw targets for each paint frame and
|
||||||
/// submit them to be drawn to the display.
|
/// submit them to be drawn to the display.
|
||||||
pub trait PaintListener {
|
pub trait PaintListener {
|
||||||
fn graphics_metadata(&mut self) -> Option<NativeGraphicsMetadata>;
|
fn native_display(&mut self) -> Option<NativeDisplay>;
|
||||||
|
|
||||||
/// Informs the compositor of the layers for the given pipeline. The compositor responds by
|
/// Informs the compositor of the layers for the given pipeline. The compositor responds by
|
||||||
/// creating and/or destroying paint layers as necessary.
|
/// creating and/or destroying paint layers as necessary.
|
||||||
|
|
4
components/servo/Cargo.lock
generated
4
components/servo/Cargo.lock
generated
|
@ -642,7 +642,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "layers"
|
name = "layers"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-layers#a3f07d9a7e34fe368aa8010a83ce8979491fc057"
|
source = "git+https://github.com/servo/rust-layers#01bfc9fbb0748af62d89720f67a84e9542fad1d1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||||
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -877,7 +877,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "offscreen_gl_context"
|
name = "offscreen_gl_context"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#9b2a5fc48de8b06d02e0d18329dd6dd797b01d05"
|
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#46c5cc8694b08c09de55821e0e8a00ebe5ed97da"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
4
ports/cef/Cargo.lock
generated
4
ports/cef/Cargo.lock
generated
|
@ -634,7 +634,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "layers"
|
name = "layers"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-layers#a3f07d9a7e34fe368aa8010a83ce8979491fc057"
|
source = "git+https://github.com/servo/rust-layers#01bfc9fbb0748af62d89720f67a84e9542fad1d1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||||
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -857,7 +857,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "offscreen_gl_context"
|
name = "offscreen_gl_context"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#9b2a5fc48de8b06d02e0d18329dd6dd797b01d05"
|
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#46c5cc8694b08c09de55821e0e8a00ebe5ed97da"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -21,7 +21,7 @@ use euclid::scale_factor::ScaleFactor;
|
||||||
use euclid::size::{Size2D, TypedSize2D};
|
use euclid::size::{Size2D, TypedSize2D};
|
||||||
use gleam::gl;
|
use gleam::gl;
|
||||||
use layers::geometry::DevicePixel;
|
use layers::geometry::DevicePixel;
|
||||||
use layers::platform::surface::NativeGraphicsMetadata;
|
use layers::platform::surface::NativeDisplay;
|
||||||
use libc::{c_char, c_void};
|
use libc::{c_char, c_void};
|
||||||
use msg::constellation_msg::{Key, KeyModifiers};
|
use msg::constellation_msg::{Key, KeyModifiers};
|
||||||
use net::net_error_list::NetError;
|
use net::net_error_list::NetError;
|
||||||
|
@ -265,26 +265,17 @@ impl WindowMethods for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os="macos")]
|
#[cfg(target_os="linux")]
|
||||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
fn native_display(&self) -> NativeDisplay {
|
||||||
use cgl::{CGLGetCurrentContext, CGLGetPixelFormat};
|
use x11::xlib;
|
||||||
|
|
||||||
// FIXME(pcwalton)
|
|
||||||
unsafe {
|
unsafe {
|
||||||
NativeGraphicsMetadata {
|
NativeDisplay::new(DISPLAY as *mut xlib::Display)
|
||||||
pixel_format: CGLGetPixelFormat(CGLGetCurrentContext()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(not(target_os="linux"))]
|
||||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
fn native_display(&self) -> NativeDisplay {
|
||||||
use x11::xlib;
|
NativeDisplay::new()
|
||||||
unsafe {
|
|
||||||
NativeGraphicsMetadata {
|
|
||||||
display: DISPLAY as *mut xlib::Display,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_compositor_channel(_: &Option<Rc<Window>>)
|
fn create_compositor_channel(_: &Option<Rc<Window>>)
|
||||||
|
|
|
@ -11,7 +11,7 @@ use euclid::size::{Size2D, TypedSize2D};
|
||||||
use gleam::gl;
|
use gleam::gl;
|
||||||
use glutin;
|
use glutin;
|
||||||
use layers::geometry::DevicePixel;
|
use layers::geometry::DevicePixel;
|
||||||
use layers::platform::surface::NativeGraphicsMetadata;
|
use layers::platform::surface::NativeDisplay;
|
||||||
use msg::constellation_msg;
|
use msg::constellation_msg;
|
||||||
use msg::constellation_msg::Key;
|
use msg::constellation_msg::Key;
|
||||||
use net::net_error_list::NetError;
|
use net::net_error_list::NetError;
|
||||||
|
@ -581,29 +581,16 @@ impl WindowMethods for Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(target_os="linux")]
|
||||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
fn native_display(&self) -> NativeDisplay {
|
||||||
use x11::xlib;
|
use x11::xlib;
|
||||||
NativeGraphicsMetadata {
|
|
||||||
display: unsafe { self.window.platform_display() as *mut xlib::Display }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os="macos")]
|
|
||||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
|
||||||
use cgl::{CGLGetCurrentContext, CGLGetPixelFormat};
|
|
||||||
unsafe {
|
unsafe {
|
||||||
NativeGraphicsMetadata {
|
NativeDisplay::new(self.window.platform_display() as *mut xlib::Display)
|
||||||
pixel_format: CGLGetPixelFormat(CGLGetCurrentContext()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os="android")]
|
#[cfg(not(target_os="linux"))]
|
||||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
fn native_display(&self) -> NativeDisplay {
|
||||||
use egl::egl::GetCurrentDisplay;
|
NativeDisplay::new()
|
||||||
NativeGraphicsMetadata {
|
|
||||||
display: GetCurrentDisplay(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function to handle keyboard events.
|
/// Helper function to handle keyboard events.
|
||||||
|
@ -734,10 +721,8 @@ impl WindowMethods for Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(target_os="linux")]
|
||||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
fn native_display(&self) -> NativeDisplay {
|
||||||
NativeGraphicsMetadata {
|
NativeDisplay::new(ptr::null_mut())
|
||||||
display: ptr::null_mut()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function to handle keyboard events.
|
/// Helper function to handle keyboard events.
|
||||||
|
|
4
ports/gonk/Cargo.lock
generated
4
ports/gonk/Cargo.lock
generated
|
@ -568,7 +568,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "layers"
|
name = "layers"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-layers#a3f07d9a7e34fe368aa8010a83ce8979491fc057"
|
source = "git+https://github.com/servo/rust-layers#01bfc9fbb0748af62d89720f67a84e9542fad1d1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||||
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -774,7 +774,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "offscreen_gl_context"
|
name = "offscreen_gl_context"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#9b2a5fc48de8b06d02e0d18329dd6dd797b01d05"
|
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#46c5cc8694b08c09de55821e0e8a00ebe5ed97da"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -9,7 +9,7 @@ use compositing::windowing::{WindowEvent, WindowMethods};
|
||||||
use euclid::scale_factor::ScaleFactor;
|
use euclid::scale_factor::ScaleFactor;
|
||||||
use euclid::size::{Size2D, TypedSize2D};
|
use euclid::size::{Size2D, TypedSize2D};
|
||||||
use layers::geometry::DevicePixel;
|
use layers::geometry::DevicePixel;
|
||||||
use layers::platform::surface::NativeGraphicsMetadata;
|
use layers::platform::surface::NativeDisplay;
|
||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
use msg::constellation_msg::{Key, KeyModifiers};
|
use msg::constellation_msg::{Key, KeyModifiers};
|
||||||
use net::net_error_list::NetError;
|
use net::net_error_list::NetError;
|
||||||
|
@ -819,10 +819,8 @@ impl WindowMethods for Window {
|
||||||
ScaleFactor::new(1.0)
|
ScaleFactor::new(1.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
fn native_display(&self) -> NativeDisplay {
|
||||||
NativeGraphicsMetadata {
|
NativeDisplay::new_with_display(self.dpy)
|
||||||
display: self.dpy,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_key(&self, _: Key, _: KeyModifiers) {
|
fn handle_key(&self, _: Key, _: KeyModifiers) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue