Skip to content

Commit

Permalink
自动关闭fas
Browse files Browse the repository at this point in the history
  • Loading branch information
shadow3aaa committed Feb 22, 2024
1 parent 04025da commit 076aeba
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
10 changes: 4 additions & 6 deletions src/framework/scheduler/looper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,10 @@ impl Looper {
.buffers
.values_mut()
.filter(|buffer| buffer.target_fps == target_fps)
.map(|buffer| buffer.normal_event(self.mode))
.filter_map(|buffer| buffer.normal_event(self.mode))
.max()
else {
return;
};

let Some(_target_fps) = target_fps else {
self.disable_fas();
return;
};

Expand All @@ -185,9 +182,10 @@ impl Looper {
.buffers
.values_mut()
.filter(|buffer| buffer.target_fps == target_fps)
.map(|buffer| buffer.jank_event(self.mode))
.filter_map(|buffer| buffer.jank_event(self.mode))
.max()
else {
self.disable_fas();
return;
};

Expand Down
16 changes: 6 additions & 10 deletions src/framework/scheduler/looper/policy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,19 @@ pub enum JankEvent {
}

impl Buffer {
pub fn normal_event(&mut self, mode: Mode) -> NormalEvent {
let Some(policy_data) = PolicyData::extract(self, mode) else {
return NormalEvent::Release;
};
pub fn normal_event(&mut self, mode: Mode) -> Option<NormalEvent> {
let policy_data = PolicyData::extract(self, mode)?;

#[cfg(debug_assertions)]
debug!("policy data: {policy_data:?}");

self.frame_analyze(policy_data)
Some(self.frame_analyze(policy_data))
}

pub fn jank_event(&mut self, mode: Mode) -> JankEvent {
let Some(policy_data) = PolicyData::extract(self, mode) else {
return JankEvent::BigJank;
};
pub fn jank_event(&mut self, mode: Mode) -> Option<JankEvent> {
let policy_data = PolicyData::extract(self, mode)?;

self.jank_analyze(policy_data)
Some(self.jank_analyze(policy_data))
}

fn frame_analyze(&mut self, policy_data: PolicyData) -> NormalEvent {
Expand Down
12 changes: 8 additions & 4 deletions src/framework/scheduler/looper/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ impl Looper {
}

pub fn disable_fas(&mut self) {
if self.state != State::NotWorking {
self.extension.call_extentions(CallBacks::StopFas);
self.controller.init_default(&self.config, &self.extension);
self.state = State::NotWorking;
match self.state {
State::Working => {
self.extension.call_extentions(CallBacks::StopFas);
self.controller.init_default(&self.config, &self.extension);
self.state = State::NotWorking;
}
State::Waiting => self.state = State::NotWorking,
State::NotWorking => (),
}
}

Expand Down

0 comments on commit 076aeba

Please sign in to comment.