Auto merge of #11573 - Ms2ger:opts, r=nox

Remove some options code.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11573)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-06-03 09:50:29 -05:00
commit 1f5b0008ac
6 changed files with 10 additions and 87 deletions

View file

@ -34,7 +34,6 @@ range = {path = "../range"}
rustc-serialize = "0.3"
serde = "0.7"
serde_macros = "0.7"
servo-skia = "0.20130412.0"
smallvec = "0.1"
string_cache = {version = "0.2.18", features = ["heap_size"]}
style = {path = "../style"}

View file

@ -71,7 +71,6 @@ extern crate serde;
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
extern crate simd;
extern crate skia;
extern crate smallvec;
#[macro_use]
extern crate string_cache;

View file

@ -25,7 +25,6 @@ use paint_context::PaintContext;
use profile_traits::mem::{self, ReportsChan};
use profile_traits::time;
use rand::{self, Rng};
use skia::gl_context::GLContext;
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::mem as std_mem;
@ -592,11 +591,7 @@ impl WorkerThreadProxy {
font_cache_thread: FontCacheThread,
time_profiler_chan: time::ProfilerChan)
-> Vec<WorkerThreadProxy> {
let thread_count = if opts::get().gpu_painting {
1
} else {
opts::get().paint_threads
};
let thread_count = opts::get().paint_threads;
(0..thread_count).map(|_| {
let (from_worker_sender, from_worker_receiver) = channel();
let (to_worker_sender, to_worker_receiver) = channel();
@ -650,24 +645,6 @@ struct WorkerThread {
native_display: Option<NativeDisplay>,
font_context: Box<FontContext>,
time_profiler_sender: time::ProfilerChan,
gl_context: Option<Arc<GLContext>>,
}
fn create_gl_context(native_display: Option<NativeDisplay>) -> Option<Arc<GLContext>> {
if !opts::get().gpu_painting {
return None;
}
match native_display {
Some(display) => {
let tile_size = opts::get().tile_size as i32;
GLContext::new(display.platform_display_data(), Size2D::new(tile_size, tile_size))
}
None => {
warn!("Could not create GLContext, falling back to CPU rasterization");
None
}
}
}
impl WorkerThread {
@ -677,14 +654,12 @@ impl WorkerThread {
font_cache_thread: FontCacheThread,
time_profiler_sender: time::ProfilerChan)
-> WorkerThread {
let gl_context = create_gl_context(native_display);
WorkerThread {
sender: sender,
receiver: receiver,
native_display: native_display,
font_context: box FontContext::new(font_cache_thread.clone()),
time_profiler_sender: time_profiler_sender,
gl_context: gl_context,
}
}
@ -710,27 +685,6 @@ impl WorkerThread {
}
}
fn create_draw_target_for_layer_buffer(&self,
size: Size2D<i32>,
layer_buffer: &mut Box<LayerBuffer>)
-> DrawTarget {
match self.gl_context {
Some(ref gl_context) => {
match layer_buffer.native_surface.gl_rasterization_context(gl_context.clone()) {
Some(rasterization_context) => {
DrawTarget::new_with_gl_rasterization_context(rasterization_context,
SurfaceFormat::B8G8R8A8)
}
None => panic!("Could not create GLRasterizationContext for LayerBuffer"),
}
},
None => {
// A missing GLContext means we want CPU rasterization.
DrawTarget::new(BackendType::Skia, size, SurfaceFormat::B8G8R8A8)
}
}
}
fn optimize_and_paint_tile(&mut self,
thread_id: usize,
mut tile: BufferRequest,
@ -742,7 +696,7 @@ impl WorkerThread {
let size = Size2D::new(tile.screen_rect.size.width as i32,
tile.screen_rect.size.height as i32);
let mut buffer = self.create_layer_buffer(&mut tile, scale);
let draw_target = self.create_draw_target_for_layer_buffer(size, &mut buffer);
let draw_target = DrawTarget::new(BackendType::Skia, size, SurfaceFormat::B8G8R8A8);
{
// Build the paint context.
@ -806,15 +760,13 @@ impl WorkerThread {
}
}
// Extract the texture from the draw target and place it into its slot in the buffer. If
// using CPU painting, upload it first.
if self.gl_context.is_none() {
draw_target.snapshot().get_data_surface().with_data(|data| {
buffer.native_surface.upload(native_display!(self), data);
debug!("painting worker thread uploading to native surface {}",
buffer.native_surface.get_id());
});
}
// Extract the texture from the draw target and place it into its slot in the buffer.
// Upload it first.
draw_target.snapshot().get_data_surface().with_data(|data| {
buffer.native_surface.upload(native_display!(self), data);
debug!("painting worker thread uploading to native surface {}",
buffer.native_surface.get_id());
});
draw_target.finish();
buffer
@ -838,7 +790,7 @@ impl WorkerThread {
rect: tile.page_rect,
screen_pos: tile.screen_rect,
resolution: scale,
painted_with_cpu: self.gl_context.is_none(),
painted_with_cpu: true,
content_age: tile.content_age,
}
}

View file

@ -781,7 +781,6 @@ dependencies = [
"serde 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
"servo-fontconfig 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"servo-skia 0.20130412.9 (registry+https://github.com/rust-lang/crates.io-index)",
"simd 0.1.0 (git+https://github.com/huonw/simd)",
"smallvec 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"string_cache 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -35,10 +35,6 @@ pub struct Opts {
/// Note that painting is sequentialized when using GPU painting.
pub paint_threads: usize,
/// 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.
pub gpu_painting: bool,
/// The maximum size of each tile in pixels (`-s`).
pub tile_size: usize,
@ -396,14 +392,6 @@ fn args_fail(msg: &str) -> ! {
process::exit(1)
}
// Always use CPU painting on android.
#[cfg(target_os = "android")]
static FORCE_CPU_PAINTING: bool = true;
#[cfg(not(target_os = "android"))]
static FORCE_CPU_PAINTING: bool = false;
static MULTIPROCESS: AtomicBool = ATOMIC_BOOL_INIT;
#[inline]
@ -466,7 +454,6 @@ pub fn default_opts() -> Opts {
is_running_problem_test: false,
url: Some(Url::parse("about:blank").unwrap()),
paint_threads: 1,
gpu_painting: false,
tile_size: 512,
device_pixels_per_px: None,
time_profiling: None,
@ -679,8 +666,6 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
period.parse().unwrap_or_else(|err| args_fail(&format!("Error parsing option: -m ({})", err)))
});
let gpu_painting = !FORCE_CPU_PAINTING && opt_match.opt_present("g");
let mut layout_threads: usize = match opt_match.opt_str("y") {
Some(layout_threads_str) => layout_threads_str.parse()
.unwrap_or_else(|err| args_fail(&format!("Error parsing option: -y ({})", err))),
@ -769,7 +754,6 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
is_running_problem_test: is_running_problem_test,
url: Some(url),
paint_threads: paint_threads,
gpu_painting: gpu_painting,
tile_size: tile_size,
device_pixels_per_px: device_pixels_per_px,
time_profiling: time_profiling,
@ -849,15 +833,6 @@ pub enum ArgumentParsingResult {
ContentProcess(String),
}
static EXPERIMENTAL_ENABLED: AtomicBool = ATOMIC_BOOL_INIT;
/// Turn on experimental features globally. Normally this is done
/// during initialization by `set` or `from_cmdline_args`, but
/// tests that require experimental features will also set it.
pub fn set_experimental_enabled(new_value: bool) {
EXPERIMENTAL_ENABLED.store(new_value, Ordering::SeqCst);
}
// Make Opts available globally. This saves having to clone and pass
// opts everywhere it is used, which gets particularly cumbersome
// when passing through the DOM structures.