summaryrefslogtreecommitdiff
path: root/src/render_hint.rs
blob: e4d37c3c46557a1a5056dc84f0d42688ed8bbf54 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::ops::*;

/// A hint to tell a window controller whether the previous render state is
/// intact and can be updated, or was destroyed and needs to be fully redrawn.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RenderHint {
    /// The buffer contents are intact, only updates need to be drawn.
    Update,
    /// The buffer contents were destroyed, a full redraw is required.
    Redraw,
}

impl RenderHint {
    pub fn is_update(&self) -> bool { *self == RenderHint::Update }
    pub fn is_redraw(&self) -> bool { *self == RenderHint::Redraw }
}

impl BitAnd for RenderHint {
    type Output = RenderHint;
    fn bitand(self, other: RenderHint) -> Self::Output {
        if self == RenderHint::Redraw || other == RenderHint::Redraw {
            RenderHint::Redraw
        } else {
            RenderHint::Update
        }
    }
}

impl BitAndAssign for RenderHint {
    fn bitand_assign(&mut self, other: RenderHint) {
        *self = *self & other;
    }
}