From 7acc0619e6d40cf6a425ceafbde21ff4461f0b5a Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Thu, 19 Feb 2015 15:57:54 -0700 Subject: [PATCH] Correct usage of number of painting threads. Previously this used the number of layout threads to allocate the threadpool. This also makes the member name consistent with the rest of the structure. --- components/gfx/paint_task.rs | 2 +- components/util/opts.rs | 16 ++++++++-------- ports/cef/core.rs | 22 ++++++++++++---------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_task.rs index 1f5c439a0d2..bab531c3a0e 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_task.rs @@ -424,7 +424,7 @@ impl WorkerThreadProxy { let thread_count = if opts::get().gpu_painting { 1 } else { - opts::get().layout_threads + opts::get().paint_threads }; (0..thread_count).map(|_| { let (from_worker_sender, from_worker_receiver) = channel(); diff --git a/components/util/opts.rs b/components/util/opts.rs index b420207bbbe..d868d47dd92 100644 --- a/components/util/opts.rs +++ b/components/util/opts.rs @@ -27,8 +27,8 @@ pub struct Opts { /// How many threads to use for CPU painting (`-t`). /// - /// FIXME(pcwalton): This is not currently used. All painting is sequential. - pub n_paint_threads: uint, + /// Note that painting is sequentialized when using GPU painting. + pub paint_threads: uint, /// True to use GPU painting via Skia-GL, false to use CPU painting via Skia (`-g`). Note that /// compositing is always done on the GPU. @@ -155,7 +155,7 @@ static FORCE_CPU_PAINTING: bool = false; pub fn default_opts() -> Opts { Opts { urls: vec!(), - n_paint_threads: 1, + paint_threads: 1, gpu_painting: false, tile_size: 512, device_pixels_per_px: None, @@ -254,9 +254,9 @@ pub fn from_cmdline_args(args: &[String]) -> bool { ScaleFactor(dppx_str.parse().unwrap()) ); - let mut n_paint_threads: uint = match opt_match.opt_str("t") { - Some(n_paint_threads_str) => n_paint_threads_str.parse().unwrap(), - None => 1, // FIXME: Number of cores. + let mut paint_threads: uint = match opt_match.opt_str("t") { + Some(paint_threads_str) => paint_threads_str.parse().unwrap(), + None => cmp::max(rt::default_sched_threads() * 3 / 4, 1), }; // If only the flag is present, default to a 5 second period for both profilers. @@ -279,7 +279,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool { let mut bubble_inline_sizes_separately = debug_options.contains(&"bubble-widths"); let trace_layout = debug_options.contains(&"trace-layout"); if trace_layout { - n_paint_threads = 1; + paint_threads = 1; layout_threads = 1; bubble_inline_sizes_separately = true; } @@ -300,7 +300,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool { let opts = Opts { urls: urls, - n_paint_threads: n_paint_threads, + paint_threads: paint_threads, gpu_painting: gpu_painting, tile_size: tile_size, device_pixels_per_px: device_pixels_per_px, diff --git a/ports/cef/core.rs b/ports/cef/core.rs index 3250922305e..4db155b36b3 100644 --- a/ports/cef/core.rs +++ b/ports/cef/core.rs @@ -60,10 +60,20 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t, } } + let rendering_threads = unsafe { + if ((*settings).rendering_threads as uint) < 1 { + 1 + } else if (*settings).rendering_threads as uint > MAX_RENDERING_THREADS { + MAX_RENDERING_THREADS + } else { + (*settings).rendering_threads as uint + } + }; + let urls = vec![HOME_URL.to_owned()]; opts::set_opts(opts::Opts { urls: urls, - n_paint_threads: 1, + paint_threads: rendering_threads, gpu_painting: false, tile_size: 512, device_pixels_per_px: None, @@ -71,15 +81,7 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t, memory_profiler_period: None, enable_experimental: false, nonincremental_layout: false, - layout_threads: unsafe { - if ((*settings).rendering_threads as uint) < 1 { - 1 - } else if (*settings).rendering_threads as uint > MAX_RENDERING_THREADS { - MAX_RENDERING_THREADS - } else { - (*settings).rendering_threads as uint - } - }, + layout_threads: rendering_threads, output_file: None, headless: false, hard_fail: false,