aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Streich <georg.streich@bluewin.ch>2018-01-15 16:25:51 +0100
committerGeorg Streich <georg.streich@bluewin.ch>2018-01-15 16:25:51 +0100
commit4b7cb2080e37a8992eb95824753829a36810522f (patch)
tree9a87378159b26d307444f561c28ef4fbc1cb2cc9
parent75f39b42abc88a2597186fe845d2deaa15bdb6da (diff)
downloadservo-4b7cb2080e37a8992eb95824753829a36810522f.tar.gz
servo-4b7cb2080e37a8992eb95824753829a36810522f.zip
Decoupled gfx and metrics
-rw-r--r--Cargo.lock1
-rw-r--r--components/gfx/display_list/mod.rs21
-rw-r--r--components/gfx_traits/lib.rs5
-rw-r--r--components/layout_thread/lib.rs2
-rw-r--r--components/metrics/Cargo.toml1
-rw-r--r--components/metrics/lib.rs21
-rw-r--r--tests/unit/metrics/paint_time.rs2
7 files changed, 29 insertions, 24 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 1f437eec006..30b9e82efd2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1761,7 +1761,6 @@ dependencies = [
name = "metrics"
version = "0.0.1"
dependencies = [
- "gfx 0.0.1",
"gfx_traits 0.0.1",
"ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs
index c4c73e50dc7..fff0d658aec 100644
--- a/components/gfx/display_list/mod.rs
+++ b/components/gfx/display_list/mod.rs
@@ -17,7 +17,7 @@
use app_units::Au;
use euclid::{Transform3D, Point2D, Vector2D, Rect, Size2D, TypedRect, SideOffsets2D};
use euclid::num::{One, Zero};
-use gfx_traits::StackingContextId;
+use gfx_traits::{self, StackingContextId};
use gfx_traits::print_tree::PrintTree;
use ipc_channel::ipc::IpcSharedMemory;
use msg::constellation_msg::PipelineId;
@@ -146,6 +146,25 @@ impl DisplayList {
}
}
+impl gfx_traits::DisplayList for DisplayList {
+ /// Analyze the display list to figure out if this may be the first
+ /// contentful paint (i.e. the display list contains items of type text,
+ /// image, non-white canvas or SVG). Used by metrics.
+ fn is_contentful(&self) -> bool {
+ for item in &self.list {
+ match item {
+ &DisplayItem::Text(_) |
+ &DisplayItem::Image(_) => {
+ return true
+ }
+ _ => (),
+ }
+ }
+
+ false
+ }
+}
+
/// Display list sections that make up a stacking context. Each section here refers
/// to the steps in CSS 2.1 Appendix E.
///
diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs
index 6f5b380dd43..4500a3816da 100644
--- a/components/gfx_traits/lib.rs
+++ b/components/gfx_traits/lib.rs
@@ -105,3 +105,8 @@ pub fn node_id_from_clip_id(id: usize) -> Option<usize> {
}
None
}
+
+pub trait DisplayList {
+ /// Returns true if this display list contains meaningful content.
+ fn is_contentful(&self) -> bool;
+}
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 2c72bd6f4b7..c37d3ada351 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -1042,7 +1042,7 @@ impl LayoutThread {
// Observe notifications about rendered frames if needed right before
// sending the display list to WebRender in order to set time related
// Progressive Web Metrics.
- self.paint_time_metrics.maybe_observe_paint_time(self, epoch, &display_list);
+ self.paint_time_metrics.maybe_observe_paint_time(self, epoch, &*display_list);
self.webrender_api.set_display_list(
self.webrender_document,
diff --git a/components/metrics/Cargo.toml b/components/metrics/Cargo.toml
index 7a05ee9b132..af186366721 100644
--- a/components/metrics/Cargo.toml
+++ b/components/metrics/Cargo.toml
@@ -10,7 +10,6 @@ name = "metrics"
path = "lib.rs"
[dependencies]
-gfx = {path = "../gfx"}
gfx_traits = {path = "../gfx_traits"}
ipc-channel = "0.9"
log = "0.3.5"
diff --git a/components/metrics/lib.rs b/components/metrics/lib.rs
index cacf057729c..59657738e57 100644
--- a/components/metrics/lib.rs
+++ b/components/metrics/lib.rs
@@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-extern crate gfx;
extern crate gfx_traits;
extern crate ipc_channel;
#[macro_use]
@@ -17,8 +16,7 @@ extern crate servo_config;
extern crate servo_url;
extern crate time;
-use gfx::display_list::{DisplayItem, DisplayList};
-use gfx_traits::Epoch;
+use gfx_traits::{Epoch, DisplayList};
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::PipelineId;
use profile_traits::time::{ProfilerChan, ProfilerCategory, send_profile_data};
@@ -324,24 +322,9 @@ impl PaintTimeMetrics {
return;
}
- let mut is_contentful = false;
- // Analyze the display list to figure out if this may be the first
- // contentful paint (i.e. the display list contains items of type text,
- // image, non-white canvas or SVG).
- for item in &display_list.list {
- match item {
- &DisplayItem::Text(_) |
- &DisplayItem::Image(_) => {
- is_contentful = true;
- break;
- }
- _ => (),
- }
- }
-
self.pending_metrics.borrow_mut().insert(epoch, (
profiler_metadata_factory.new_metadata(),
- is_contentful,
+ display_list.is_contentful(),
));
// Send the pending metric information to the compositor thread.
diff --git a/tests/unit/metrics/paint_time.rs b/tests/unit/metrics/paint_time.rs
index e3eb6012c19..01020ea6fef 100644
--- a/tests/unit/metrics/paint_time.rs
+++ b/tests/unit/metrics/paint_time.rs
@@ -69,7 +69,7 @@ fn test_common(display_list: &DisplayList, epoch: Epoch) -> PaintTimeMetrics {
paint_time_metrics.maybe_observe_paint_time(
&dummy_profiler_metadata_factory,
epoch,
- &display_list,
+ &*display_list,
);
// Should not set any metric until navigation start is set.