commit | 0462b8d1526acb8e9645653172d58cfcee1cdaaa | [log] [tgz] |
---|---|---|
author | James Farrell <[email protected]> | Thu May 09 20:27:42 2024 +0000 |
committer | Automerger Merge Worker <[email protected]> | Thu May 09 20:27:42 2024 +0000 |
tree | bca33c2cb9de29752618fca45443fcc462a9e5fc | |
parent | 7f5253e8c7b84562b23f876d2d0b2d96412d6b7a [diff] | |
parent | 6323d58016b749c057c27172fa330fd33e448944 [diff] |
Update Android.bp by running cargo_embargo am: bb01491c6f am: 6323d58016 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/gbm/+/3080487 Change-Id: I1853a031b4b3614d9d36ed1d77901201f1010a14 Signed-off-by: Automerger Merge Worker <[email protected]>
libgbm
bindings for rustThe Generic Buffer Manager
This module provides an abstraction that the caller can use to request a buffer from the underlying memory management system for the platform.
This allows the creation of portable code whilst still allowing access to the underlying memory manager.
This library is best used in combination with drm-rs
, provided through the drm-support
feature.
Add to your Cargo.toml
gbm = "0.14.2"
extern crate drm; extern crate gbm; use drm::control::{self, crtc, framebuffer}; use gbm::{BufferObjectFlags, Device, Format}; // ... init your drm device ... let drm = init_drm_device(); // init a GBM device let gbm = Device::new(drm).unwrap(); // create a buffer let mut bo = gbm .create_buffer_object::<()>( 1280, 720, Format::Argb8888, BufferObjectFlags::SCANOUT | BufferObjectFlags::WRITE, ) .unwrap(); // write something to it (usually use import or egl rendering instead) let buffer = { let mut buffer = Vec::new(); for i in 0..1280 { for _ in 0..720 { buffer.push(if i % 2 == 0 { 0 } else { 255 }); } } buffer }; bo.write(&buffer).unwrap(); // create a framebuffer from our buffer let fb = gbm.add_framebuffer(&bo, 32, 32).unwrap(); // display it (and get a crtc, mode and connector before) gbm.set_crtc(crtc_handle, Some(fb), (0, 0), &[con], Some(mode)) .unwrap();