Skip to content

Commit

Permalink
servo: Merge #9781 - Allow user to choose between GL and ES2 (from jd…
Browse files Browse the repository at this point in the history
…m:refactor_gle); r=glennw

Rebase of #8869. Requires servo/rust-layers#232.

Source-Repo: https://github.com/servo/servo
Source-Revision: f3a871ec3ded9efe5dfc07f8a3a39ddd6fb05856

UltraBlame original commit: a174eef4faed2e8280b7e4b5b896e56f6b270d07
  • Loading branch information
marco-c committed Oct 1, 2019
1 parent 4b1b4c0 commit 641f8cf
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 36 deletions.
20 changes: 10 additions & 10 deletions servo/components/servo/Cargo.lock

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

21 changes: 21 additions & 0 deletions servo/components/util/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ pub struct Opts {


pub use_msaa: bool,


pub render_api: RenderApi,
}

fn print_usage(app: &str, opts: &Options) {
Expand Down Expand Up @@ -391,6 +394,14 @@ enum UserAgent {
Gonk,
}

#[derive(Clone, Debug, Eq, Deserialize, PartialEq, Serialize)]
pub enum RenderApi {
GL,
ES2,
}

const DEFAULT_RENDER_API: RenderApi = RenderApi::GL;

fn default_user_agent_string(agent: UserAgent) -> String {
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
const DESKTOP_UA_STRING: &'static str =
Expand Down Expand Up @@ -487,6 +498,7 @@ pub fn default_opts() -> Opts {
use_webrender: false,
webrender_stats: false,
use_msaa: false,
render_api: DEFAULT_RENDER_API,
}
}

Expand Down Expand Up @@ -531,6 +543,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
"A preference to set to enable", "dom.mozbrowser.enabled");
opts.optflag("b", "no-native-titlebar", "Do not use native titlebar");
opts.optflag("w", "webrender", "Use webrender backend");
opts.optopt("G", "graphics", "Select graphics backend (gl or es2)", "gl");

let opt_match = match opts.parse(args) {
Ok(m) => m,
Expand Down Expand Up @@ -675,6 +688,13 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {

let use_webrender = opt_match.opt_present("w") && !opt_match.opt_present("z");

let render_api = match opt_match.opt_str("G") {
Some(ref ga) if ga == "gl" => RenderApi::GL,
Some(ref ga) if ga == "es2" => RenderApi::ES2,
None => DEFAULT_RENDER_API,
_ => args_fail(&format!("error: graphics option must be gl or es2:")),
};

let opts = Opts {
is_running_problem_test: is_running_problem_test,
url: Some(url),
Expand Down Expand Up @@ -704,6 +724,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
user_agent: user_agent,
multiprocess: opt_match.opt_present("M"),
sandbox: opt_match.opt_present("S"),
render_api: render_api,
show_debug_borders: debug_options.show_compositor_borders,
show_debug_fragment_borders: debug_options.show_fragment_borders,
show_debug_parallel_paint: debug_options.show_parallel_paint,
Expand Down
22 changes: 11 additions & 11 deletions servo/ports/cef/Cargo.lock

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

23 changes: 18 additions & 5 deletions servo/ports/glutin/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use style_traits::cursor::Cursor;
use url::Url;
use util::geometry::ScreenPx;
#[cfg(feature = "window")]
use util::opts;
use util::opts::{self, RenderApi};

#[cfg(feature = "window")]
static mut g_nested_event_loop_listener: Option<*mut (NestedEventLoopListener + 'static)> = None;
Expand Down Expand Up @@ -157,9 +157,15 @@ impl Window {
#[cfg(not(target_os = "android"))]
fn gl_version() -> GlRequest {
if opts::get().use_webrender {
GlRequest::Specific(Api::OpenGl, (3, 2))
} else {
GlRequest::Specific(Api::OpenGl, (2, 1))
return GlRequest::Specific(Api::OpenGl, (3, 2));
}
match opts::get().render_api {
RenderApi::GL => {
GlRequest::Specific(Api::OpenGl, (2, 1))
}
RenderApi::ES2 => {
GlRequest::Specific(Api::OpenGlEs, (2, 0))
}
}
}

Expand Down Expand Up @@ -672,7 +678,14 @@ impl WindowMethods for Window {
fn native_display(&self) -> NativeDisplay {
use x11::xlib;
unsafe {
NativeDisplay::new(self.window.platform_display() as *mut xlib::Display)
match opts::get().render_api {
RenderApi::GL => {
NativeDisplay::new(self.window.platform_display() as *mut xlib::Display)
},
RenderApi::ES2 => {
NativeDisplay::new_egl_display()
}
}
}
}

Expand Down
20 changes: 10 additions & 10 deletions servo/ports/gonk/Cargo.lock

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

0 comments on commit 641f8cf

Please # to comment.