-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95c5acf
commit 576f9c8
Showing
5 changed files
with
158 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* Copyright 2023 [email protected] | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. */ | ||
use std::time::Duration; | ||
|
||
use super::super::buffer::Buffer; | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct PolicyData { | ||
pub target_fps: u32, | ||
pub normalized_big_jank_scale: Duration, | ||
pub normalized_jank_scale: Duration, | ||
pub normalized_frame: Duration, | ||
pub normalized_avg_frame: Duration, | ||
} | ||
|
||
impl PolicyData { | ||
pub fn extract(buffer: &Buffer) -> Option<Self> { | ||
let target_fps = buffer.target_fps?; | ||
let window = buffer.windows.get(&target_fps)?; | ||
let normalized_avg_frame = window.avg_normalized(f64::from(target_fps))?; | ||
let last_frame = window.last()?; | ||
let normalized_frame = last_frame * target_fps; | ||
|
||
let normalized_big_jank_scale = Duration::from_secs(5); | ||
let normalized_jank_scale = Duration::from_millis(1700); | ||
|
||
Some(Self { | ||
target_fps, | ||
normalized_big_jank_scale, | ||
normalized_jank_scale, | ||
normalized_frame, | ||
normalized_avg_frame, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters