File tree Expand file tree Collapse file tree
libs/nativewindow/rust/src/surface Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313// limitations under the License.
1414
1515use super :: { ErrorCode , Surface } ;
16- use nativewindow_bindgen:: ANativeWindow_Buffer ;
16+ use nativewindow_bindgen:: { AHardwareBuffer_Format , ANativeWindow_Buffer } ;
1717use std:: ptr:: null_mut;
1818
1919/// An empty `ANativeWindow_Buffer`.
@@ -43,4 +43,26 @@ impl<'a> Buffer<'a> {
4343 pub fn unlock_and_post ( self ) -> Result < ( ) , ErrorCode > {
4444 self . surface . unlock_and_post ( )
4545 }
46+
47+ /// The number of pixels that are shown horizontally.
48+ pub fn width ( & self ) -> i32 {
49+ self . buffer . width
50+ }
51+
52+ /// The number of pixels that are shown vertically.
53+ pub fn height ( & self ) -> i32 {
54+ self . buffer . height
55+ }
56+
57+ /// The number of pixels that a line in the buffer takes in memory.
58+ ///
59+ /// This may be greater than the width.
60+ pub fn stride ( & self ) -> i32 {
61+ self . buffer . stride
62+ }
63+
64+ /// The pixel format of the buffer.
65+ pub fn format ( & self ) -> Result < AHardwareBuffer_Format :: Type , ErrorCode > {
66+ self . buffer . format . try_into ( ) . map_err ( |_| ErrorCode ( self . buffer . format ) )
67+ }
4668}
You can’t perform that action at this time.
0 commit comments