diff options
author | Reid Swan <reidswan@outlook.com> | 2023-10-26 16:14:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-26 14:14:43 +0000 |
commit | e4fc4fa3f512bd64c45dd7035e5fd26ab36cbf7d (patch) | |
tree | 9c94a7616d6b56632a1fbacc0044d865e22fad72 /components/compositing | |
parent | 26a3dffd956b332361c75e5a3cef6dbf4d7584cc (diff) | |
download | servo-e4fc4fa3f512bd64c45dd7035e5fd26ab36cbf7d.tar.gz servo-e4fc4fa3f512bd64c45dd7035e5fd26ab36cbf7d.zip |
Replace the time crate with std::time in components/compositing (#30613)
* Replace the time crate with std::time in components/compositing
Signed-off-by: Reid Swan <reidswan@outlook.com>
* Remove elapsed_since_epoch function
---------
Signed-off-by: Reid Swan <reidswan@outlook.com>
Diffstat (limited to 'components/compositing')
-rw-r--r-- | components/compositing/compositor.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 9e45f2ab7ba..8ea0e4634e5 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -8,6 +8,7 @@ use std::fs::{create_dir_all, File}; use std::io::Write; use std::num::NonZeroU32; use std::rc::Rc; +use std::time::{SystemTime, UNIX_EPOCH}; use canvas::canvas_paint_thread::ImageUpdate; use compositing_traits::{ @@ -42,7 +43,6 @@ use script_traits::{ }; use servo_geometry::{DeviceIndependentPixel, FramebufferUintLength}; use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor}; -use time::{now, precise_time_ns, precise_time_s}; use webrender; use webrender::{CaptureBits, RenderApi, Transaction}; use webrender_api::units::{ @@ -1753,7 +1753,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { // we get the current time, inform the layout thread about it and remove the // pending metric from the list. if !self.pending_paint_metrics.is_empty() { - let paint_time = precise_time_ns(); + let paint_time = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default() + .as_nanos() as u64; let mut to_remove = Vec::new(); // For each pending paint metrics pipeline id for (id, pending_epoch) in &self.pending_paint_metrics { @@ -1974,8 +1977,12 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { return false; } + let now = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default() + .as_secs() as f64; // If a pinch-zoom happened recently, ask for tiles at the new resolution - if self.zoom_action && precise_time_s() - self.zoom_time > 0.3 { + if self.zoom_action && now - self.zoom_time > 0.3 { self.zoom_action = false; } @@ -2055,7 +2062,11 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { } pub fn capture_webrender(&mut self) { - let capture_id = now().to_timespec().sec.to_string(); + let capture_id = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default() + .as_secs() + .to_string(); let available_path = [env::current_dir(), Ok(env::temp_dir())] .iter() .filter_map(|val| { |