Auto merge of #6842 - mrobinson:preserve-gl, r=pcwalton

Update to the latest skia

Now GLRasteizationContexts require having an active GLContext. This will
allow preserving GLContexts and possibly framebuffers between
rasterization sessions, improving GL Rasterization performance.

Linux Before:
+ Painting Per Tile    4.5559    4.3392  1.6920  18.5548 74
Painting             170.1554  151.8353  0.0008 350.1093 28

Linux After:
+ Painting Per Tile    3.8726    3.1299  1.5848  12.6732 62
Painting              13.5480   10.8947  0.0029  39.1198 23

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6842)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-07-30 07:29:38 -06:00
commit ccd341cc68
4 changed files with 45 additions and 25 deletions

View file

@ -28,6 +28,7 @@ use msg::constellation_msg::PipelineExitType;
use profile_traits::mem::{self, Reporter, ReporterRequest, ReportsChan}; use profile_traits::mem::{self, Reporter, ReporterRequest, ReportsChan};
use profile_traits::time::{self, profile}; use profile_traits::time::{self, profile};
use rand::{self, Rng}; use rand::{self, Rng};
use skia::gl_context::GLContext;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::mem as std_mem; use std::mem as std_mem;
use std::sync::Arc; use std::sync::Arc;
@ -467,6 +468,24 @@ struct WorkerThread {
native_display: Option<NativeDisplay>, native_display: Option<NativeDisplay>,
font_context: Box<FontContext>, font_context: Box<FontContext>,
time_profiler_sender: time::ProfilerChan, 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 { impl WorkerThread {
@ -476,14 +495,14 @@ impl WorkerThread {
font_cache_task: FontCacheTask, font_cache_task: FontCacheTask,
time_profiler_sender: time::ProfilerChan) time_profiler_sender: time::ProfilerChan)
-> WorkerThread { -> WorkerThread {
let gl_context = create_gl_context(native_display);
WorkerThread { WorkerThread {
sender: sender, sender: sender,
receiver: receiver, receiver: receiver,
native_display: native_display.map(|display| { native_display: native_display,
display
}),
font_context: box FontContext::new(font_cache_task.clone()), font_context: box FontContext::new(font_cache_task.clone()),
time_profiler_sender: time_profiler_sender, time_profiler_sender: time_profiler_sender,
gl_context: gl_context,
} }
} }
@ -507,18 +526,19 @@ impl WorkerThread {
size: Size2D<i32>, size: Size2D<i32>,
layer_buffer: &mut Box<LayerBuffer>) layer_buffer: &mut Box<LayerBuffer>)
-> DrawTarget { -> DrawTarget {
if !opts::get().gpu_painting { match self.gl_context {
DrawTarget::new(BackendType::Skia, size, SurfaceFormat::B8G8R8A8) Some(ref gl_context) => {
} else { match layer_buffer.native_surface.gl_rasterization_context(gl_context.clone()) {
let gl_rasterization_context = Some(rasterization_context) => {
layer_buffer.native_surface.gl_rasterization_context(native_display!(self)); DrawTarget::new_with_gl_rasterization_context(rasterization_context,
match gl_rasterization_context {
Some(gl_rasterization_context) => {
gl_rasterization_context.make_current();
DrawTarget::new_with_gl_rasterization_context(gl_rasterization_context,
SurfaceFormat::B8G8R8A8) SurfaceFormat::B8G8R8A8)
} }
None => panic!("Could not create GPU rasterization context for LayerBuffer"), None => panic!("Could not create GLRasterizationContext for LayerBuffer"),
}
},
None => {
// A missing GLContext means we want CPU rasterization.
DrawTarget::new(BackendType::Skia, size, SurfaceFormat::B8G8R8A8)
} }
} }
} }
@ -596,7 +616,7 @@ impl WorkerThread {
// Extract the texture from the draw target and place it into its slot in the buffer. If // Extract the texture from the draw target and place it into its slot in the buffer. If
// using CPU painting, upload it first. // using CPU painting, upload it first.
if !opts::get().gpu_painting { if self.gl_context.is_none() {
draw_target.snapshot().get_data_surface().with_data(|data| { draw_target.snapshot().get_data_surface().with_data(|data| {
buffer.native_surface.upload(native_display!(self), data); buffer.native_surface.upload(native_display!(self), data);
debug!("painting worker thread uploading to native surface {}", debug!("painting worker thread uploading to native surface {}",
@ -626,7 +646,7 @@ impl WorkerThread {
rect: tile.page_rect, rect: tile.page_rect,
screen_pos: tile.screen_rect, screen_pos: tile.screen_rect,
resolution: scale, resolution: scale,
painted_with_cpu: !opts::get().gpu_painting, painted_with_cpu: self.gl_context.is_none(),
content_age: tile.content_age, content_age: tile.content_age,
} }
} }

View file

@ -55,7 +55,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "azure" name = "azure"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-azure#5d2baca5fbbe3924a76b57b4b98dbbefd62cea99" source = "git+https://github.com/servo/rust-azure#53ac8495ca2618a4e795c402ab24ec96d5d6f596"
dependencies = [ dependencies = [
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -697,7 +697,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "layers" name = "layers"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-layers#251c48b7a3c0d563acd96397679c114add2c4fd7" source = "git+https://github.com/servo/rust-layers#e2283b8ec3d3eb2e10afa8a318deda71dd59d11a"
dependencies = [ dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)", "azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1271,7 +1271,7 @@ dependencies = [
[[package]] [[package]]
name = "skia" name = "skia"
version = "0.0.20130412" version = "0.0.20130412"
source = "git+https://github.com/servo/skia#4569e30e308f33f45ee773e73393d769feaf8494" source = "git+https://github.com/servo/skia#6eddb1b798c8f1fa9182a4ebfe38f2a84c7ef418"
dependencies = [ dependencies = [
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"egl 0.1.0 (git+https://github.com/servo/rust-egl)", "egl 0.1.0 (git+https://github.com/servo/rust-egl)",

6
ports/cef/Cargo.lock generated
View file

@ -54,7 +54,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "azure" name = "azure"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-azure#5d2baca5fbbe3924a76b57b4b98dbbefd62cea99" source = "git+https://github.com/servo/rust-azure#53ac8495ca2618a4e795c402ab24ec96d5d6f596"
dependencies = [ dependencies = [
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -689,7 +689,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "layers" name = "layers"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-layers#251c48b7a3c0d563acd96397679c114add2c4fd7" source = "git+https://github.com/servo/rust-layers#e2283b8ec3d3eb2e10afa8a318deda71dd59d11a"
dependencies = [ dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)", "azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1268,7 +1268,7 @@ dependencies = [
[[package]] [[package]]
name = "skia" name = "skia"
version = "0.0.20130412" version = "0.0.20130412"
source = "git+https://github.com/servo/skia#4569e30e308f33f45ee773e73393d769feaf8494" source = "git+https://github.com/servo/skia#6eddb1b798c8f1fa9182a4ebfe38f2a84c7ef418"
dependencies = [ dependencies = [
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"egl 0.1.0 (git+https://github.com/servo/rust-egl)", "egl 0.1.0 (git+https://github.com/servo/rust-egl)",

6
ports/gonk/Cargo.lock generated
View file

@ -41,7 +41,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "azure" name = "azure"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-azure#5d2baca5fbbe3924a76b57b4b98dbbefd62cea99" source = "git+https://github.com/servo/rust-azure#53ac8495ca2618a4e795c402ab24ec96d5d6f596"
dependencies = [ dependencies = [
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -623,7 +623,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "layers" name = "layers"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-layers#251c48b7a3c0d563acd96397679c114add2c4fd7" source = "git+https://github.com/servo/rust-layers#e2283b8ec3d3eb2e10afa8a318deda71dd59d11a"
dependencies = [ dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)", "azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1166,7 +1166,7 @@ dependencies = [
[[package]] [[package]]
name = "skia" name = "skia"
version = "0.0.20130412" version = "0.0.20130412"
source = "git+https://github.com/servo/skia#4569e30e308f33f45ee773e73393d769feaf8494" source = "git+https://github.com/servo/skia#6eddb1b798c8f1fa9182a4ebfe38f2a84c7ef418"
dependencies = [ dependencies = [
"cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cgl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"egl 0.1.0 (git+https://github.com/servo/rust-egl)", "egl 0.1.0 (git+https://github.com/servo/rust-egl)",