Skip to main content

windows_composition/
batch.rs

1use super::*;
2
3/// The kinds of work a [`CompositionScopedBatch`] can track for completion.
4#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5pub enum BatchKind {
6    /// Track key-frame and expression animations.
7    Animation,
8    /// Track effect loads.
9    Effect,
10    /// Track infinitely-repeating animations.
11    InfiniteAnimation,
12    /// Track all animations, including infinite ones.
13    AllAnimations,
14}
15
16impl From<BatchKind> for bindings::CompositionBatchTypes {
17    fn from(kind: BatchKind) -> Self {
18        match kind {
19            BatchKind::Animation => Self::Animation,
20            BatchKind::Effect => Self::Effect,
21            BatchKind::InfiniteAnimation => Self::InfiniteAnimation,
22            BatchKind::AllAnimations => Self::AllAnimations,
23        }
24    }
25}
26
27/// Groups the animations started while it is open so they can be sealed
28/// together with [`end`](Self::end).
29///
30/// Create the batch, start the animations, then call [`end`](Self::end) to seal
31/// it so no later work is added to the group.
32pub struct CompositionScopedBatch(pub(crate) bindings::CompositionScopedBatch);
33
34impl CompositionScopedBatch {
35    /// Seals the batch. No further work started after this call is tracked by
36    /// the batch.
37    pub fn end(&self) {
38        self.0.End().unwrap();
39    }
40}