Skip to content

Commit

Permalink
Auto merge of #2529 - servo:angle-wrench, r=nical
Browse files Browse the repository at this point in the history
Add ANGLE rendering in Wrench

The `--angle` command-line parameter enables it on Windows, when `--headless` is not also used. It panics on non-Windows.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2529)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo authored Mar 16, 2018
2 parents 486ee5f + 06c43ed commit f7fc88c
Show file tree
Hide file tree
Showing 7 changed files with 761 additions and 33 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion servo-tidy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ packages = [
]

# Files that are ignored for all tidy and lint checks.
files = [ ]
files = [
"./wrench/src/egl.rs", # Copied from glutin
]

# Many directories are currently ignored while we tidy things up
# gradually.
Expand Down
1 change: 1 addition & 0 deletions wrench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ headless = [ "osmesa-sys", "osmesa-src" ]

[target.'cfg(target_os = "windows")'.dependencies]
dwrote = "0.4.1"
mozangle = {version = "0.1.5", features = ["egl"]}

[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
font-loader = "0.6"
72 changes: 72 additions & 0 deletions wrench/src/angle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* 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 http://mozilla.org/MPL/2.0/. */

use glutin;
use glutin::{WindowBuilder, ContextBuilder, EventsLoop, Window, CreationError};

#[cfg(not(windows))]
pub enum Context {}

#[cfg(windows)]
pub use ::egl::Context;

impl Context {
#[cfg(not(windows))]
pub fn with_window(
_: WindowBuilder,
_: ContextBuilder,
_: &EventsLoop,
) -> Result<(Window, Self), CreationError> {
Err(CreationError::PlatformSpecific("ANGLE rendering is only supported on Windows".into()))
}

#[cfg(windows)]
pub fn with_window(
window_builder: WindowBuilder,
context_builder: ContextBuilder,
events_loop: &EventsLoop,
) -> Result<(Window, Self), CreationError> {
use glutin::os::windows::WindowExt;

// FIXME: &context_builder.pf_reqs https://github.com/tomaka/glutin/pull/1002
let pf_reqs = &glutin::PixelFormatRequirements::default();
let gl_attr = &context_builder.gl_attr.map_sharing(|_| unimplemented!());
let window = window_builder.build(events_loop)?;
Self::new(pf_reqs, gl_attr)
.and_then(|p| p.finish(window.get_hwnd() as _))
.map(|context| (window, context))
}
}

#[cfg(not(windows))]
impl glutin::GlContext for Context {
unsafe fn make_current(&self) -> Result<(), glutin::ContextError> {
match *self {}
}

fn is_current(&self) -> bool {
match *self {}
}

fn get_proc_address(&self, _: &str) -> *const () {
match *self {}
}

fn swap_buffers(&self) -> Result<(), glutin::ContextError> {
match *self {}
}

fn get_api(&self) -> glutin::Api {
match *self {}
}

fn get_pixel_format(&self) -> glutin::PixelFormat {
match *self {}
}

fn resize(&self, _: u32, _: u32) {
match *self {}
}
}

3 changes: 3 additions & 0 deletions wrench/src/args.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ args:
short: h
long: headless
help: Enable headless rendering
- angle:
long: angle
help: Enable ANGLE rendering (on Windows only)
- dp_ratio:
short: p
long: device-pixel-ratio
Expand Down
Loading

0 comments on commit f7fc88c

Please sign in to comment.