Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ANGLE rendering in Wrench #2529

Merged
merged 1 commit into from Mar 16, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

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

@@ -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.
@@ -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"
@@ -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();

This comment has been minimized.

@SimonSapin

SimonSapin Mar 15, 2018

Author Member

At the moment Wrench does not call any ContextBuilder method that touches the pixel format requirements, so using default() doesn’t make a difference.

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 {}
}
}

@@ -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
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.