@@ -32,10 +32,23 @@ pub struct StreamConfig {
3232 pub stride : u32 ,
3333}
3434
35+ impl From < StreamConfig > for HardwareBufferDescription {
36+ fn from ( config : StreamConfig ) -> Self {
37+ HardwareBufferDescription :: new (
38+ config. width ,
39+ config. height ,
40+ config. layers ,
41+ config. format ,
42+ config. usage ,
43+ config. stride ,
44+ )
45+ }
46+ }
47+
3548impl StreamConfig {
3649 /// Tries to create a new HardwareBuffer from settings in a [StreamConfig].
3750 pub fn create_hardware_buffer ( & self ) -> Option < HardwareBuffer > {
38- HardwareBuffer :: new ( self . width , self . height , self . layers , self . format , self . usage )
51+ HardwareBuffer :: new ( & ( * self ) . into ( ) )
3952 }
4053}
4154
@@ -59,9 +72,10 @@ mod test {
5972 assert ! ( maybe_buffer. is_some( ) ) ;
6073
6174 let buffer = maybe_buffer. unwrap ( ) ;
62- assert_eq ! ( config. width, buffer. width( ) ) ;
63- assert_eq ! ( config. height, buffer. height( ) ) ;
64- assert_eq ! ( config. format, buffer. format( ) ) ;
65- assert_eq ! ( config. usage, buffer. usage( ) ) ;
75+ let description = buffer. description ( ) ;
76+ assert_eq ! ( config. width, description. width( ) ) ;
77+ assert_eq ! ( config. height, description. height( ) ) ;
78+ assert_eq ! ( config. format, description. format( ) ) ;
79+ assert_eq ! ( config. usage, description. usage( ) ) ;
6680 }
6781}
0 commit comments