Skip to content
Permalink
Browse files

Add ANGLE support to default embedding.

  • Loading branch information...
jdm committed Mar 9, 2019
1 parent af077f8 commit 3bfbfa79d9c817ac2d2be30cc76d239782ef848c
Showing with 49 additions and 11 deletions.
  1. +24 −0 Cargo.lock
  2. +11 −0 components/config/opts.rs
  3. +1 −0 ports/glutin/Cargo.toml
  4. +8 −7 ports/glutin/app.rs
  5. +5 −4 ports/glutin/headed_window.rs

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

Oops, something went wrong.
@@ -76,6 +76,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
@@ -558,6 +562,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,
@@ -666,6 +671,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",
@@ -998,6 +1008,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,
@@ -66,6 +66,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]
@@ -184,12 +184,13 @@ fn get_default_url() -> ServoUrl {
cmdline_url.or(pref_url).or(blank_url).unwrap()
}

#[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))]
pub fn gl_version() -> glutin::GlRequest {
glutin::GlRequest::Specific(glutin::Api::OpenGl, (3, 2))
}

#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
pub fn gl_version() -> glutin::GlRequest {
glutin::GlRequest::Specific(glutin::Api::OpenGlEs, (3, 0))
if opts::get().angle {
glutin::GlRequest::Specific(glutin::Api::OpenGlEs, (3, 0))
} else {
glutin::GlRequest::GlThenGles {
opengl_version: (3, 2),
opengles_version: (3, 0),
}
}
}
@@ -14,7 +14,7 @@ use glutin::dpi::{LogicalPosition, LogicalSize, PhysicalSize};
use glutin::os::macos::{ActivationPolicy, WindowBuilderExt};
#[cfg(any(target_os = "linux", target_os = "windows"))]
use glutin::Icon;
use glutin::{ContextBuilder, GlContext, GlWindow};
use glutin::{Api, ContextBuilder, GlContext, GlWindow};
use glutin::{ElementState, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase};
#[cfg(any(target_os = "linux", target_os = "windows"))]
use image;
@@ -145,13 +145,14 @@ impl Window {

glutin_window.show();

let gl = match gl::GlType::default() {
gl::GlType::Gl => unsafe {
let gl = match glutin_window.context().get_api() {
Api::OpenGl => unsafe {
gl::GlFns::load_with(|s| glutin_window.get_proc_address(s) as *const _)
},
gl::GlType::Gles => unsafe {
Api::OpenGlEs => unsafe {
gl::GlesFns::load_with(|s| glutin_window.get_proc_address(s) as *const _)
},
Api::WebGl => unreachable!("webgl is unsupported"),
};

gl.clear_color(0.6, 0.6, 0.6, 1.0);

0 comments on commit 3bfbfa7

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