mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Decoupled gfx and metrics
This commit is contained in:
parent
75f39b42ab
commit
4b7cb2080e
7 changed files with 29 additions and 24 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -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)",
|
||||
|
|
|
@ -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.
|
||||
///
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue