mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01: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"
|
name = "metrics"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gfx 0.0.1",
|
|
||||||
"gfx_traits 0.0.1",
|
"gfx_traits 0.0.1",
|
||||||
"ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use euclid::{Transform3D, Point2D, Vector2D, Rect, Size2D, TypedRect, SideOffsets2D};
|
use euclid::{Transform3D, Point2D, Vector2D, Rect, Size2D, TypedRect, SideOffsets2D};
|
||||||
use euclid::num::{One, Zero};
|
use euclid::num::{One, Zero};
|
||||||
use gfx_traits::StackingContextId;
|
use gfx_traits::{self, StackingContextId};
|
||||||
use gfx_traits::print_tree::PrintTree;
|
use gfx_traits::print_tree::PrintTree;
|
||||||
use ipc_channel::ipc::IpcSharedMemory;
|
use ipc_channel::ipc::IpcSharedMemory;
|
||||||
use msg::constellation_msg::PipelineId;
|
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
|
/// Display list sections that make up a stacking context. Each section here refers
|
||||||
/// to the steps in CSS 2.1 Appendix E.
|
/// 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
|
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
|
// Observe notifications about rendered frames if needed right before
|
||||||
// sending the display list to WebRender in order to set time related
|
// sending the display list to WebRender in order to set time related
|
||||||
// Progressive Web Metrics.
|
// 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_api.set_display_list(
|
||||||
self.webrender_document,
|
self.webrender_document,
|
||||||
|
|
|
@ -10,7 +10,6 @@ name = "metrics"
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gfx = {path = "../gfx"}
|
|
||||||
gfx_traits = {path = "../gfx_traits"}
|
gfx_traits = {path = "../gfx_traits"}
|
||||||
ipc-channel = "0.9"
|
ipc-channel = "0.9"
|
||||||
log = "0.3.5"
|
log = "0.3.5"
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
extern crate gfx;
|
|
||||||
extern crate gfx_traits;
|
extern crate gfx_traits;
|
||||||
extern crate ipc_channel;
|
extern crate ipc_channel;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -17,8 +16,7 @@ extern crate servo_config;
|
||||||
extern crate servo_url;
|
extern crate servo_url;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
|
|
||||||
use gfx::display_list::{DisplayItem, DisplayList};
|
use gfx_traits::{Epoch, DisplayList};
|
||||||
use gfx_traits::Epoch;
|
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use profile_traits::time::{ProfilerChan, ProfilerCategory, send_profile_data};
|
use profile_traits::time::{ProfilerChan, ProfilerCategory, send_profile_data};
|
||||||
|
@ -324,24 +322,9 @@ impl PaintTimeMetrics {
|
||||||
return;
|
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, (
|
self.pending_metrics.borrow_mut().insert(epoch, (
|
||||||
profiler_metadata_factory.new_metadata(),
|
profiler_metadata_factory.new_metadata(),
|
||||||
is_contentful,
|
display_list.is_contentful(),
|
||||||
));
|
));
|
||||||
|
|
||||||
// Send the pending metric information to the compositor thread.
|
// 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(
|
paint_time_metrics.maybe_observe_paint_time(
|
||||||
&dummy_profiler_metadata_factory,
|
&dummy_profiler_metadata_factory,
|
||||||
epoch,
|
epoch,
|
||||||
&display_list,
|
&*display_list,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Should not set any metric until navigation start is set.
|
// Should not set any metric until navigation start is set.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue