commit | 6bd6662bb0e5d747e29a1b7d8450f61f7883632e | [log] [tgz] |
---|---|---|
author | Roman Yepishev <[email protected]> | Thu Apr 04 08:47:19 2024 +0000 |
committer | Automerger Merge Worker <[email protected]> | Thu Apr 04 08:47:19 2024 +0000 |
tree | b0cc0dc0e8c27e95ffea0b288da2b9b82acb4dcf | |
parent | 3873302c6716e710b9ccae31d0de5d8af07b1554 [diff] | |
parent | 4d2bf6d6932c4551c6c6e9661ce099dad06ee05d [diff] |
Merge remote-tracking branch 'origin/upstream' am: 4d2bf6d693 Original change: undetermined Change-Id: I3176af8a19a866216fd13b8b91f41370a8068cbc 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();