mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 17:55:50 +00:00
servo: Merge #6525 - Update to latest rust-layers (from mrobinson:simplify-display); r=glennw
The compositing context, painting context and display metadata have all been collapsed into a single NativeDisplay class. Source-Repo: https://github.com/servo/servo Source-Revision: 4674afe846df6720882da28cbd2c3087c17d0b22
This commit is contained in:
parent
a04c2b3c4d
commit
94211ab952
@ -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),
|
||||
@ -1446,9 +1452,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()))
|
||||
}
|
||||
|
@ -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>,
|
||||
|
@ -80,7 +80,7 @@ impl CompositorEventListener for NullCompositor {
|
||||
return false
|
||||
}
|
||||
|
||||
Msg::GetGraphicsMetadata(chan) => {
|
||||
Msg::GetNativeDisplay(chan) => {
|
||||
chan.send(None).unwrap();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
@ -119,8 +119,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.
|
||||
|
@ -5,7 +5,7 @@
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use euclid::size::Size2D;
|
||||
use layers::platform::surface::NativePaintingGraphicsContext;
|
||||
use layers::platform::surface::NativeDisplay;
|
||||
use layers::layers::LayerBuffer;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::mem;
|
||||
@ -71,14 +71,14 @@ impl BufferMap {
|
||||
}
|
||||
|
||||
/// 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());
|
||||
|
||||
// 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.
|
||||
if self.mem + new_buffer.get_mem() > self.max_mem && self.map.len() == 1 &&
|
||||
self.map.contains_key(&new_key) {
|
||||
new_buffer.destroy(graphics_context);
|
||||
new_buffer.destroy(display);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ impl BufferMap {
|
||||
let list = &mut self.map.get_mut(&old_key).unwrap().buffers;
|
||||
let condemned_buffer = list.pop().take().unwrap();
|
||||
self.mem -= condemned_buffer.get_mem();
|
||||
condemned_buffer.destroy(graphics_context);
|
||||
condemned_buffer.destroy(display);
|
||||
list.is_empty()
|
||||
}
|
||||
{ // then
|
||||
@ -151,11 +151,11 @@ impl BufferMap {
|
||||
}
|
||||
|
||||
/// 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());
|
||||
for (_, value) in map.into_iter() {
|
||||
for tile in value.buffers.into_iter() {
|
||||
tile.destroy(graphics_context)
|
||||
tile.destroy(display)
|
||||
}
|
||||
}
|
||||
self.mem = 0
|
||||
|
@ -16,8 +16,7 @@ use euclid::Matrix4;
|
||||
use euclid::point::Point2D;
|
||||
use euclid::rect::Rect;
|
||||
use euclid::size::Size2D;
|
||||
use layers::platform::surface::{NativeGraphicsMetadata, NativePaintingGraphicsContext};
|
||||
use layers::platform::surface::NativeSurface;
|
||||
use layers::platform::surface::{NativeDisplay, NativeSurface};
|
||||
use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet};
|
||||
use layers;
|
||||
use canvas_traits::CanvasMsg;
|
||||
@ -127,7 +126,7 @@ pub struct PaintTask<C> {
|
||||
pub reporter_name: String,
|
||||
|
||||
/// The native graphics context.
|
||||
native_graphics_context: Option<NativePaintingGraphicsContext>,
|
||||
native_display: Option<NativeDisplay>,
|
||||
|
||||
/// The root stacking context sent to us by the layout thread.
|
||||
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
|
||||
// the whole PaintTask struct.
|
||||
macro_rules! native_graphics_context(
|
||||
macro_rules! native_display(
|
||||
($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
|
||||
// shutdown message.
|
||||
let mut compositor = compositor;
|
||||
let native_graphics_context = compositor.graphics_metadata().map(
|
||||
|md| NativePaintingGraphicsContext::from_metadata(&md));
|
||||
let worker_threads = WorkerThreadProxy::spawn(compositor.graphics_metadata(),
|
||||
let native_display = compositor.native_display().map(
|
||||
|display| display);
|
||||
let worker_threads = WorkerThreadProxy::spawn(native_display.clone(),
|
||||
font_cache_task,
|
||||
time_profiler_chan.clone());
|
||||
|
||||
@ -200,7 +199,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||
time_profiler_chan: time_profiler_chan,
|
||||
mem_profiler_chan: mem_profiler_chan,
|
||||
reporter_name: reporter_name,
|
||||
native_graphics_context: native_graphics_context,
|
||||
native_display: native_display,
|
||||
root_stacking_context: None,
|
||||
paint_permission: false,
|
||||
current_epoch: None,
|
||||
@ -213,7 +212,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||
paint_task.start();
|
||||
|
||||
// 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),
|
||||
None => (),
|
||||
}
|
||||
@ -298,7 +297,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||
self.used_buffer_count -= unused_buffers.len();
|
||||
|
||||
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 {
|
||||
@ -385,7 +384,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||
// Create an empty native surface. We mark it as not leaking
|
||||
// in case it dies in transit to the compositor task.
|
||||
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));
|
||||
native_surface.mark_wont_leak();
|
||||
|
||||
@ -528,7 +527,7 @@ struct WorkerThreadProxy {
|
||||
}
|
||||
|
||||
impl WorkerThreadProxy {
|
||||
fn spawn(native_graphics_metadata: Option<NativeGraphicsMetadata>,
|
||||
fn spawn(native_display: Option<NativeDisplay>,
|
||||
font_cache_task: FontCacheTask,
|
||||
time_profiler_chan: time::ProfilerChan)
|
||||
-> Vec<WorkerThreadProxy> {
|
||||
@ -540,13 +539,12 @@ impl WorkerThreadProxy {
|
||||
(0..thread_count).map(|_| {
|
||||
let (from_worker_sender, from_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 time_profiler_chan = time_profiler_chan.clone();
|
||||
spawn_named("PaintWorker".to_owned(), move || {
|
||||
let mut worker_thread = WorkerThread::new(from_worker_sender,
|
||||
to_worker_receiver,
|
||||
native_graphics_metadata,
|
||||
native_display,
|
||||
font_cache_task,
|
||||
time_profiler_chan);
|
||||
worker_thread.main();
|
||||
@ -588,7 +586,7 @@ impl WorkerThreadProxy {
|
||||
struct WorkerThread {
|
||||
sender: Sender<MsgFromWorkerThread>,
|
||||
receiver: Receiver<MsgToWorkerThread>,
|
||||
native_graphics_context: Option<NativePaintingGraphicsContext>,
|
||||
native_display: Option<NativeDisplay>,
|
||||
font_context: Box<FontContext>,
|
||||
time_profiler_sender: time::ProfilerChan,
|
||||
}
|
||||
@ -596,15 +594,15 @@ struct WorkerThread {
|
||||
impl WorkerThread {
|
||||
fn new(sender: Sender<MsgFromWorkerThread>,
|
||||
receiver: Receiver<MsgToWorkerThread>,
|
||||
native_graphics_metadata: Option<NativeGraphicsMetadata>,
|
||||
native_display: Option<NativeDisplay>,
|
||||
font_cache_task: FontCacheTask,
|
||||
time_profiler_sender: time::ProfilerChan)
|
||||
-> WorkerThread {
|
||||
WorkerThread {
|
||||
sender: sender,
|
||||
receiver: receiver,
|
||||
native_graphics_context: native_graphics_metadata.map(|metadata| {
|
||||
NativePaintingGraphicsContext::from_metadata(&metadata)
|
||||
native_display: native_display.map(|display| {
|
||||
display
|
||||
}),
|
||||
font_context: box FontContext::new(font_cache_task.clone()),
|
||||
time_profiler_sender: time_profiler_sender,
|
||||
@ -645,7 +643,7 @@ impl WorkerThread {
|
||||
// FIXME(pcwalton): Cache the components of draw targets (texture color buffer,
|
||||
// paintbuffers) instead of recreating them.
|
||||
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,
|
||||
native_graphics_context,
|
||||
size,
|
||||
@ -731,7 +729,7 @@ impl WorkerThread {
|
||||
if !opts::get().gpu_painting {
|
||||
let mut buffer = layer_buffer.unwrap();
|
||||
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 {}",
|
||||
buffer.native_surface.get_id());
|
||||
});
|
||||
|
@ -7,7 +7,7 @@ use constellation_msg::{Key, KeyState, KeyModifiers};
|
||||
use euclid::point::Point2D;
|
||||
use euclid::rect::Rect;
|
||||
use euclid::Matrix4;
|
||||
use layers::platform::surface::NativeGraphicsMetadata;
|
||||
use layers::platform::surface::NativeDisplay;
|
||||
use layers::layers::LayerBufferSet;
|
||||
use std::fmt::{Formatter, Debug};
|
||||
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
|
||||
/// submit them to be drawn to the display.
|
||||
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
|
||||
/// creating and/or destroying paint layers as necessary.
|
||||
|
4
servo/components/servo/Cargo.lock
generated
4
servo/components/servo/Cargo.lock
generated
@ -642,7 +642,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
[[package]]
|
||||
name = "layers"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-layers#a3f07d9a7e34fe368aa8010a83ce8979491fc057"
|
||||
source = "git+https://github.com/servo/rust-layers#01bfc9fbb0748af62d89720f67a84e9542fad1d1"
|
||||
dependencies = [
|
||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -877,7 +877,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "offscreen_gl_context"
|
||||
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 = [
|
||||
"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)",
|
||||
|
4
servo/ports/cef/Cargo.lock
generated
4
servo/ports/cef/Cargo.lock
generated
@ -634,7 +634,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
[[package]]
|
||||
name = "layers"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-layers#a3f07d9a7e34fe368aa8010a83ce8979491fc057"
|
||||
source = "git+https://github.com/servo/rust-layers#01bfc9fbb0748af62d89720f67a84e9542fad1d1"
|
||||
dependencies = [
|
||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -857,7 +857,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "offscreen_gl_context"
|
||||
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 = [
|
||||
"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)",
|
||||
|
@ -21,7 +21,7 @@ use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::{Size2D, TypedSize2D};
|
||||
use gleam::gl;
|
||||
use layers::geometry::DevicePixel;
|
||||
use layers::platform::surface::NativeGraphicsMetadata;
|
||||
use layers::platform::surface::NativeDisplay;
|
||||
use libc::{c_char, c_void};
|
||||
use msg::constellation_msg::{Key, KeyModifiers};
|
||||
use net::net_error_list::NetError;
|
||||
@ -265,26 +265,17 @@ impl WindowMethods for Window {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os="macos")]
|
||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
||||
use cgl::{CGLGetCurrentContext, CGLGetPixelFormat};
|
||||
|
||||
// FIXME(pcwalton)
|
||||
#[cfg(target_os="linux")]
|
||||
fn native_display(&self) -> NativeDisplay {
|
||||
use x11::xlib;
|
||||
unsafe {
|
||||
NativeGraphicsMetadata {
|
||||
pixel_format: CGLGetPixelFormat(CGLGetCurrentContext()),
|
||||
}
|
||||
NativeDisplay::new(DISPLAY as *mut xlib::Display)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
||||
use x11::xlib;
|
||||
unsafe {
|
||||
NativeGraphicsMetadata {
|
||||
display: DISPLAY as *mut xlib::Display,
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_os="linux"))]
|
||||
fn native_display(&self) -> NativeDisplay {
|
||||
NativeDisplay::new()
|
||||
}
|
||||
|
||||
fn create_compositor_channel(_: &Option<Rc<Window>>)
|
||||
|
@ -11,7 +11,7 @@ use euclid::size::{Size2D, TypedSize2D};
|
||||
use gleam::gl;
|
||||
use glutin;
|
||||
use layers::geometry::DevicePixel;
|
||||
use layers::platform::surface::NativeGraphicsMetadata;
|
||||
use layers::platform::surface::NativeDisplay;
|
||||
use msg::constellation_msg;
|
||||
use msg::constellation_msg::Key;
|
||||
use net::net_error_list::NetError;
|
||||
@ -617,29 +617,16 @@ impl WindowMethods for Window {
|
||||
}
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
||||
fn native_display(&self) -> NativeDisplay {
|
||||
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 {
|
||||
NativeGraphicsMetadata {
|
||||
pixel_format: CGLGetPixelFormat(CGLGetCurrentContext()),
|
||||
}
|
||||
NativeDisplay::new(self.window.platform_display() as *mut xlib::Display)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os="android")]
|
||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
||||
use egl::egl::GetCurrentDisplay;
|
||||
NativeGraphicsMetadata {
|
||||
display: GetCurrentDisplay(),
|
||||
}
|
||||
#[cfg(not(target_os="linux"))]
|
||||
fn native_display(&self) -> NativeDisplay {
|
||||
NativeDisplay::new()
|
||||
}
|
||||
|
||||
/// Helper function to handle keyboard events.
|
||||
@ -795,10 +782,8 @@ impl WindowMethods for Window {
|
||||
}
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
||||
NativeGraphicsMetadata {
|
||||
display: ptr::null_mut()
|
||||
}
|
||||
fn native_display(&self) -> NativeDisplay {
|
||||
NativeDisplay::new(ptr::null_mut())
|
||||
}
|
||||
|
||||
/// Helper function to handle keyboard events.
|
||||
|
4
servo/ports/gonk/Cargo.lock
generated
4
servo/ports/gonk/Cargo.lock
generated
@ -568,7 +568,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
[[package]]
|
||||
name = "layers"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-layers#a3f07d9a7e34fe368aa8010a83ce8979491fc057"
|
||||
source = "git+https://github.com/servo/rust-layers#01bfc9fbb0748af62d89720f67a84e9542fad1d1"
|
||||
dependencies = [
|
||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -774,7 +774,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "offscreen_gl_context"
|
||||
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 = [
|
||||
"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)",
|
||||
|
@ -9,7 +9,7 @@ use compositing::windowing::{WindowEvent, WindowMethods};
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::{Size2D, TypedSize2D};
|
||||
use layers::geometry::DevicePixel;
|
||||
use layers::platform::surface::NativeGraphicsMetadata;
|
||||
use layers::platform::surface::NativeDisplay;
|
||||
use libc::c_int;
|
||||
use msg::constellation_msg::{Key, KeyModifiers};
|
||||
use net::net_error_list::NetError;
|
||||
@ -819,10 +819,8 @@ impl WindowMethods for Window {
|
||||
ScaleFactor::new(1.0)
|
||||
}
|
||||
|
||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
||||
NativeGraphicsMetadata {
|
||||
display: self.dpy,
|
||||
}
|
||||
fn native_display(&self) -> NativeDisplay {
|
||||
NativeDisplay::new_with_display(self.dpy)
|
||||
}
|
||||
|
||||
fn handle_key(&self, _: Key, _: KeyModifiers) {
|
||||
|
Loading…
Reference in New Issue
Block a user