Skip to content
Permalink
Browse files

Auto merge of #22856 - jdm:angle, r=paulrouget

Add optional ANGLE support to glutin port

Supporting ANGLE in Servo has two important benefits:
* we can actually run Servo instances on our Windows CI machines, which gives us more confidence that we're not breaking it
* we can continue to use OpenGL on devices like the Hololens, rather than creating platform-specific graphical backends

<!-- 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 May 10, 2019
2 parents 58ebacc + a690d6f commit 7304606d79f38220a3dca0298457717df59d99e0

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

@@ -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,
@@ -115,4 +115,4 @@ webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
webvr_traits = {path = "../webvr_traits"}

[target.'cfg(not(target_os = "ios"))'.dependencies]
mozangle = "0.1"
mozangle = "0.2"
@@ -66,6 +66,7 @@ sig = "1.0"
x11 = "2.0.0"

[target.'cfg(target_os = "windows")'.dependencies]
mozangle = { version = "0.2", 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);
@@ -625,16 +625,23 @@ def build(self, target=None, release=False, dev=False, jobs=None,
servo_exe_dir)
# Search for the generated nspr4.dll
build_path = path.join(servo_exe_dir, "build")
nspr4 = "nspr4.dll"
nspr4_path = None
for root, dirs, files in os.walk(build_path):
if nspr4 in files:
nspr4_path = path.join(root, nspr4)
break
if nspr4_path is None:
print("WARNING: could not find nspr4.dll")
else:
shutil.copy(nspr4_path, servo_exe_dir)

def package_generated_shared_libraries(libs, build_path, servo_exe_dir):
for root, dirs, files in os.walk(build_path):
remaining_libs = list(libs)
for lib in libs:
if lib in files:
shutil.copy(path.join(root, lib), servo_exe_dir)
remaining_libs.remove(lib)
continue
libs = remaining_libs
if not libs:
return
for lib in libs:
print("WARNING: could not find " + lib)

package_generated_shared_libraries(["nspr4.dll", "libEGL.dll"], build_path, servo_exe_dir)

# copy needed gstreamer DLLs in to servo.exe dir
gst_x64 = "X86_64" if msvc_x64 == "64" else "X86"
gst_root = ""
@@ -971,3 +971,13 @@ def update_webgl(self, version=None):
run_globals = {"__file__": run_file}
execfile(run_file, run_globals)
return run_globals["update_conformance"](version, dest_folder, None, patches_dir)

@Command('smoketest',
description='Load a simple page in Servo and ensure that it closes properly',
category='testing')
@CommandArgument('params', nargs='...',
help="Command-line arguments to be passed through to Servo")
def smoketest(self, params):
params = params + ['tests/html/close-on-load.html']
return self.context.commands.dispatch(
'run', self.context, params=params)
@@ -0,0 +1,5 @@
<script>
window.onload = function() {
window.close();
}
</script>

0 comments on commit 7304606

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