• Home
Name Date Size #Lines LOC

..--

src/06-Sep-2024-1,4701,068

.cargo_vcs_info.jsonD06-Sep-202494 66

Android.bpD06-Sep-2024822 3331

CHANGELOG.mdD06-Sep-20241.8 KiB8250

Cargo.tomlD06-Sep-20241.5 KiB7766

Cargo.toml.origD06-Sep-20241 KiB5041

LICENSED06-Sep-20241 KiB2217

METADATAD06-Sep-2024365 2120

MODULE_LICENSE_MITD06-Sep-20240

OWNERSD06-Sep-2024149 86

README.mdD06-Sep-20241.5 KiB6649

cargo_embargo.jsonD06-Sep-2024155 1110

README.md

1## Safe `libgbm` bindings for [rust](https://www.rust-lang.org)
2
3The Generic Buffer Manager
4
5This module provides an abstraction that the caller can use to request a
6buffer from the underlying memory management system for the platform.
7
8This allows the creation of portable code whilst still allowing access to
9the underlying memory manager.
10
11This library is best used in combination with [`drm-rs`](https://github.com/Smithay/drm-rs),
12provided through the `drm-support` feature.
13
14## Usage
15
16Add to your Cargo.toml
17
18```toml
19gbm = "0.14.2"
20```
21
22## Example
23
24```rust
25extern crate drm;
26extern crate gbm;
27
28use drm::control::{self, crtc, framebuffer};
29use gbm::{BufferObjectFlags, Device, Format};
30
31// ... init your drm device ...
32let drm = init_drm_device();
33
34// init a GBM device
35let gbm = Device::new(drm).unwrap();
36
37// create a buffer
38let mut bo = gbm
39    .create_buffer_object::<()>(
40        1280,
41        720,
42        Format::Argb8888,
43        BufferObjectFlags::SCANOUT | BufferObjectFlags::WRITE,
44    )
45    .unwrap();
46
47// write something to it (usually use import or egl rendering instead)
48let buffer = {
49    let mut buffer = Vec::new();
50    for i in 0..1280 {
51        for _ in 0..720 {
52            buffer.push(if i % 2 == 0 { 0 } else { 255 });
53        }
54    }
55    buffer
56};
57bo.write(&buffer).unwrap();
58
59// create a framebuffer from our buffer
60let fb = gbm.add_framebuffer(&bo, 32, 32).unwrap();
61
62// display it (and get a crtc, mode and connector before)
63gbm.set_crtc(crtc_handle, Some(fb), (0, 0), &[con], Some(mode))
64    .unwrap();
65```
66