Use WindowMethods to get native graphics metadata instead of

relying on azure. This is a prerequisite for the switch to glutin.

Tested on Linux, mac. Tested that android + cef build.
This commit is contained in:
Glenn Watson 2014-10-24 13:45:42 +10:00
parent 44eec48c57
commit 2d6626e7ef
12 changed files with 49 additions and 9 deletions

View file

@ -4,6 +4,7 @@ version = "0.0.1"
dependencies = [
"alert 0.1.0 (git+https://github.com/servo/rust-alert#fdc24f13be8d8a2d15214ec228d166b3221b809e)",
"compositing 0.0.1",
"egl 0.1.0 (git+https://github.com/servo/rust-egl#88f2a13812ddbce2bf2317221663a61c31b3e220)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom#b001a76e907befaae1d0d6dd259418a22092da86)",
"glut 0.0.1 (git+https://github.com/servo/rust-glut#01af0162ea0322ad1a40d6adb023a39813605949)",
"layers 0.1.0 (git+https://github.com/servo/rust-layers#eac91e00db9af155f3004b408a18cb6d9f462a25)",

View file

@ -32,3 +32,6 @@ default-features = false
[dependencies.util]
path = "../../../components/util"
[dependencies.egl]
git = "https://github.com/servo/rust-egl"

View file

@ -10,6 +10,7 @@
extern crate alert;
extern crate compositing;
extern crate egl;
extern crate geom;
extern crate glut;
extern crate layers;

View file

@ -18,6 +18,7 @@ use geom::point::{Point2D, TypedPoint2D};
use geom::scale_factor::ScaleFactor;
use geom::size::TypedSize2D;
use layers::geometry::DevicePixel;
use layers::platform::surface::NativeGraphicsMetadata;
use msg::compositor_msg::{IdleRenderState, RenderState, RenderingRenderState};
use msg::compositor_msg::{FinishedLoading, Blank, ReadyState};
use util::geometry::ScreenPx;
@ -187,6 +188,13 @@ impl WindowMethods for Window {
//FIXME: Do nothing in GLUT now.
ScaleFactor(1.0)
}
fn native_metadata(&self) -> NativeGraphicsMetadata {
use egl::egl::GetCurrentDisplay;
NativeGraphicsMetadata {
display: GetCurrentDisplay(),
}
}
}
impl Window {

1
ports/cef/Cargo.lock generated
View file

@ -226,6 +226,7 @@ dependencies = [
"glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo#a15c2d04b8969aea653841d1d79e5fdf68de664b)",
"layers 0.1.0 (git+https://github.com/servo/rust-layers#eac91e00db9af155f3004b408a18cb6d9f462a25)",
"msg 0.0.1",
"opengles 0.1.0 (git+https://github.com/servo/rust-opengles#6776e9c07feb149d34b087039ecf6b2c143e3afc)",
"util 0.0.1",
]

View file

@ -28,3 +28,6 @@ path = "../../components/msg"
[dependencies.util]
path = "../../components/util"
[dependencies.opengles]
git = "https://github.com/servo/rust-opengles"

View file

@ -17,6 +17,7 @@ extern crate libc;
extern crate msg;
extern crate time;
extern crate util;
extern crate opengles;
use geom::scale_factor::ScaleFactor;
use std::rc::Rc;

View file

@ -17,6 +17,7 @@ use geom::scale_factor::ScaleFactor;
use geom::size::TypedSize2D;
use glfw::{mod, Context};
use layers::geometry::DevicePixel;
use layers::platform::surface::NativeGraphicsMetadata;
use libc::c_int;
use msg::compositor_msg::{IdleRenderState, RenderState, RenderingRenderState};
use msg::compositor_msg::{FinishedLoading, Blank, Loading, PerformingLayout, ReadyState};
@ -151,6 +152,23 @@ impl WindowMethods for Window {
let window_size = self.size().width.get();
ScaleFactor((backing_size as f32) / window_size)
}
#[cfg(target_os="linux")]
fn native_metadata(&self) -> NativeGraphicsMetadata {
NativeGraphicsMetadata {
display: unsafe { glfw::ffi::glfwGetX11Display() },
}
}
#[cfg(target_os="macos")]
fn native_metadata(&self) -> NativeGraphicsMetadata {
use opengles::cgl::{CGLGetCurrentContext, CGLGetPixelFormat};
unsafe {
NativeGraphicsMetadata {
pixel_format: CGLGetPixelFormat(CGLGetCurrentContext()),
}
}
}
}
impl Window {