commit | e81922e1f2acc3f192a54af519efafb6be010d5c | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Thu Aug 29 01:10:18 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Thu Aug 29 01:10:18 2024 +0000 |
tree | eb09ce53cec355c59d4aa2a1b0ef851cacd63b02 | |
parent | 9ec1bf333987566bd6334b46f1c26df0a447736f [diff] | |
parent | b46ad949f4ab5d908ed58926012296c23f9ce650 [diff] |
Snap for 12291954 from b46ad949f4ab5d908ed58926012296c23f9ce650 to sdk-release Change-Id: I725341c2b62ff0ae06e23e762cd5475915c25ce7
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();