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
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// Generated by `scripts/generate.js`

use utils::vk_traits::*;

/// Wrapper for [VkSurfaceTransformFlagsKHR](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkSurfaceTransformFlagsKHR.html).
///
/// Use the macro `VkSurfaceTransformFlags!` as an alternative method to create a structure. For example, these two snippets return the same value:
/// ```
/// VkSurfaceTransformFlags!(identity, rotate_90)
/// ```
/// ```
/// VkSurfaceTransformFlags {
///     identity: true,
///     rotate_90: true,
///     ..VkSurfaceTransformFlags::none()
/// }
/// ```
#[derive(Debug, Clone)]
pub struct VkSurfaceTransformFlags {
    pub identity: bool,
    pub rotate_90: bool,
    pub rotate_180: bool,
    pub rotate_270: bool,
    pub horizontal_mirror: bool,
    pub horizontal_mirror_rotate_90: bool,
    pub horizontal_mirror_rotate_180: bool,
    pub horizontal_mirror_rotate_270: bool,
    pub inherit: bool,
}

#[doc(hidden)]
pub type RawVkSurfaceTransformFlags = u32;

impl VkWrappedType<RawVkSurfaceTransformFlags> for VkSurfaceTransformFlags {
    fn vk_to_raw(src: &VkSurfaceTransformFlags, dst: &mut RawVkSurfaceTransformFlags) {
        *dst = 0;
        if src.identity { *dst |= 0x00000001; }
        if src.rotate_90 { *dst |= 0x00000002; }
        if src.rotate_180 { *dst |= 0x00000004; }
        if src.rotate_270 { *dst |= 0x00000008; }
        if src.horizontal_mirror { *dst |= 0x00000010; }
        if src.horizontal_mirror_rotate_90 { *dst |= 0x00000020; }
        if src.horizontal_mirror_rotate_180 { *dst |= 0x00000040; }
        if src.horizontal_mirror_rotate_270 { *dst |= 0x00000080; }
        if src.inherit { *dst |= 0x00000100; }
    }
}

impl VkRawType<VkSurfaceTransformFlags> for RawVkSurfaceTransformFlags {
    fn vk_to_wrapped(src: &RawVkSurfaceTransformFlags) -> VkSurfaceTransformFlags {
        VkSurfaceTransformFlags {
            identity: (src & 0x00000001) != 0,
            rotate_90: (src & 0x00000002) != 0,
            rotate_180: (src & 0x00000004) != 0,
            rotate_270: (src & 0x00000008) != 0,
            horizontal_mirror: (src & 0x00000010) != 0,
            horizontal_mirror_rotate_90: (src & 0x00000020) != 0,
            horizontal_mirror_rotate_180: (src & 0x00000040) != 0,
            horizontal_mirror_rotate_270: (src & 0x00000080) != 0,
            inherit: (src & 0x00000100) != 0,
        }
    }
}

impl Default for VkSurfaceTransformFlags {
    fn default() -> VkSurfaceTransformFlags {
        VkSurfaceTransformFlags {
            identity: false,
            rotate_90: false,
            rotate_180: false,
            rotate_270: false,
            horizontal_mirror: false,
            horizontal_mirror_rotate_90: false,
            horizontal_mirror_rotate_180: false,
            horizontal_mirror_rotate_270: false,
            inherit: false,
        }
    }
}

impl VkSurfaceTransformFlags {
    
    /// Return a structure with all flags to `false`.
    pub fn none() -> Self {
        VkSurfaceTransformFlags {
            identity: false,
            rotate_90: false,
            rotate_180: false,
            rotate_270: false,
            horizontal_mirror: false,
            horizontal_mirror_rotate_90: false,
            horizontal_mirror_rotate_180: false,
            horizontal_mirror_rotate_270: false,
            inherit: false,
        }
    }
    
    /// Return a structure with all flags to `true`.
    pub fn all() -> Self {
        VkSurfaceTransformFlags {
            identity: true,
            rotate_90: true,
            rotate_180: true,
            rotate_270: true,
            horizontal_mirror: true,
            horizontal_mirror_rotate_90: true,
            horizontal_mirror_rotate_180: true,
            horizontal_mirror_rotate_270: true,
            inherit: true,
        }
    }
    
    /// Return the numerical bit flags corresponding to the structure (as described in the Vulkan specs).
    pub fn to_u32(&self) -> u32 {
        0
        + if self.identity { 0x00000001 } else { 0 }
        + if self.rotate_90 { 0x00000002 } else { 0 }
        + if self.rotate_180 { 0x00000004 } else { 0 }
        + if self.rotate_270 { 0x00000008 } else { 0 }
        + if self.horizontal_mirror { 0x00000010 } else { 0 }
        + if self.horizontal_mirror_rotate_90 { 0x00000020 } else { 0 }
        + if self.horizontal_mirror_rotate_180 { 0x00000040 } else { 0 }
        + if self.horizontal_mirror_rotate_270 { 0x00000080 } else { 0 }
        + if self.inherit { 0x00000100 } else { 0 }
    }
    
    /// Create a structure corresponding to the specified numerical bit flags.
    pub fn from_u32(value: u32) -> Self {
        VkSurfaceTransformFlags {
            identity: value & 0x00000001 > 0,
            rotate_90: value & 0x00000002 > 0,
            rotate_180: value & 0x00000004 > 0,
            rotate_270: value & 0x00000008 > 0,
            horizontal_mirror: value & 0x00000010 > 0,
            horizontal_mirror_rotate_90: value & 0x00000020 > 0,
            horizontal_mirror_rotate_180: value & 0x00000040 > 0,
            horizontal_mirror_rotate_270: value & 0x00000080 > 0,
            inherit: value & 0x00000100 > 0,
        }
    }
}

#[doc(hidden)]
#[macro_export]
macro_rules! VkSurfaceTransformFlags {
    ( $( $x:ident ),* ) => {
        VkSurfaceTransformFlags {
            $($x: true,)*
            ..VkSurfaceTransformFlags::none()
        }
    }
}