Skip to content
Permalink
Browse files

Auto merge of #22856 - jdm:angle, r=<try>

WIP add angle support

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22856)
<!-- Reviewable:end -->
  • Loading branch information...
bors-servo committed Feb 9, 2019
2 parents 5de6d87 + 211138d commit c5ecb00c061e6cf731cc39cbd93fd3bded1e425f

Some generated files are not rendered by default. Learn more.

@@ -77,6 +77,10 @@ pub struct Opts {
pub load_webfonts_synchronously: bool,

pub headless: bool,

/// Use ANGLE to create the GL context (Windows-only).
pub angle: bool,

pub hard_fail: bool,

/// True if we should bubble intrinsic widths sequentially (`-b`). If this is true, then
@@ -559,6 +563,7 @@ pub fn default_opts() -> Opts {
gc_profile: false,
load_webfonts_synchronously: false,
headless: false,
angle: false,
hard_fail: true,
bubble_inline_sizes_separately: false,
show_debug_fragment_borders: false,
@@ -667,6 +672,11 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
"",
);
opts.optflag("z", "headless", "Headless mode");
opts.optflag(
"",
"angle",
"Use ANGLE to create a GL context (Windows-only)",
);
opts.optflag(
"f",
"hard-fail",
@@ -1005,6 +1015,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
gc_profile: debug_options.gc_profile,
load_webfonts_synchronously: debug_options.load_webfonts_synchronously,
headless: opt_match.opt_present("z"),
angle: opt_match.opt_present("angle"),
hard_fail: opt_match.opt_present("f") && !opt_match.opt_present("F"),
bubble_inline_sizes_separately: bubble_inline_sizes_separately,
profile_script_events: debug_options.profile_script_events,
@@ -310,6 +310,7 @@ def windows_unit():
"mach fetch",

"mach build --dev",
"mach smoketest",
"mach test-unit",
"mach package --dev",
)
@@ -62,6 +62,7 @@ sig = "1.0"
x11 = "2.0.0"

[target.'cfg(target_os = "windows")'.dependencies]
mozangle = { version = "0.1", features = ["egl"] }
winapi = { version = "0.3", features = ["wingdi", "winuser"] }

[target.'cfg(any(target_os = "macos", all(target_arch = "x86_64", target_os = "linux")))'.dependencies]
@@ -0,0 +1,95 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use glutin::{
Api, ContextError, GlAttributes, GlContext, PixelFormatRequirements
};
#[cfg(target_os = "windows")]
use glutin::Context as GlutinContext;
#[cfg(target_os = "windows")]
use crate::platform::windows::egl::EglContext;
use winit::Window;
#[cfg(target_os = "windows")]
use winit::os::windows::WindowExt;

#[cfg(target_os = "windows")]
pub struct Context {
context: EglContext,
}

#[cfg(target_os = "windows")]
pub fn create_context(
pf_reqs: &PixelFormatRequirements,
gl_attr: &GlAttributes<&GlutinContext>,
window: &Window,
) -> Context {
let context = EglContext::new(pf_reqs, gl_attr)
.and_then(|p| p.finish(window.get_hwnd() as _))
.expect("Couldn't create ANGLE context");
Context { context }
}

#[cfg(target_os = "windows")]
impl GlContext for Context {
unsafe fn make_current(&self) -> Result<(), ContextError> {
self.context.make_current()
}

fn is_current(&self) -> bool {
self.context.is_current()
}

fn get_proc_address(&self, addr: &str) -> *const () {
self.context.get_proc_address(addr)
}

fn get_api(&self) -> Api {
self.context.get_api()
}
}

#[cfg(target_os = "windows")]
impl Context {
pub fn swap_buffers(&self) -> Result<(), ContextError> {
self.context.swap_buffers()
}
}

#[cfg(not(target_os = "windows"))]
pub struct Context;

#[cfg(not(target_os = "windows"))]
impl GlContext for Context {
unsafe fn make_current(&self) -> Result<(), ContextError> {
unimplemented!()
}

fn is_current(&self) -> bool {
unimplemented!()
}

fn get_proc_address(&self, _addr: &str) -> *const () {
unimplemented!()
}

fn get_api(&self) -> Api {
unimplemented!()
}
}

#[cfg(not(target_os = "windows"))]
impl Context {
pub fn swap_buffers(&self) -> Result<(), ContextError> {
unimplemented!()
}
}

#[cfg(not(target_os = "windows"))]
pub fn create_context(
_pf_reqs: &PixelFormatRequirements,
_gl_attr: &GlAttributes<&Context>,
_window: &Window,
) -> Context {
unimplemented!("ANGLE is only supported on Windows platforms")
}
@@ -4,6 +4,7 @@

//! A simple application that uses glutin to open a window for Servo to display in.

mod angle;
pub mod keyutils;
pub mod window;

0 comments on commit c5ecb00

Please sign in to comment.
You can’t perform that action at this time.