tessera_ui_basic_components/pipelines/contrast/
command.rs

1use tessera_ui::{
2    BarrierRequirement, compute::ComputeResourceRef, renderer::compute::command::ComputeCommand,
3};
4
5/// Command to apply a contrast adjustment using a pre-calculated mean luminance.
6///
7/// # Parameters
8/// - `contrast`: The contrast adjustment factor.
9/// - `mean_result_handle`: Handle to the buffer containing mean luminance data.
10///
11/// # Example
12/// ```rust,ignore
13/// use tessera_ui_basic_components::pipelines::contrast::ContrastCommand;
14/// let command = ContrastCommand::new(1.2, mean_result_handle);
15/// ```
16#[derive(Debug, Clone, Copy, PartialEq)]
17pub struct ContrastCommand {
18    /// The contrast adjustment factor.
19    pub contrast: f32,
20    /// A handle to the `wgpu::Buffer` containing the mean luminance data.
21    pub mean_result_handle: ComputeResourceRef,
22}
23
24impl ContrastCommand {
25    /// Creates a new `ContrastCommand`.
26    ///
27    /// # Parameters
28    /// - `contrast`: The contrast adjustment factor.
29    /// - `mean_result_handle`: Handle to the buffer containing mean luminance data.
30    pub fn new(contrast: f32, mean_result_handle: ComputeResourceRef) -> Self {
31        Self {
32            contrast,
33            mean_result_handle,
34        }
35    }
36}
37
38impl ComputeCommand for ContrastCommand {
39    fn barrier(&self) -> tessera_ui::BarrierRequirement {
40        BarrierRequirement::ZERO_PADDING_LOCAL
41    }
42}