librashader/librashader-runtime-d3d11/src/parameters.rs

41 lines
1 KiB
Rust
Raw Normal View History

2023-01-13 18:32:21 +11:00
use crate::FilterChain;
2022-12-22 13:39:31 +11:00
use librashader_runtime::parameters::FilterChainParameters;
use std::collections::hash_map::Iter;
2022-12-01 14:50:57 +11:00
2023-01-13 18:32:21 +11:00
impl FilterChainParameters for FilterChain {
2022-12-01 14:50:57 +11:00
fn get_enabled_pass_count(&self) -> usize {
self.common.config.passes_enabled
}
fn set_enabled_pass_count(&mut self, count: usize) {
self.common.config.passes_enabled = count
}
fn enumerate_parameters(&self) -> Iter<String, f32> {
self.common.config.parameters.iter()
}
fn get_parameter(&self, parameter: &str) -> Option<f32> {
2022-12-22 13:39:31 +11:00
self.common
.config
.parameters
.get::<str>(parameter.as_ref())
.copied()
2022-12-01 14:50:57 +11:00
}
fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option<f32> {
2022-12-22 13:39:31 +11:00
if let Some(value) = self
.common
.config
.parameters
.get_mut::<str>(parameter.as_ref())
{
2022-12-01 14:50:57 +11:00
let old = *value;
*value = new_value;
Some(old)
} else {
None
}
}
2022-12-22 13:39:31 +11:00
}