tessera_ui_basic_components/pipelines/image/
command.rs

1use std::{
2    hash::{Hash, Hasher},
3    sync::Arc,
4};
5
6use tessera_ui::DrawCommand;
7
8/// Image pixel data for rendering.
9///
10/// # Fields
11///
12/// - `data`: Raw pixel data (RGBA).
13/// - `width`: Image width in pixels.
14/// - `height`: Image height in pixels.
15#[derive(Debug, Clone)]
16pub struct ImageData {
17    /// Raw RGBA pixel buffer.
18    pub data: Arc<Vec<u8>>,
19    /// Image width in pixels.
20    pub width: u32,
21    /// Image height in pixels.
22    pub height: u32,
23}
24
25impl Hash for ImageData {
26    fn hash<H: Hasher>(&self, state: &mut H) {
27        self.data.as_ref().hash(state);
28        self.width.hash(state);
29        self.height.hash(state);
30    }
31}
32
33impl PartialEq for ImageData {
34    fn eq(&self, other: &Self) -> bool {
35        self.width == other.width
36            && self.height == other.height
37            && self.data.as_ref() == other.data.as_ref()
38    }
39}
40
41impl Eq for ImageData {}
42
43/// Command for rendering an image in a UI component.
44#[derive(Debug, Clone, Hash, PartialEq, Eq)]
45pub struct ImageCommand {
46    /// Shared image buffer used by the draw pass.
47    pub data: Arc<ImageData>,
48}
49
50impl DrawCommand for ImageCommand {
51    fn barrier(&self) -> Option<tessera_ui::BarrierRequirement> {
52        // This command does not require any specific barriers.
53        None
54    }
55}