gpu_buffer: add ability to get backend name

This is useful for letting the guest know about host-specific
features.

BUG=chromium:924405
TEST=compile

Change-Id: I0edc4280eec7235644c9ad8561dbe063276bb3bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1650288
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
This commit is contained in:
Gurchetan Singh 2019-06-07 17:30:11 -07:00 committed by Commit Bot
parent 44863792aa
commit ab827ab177

View file

@ -35,10 +35,11 @@ mod raw;
pub mod rendernode;
use std::cmp::min;
use std::ffi::CStr;
use std::fmt::{self, Display};
use std::fs::File;
use std::isize;
use std::os::raw::c_void;
use std::os::raw::{c_char, c_void};
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::ptr::null_mut;
use std::rc::Rc;
@ -379,6 +380,14 @@ impl Device {
}
}
/// Copies and returns name of GBM backend.
pub fn get_backend_name(&self) -> String {
let backend_name: *const c_char = unsafe { gbm_device_get_backend_name(self.0.gbm) };
let c_str: &CStr = unsafe { CStr::from_ptr(backend_name) };
let str_slice: &str = c_str.to_str().unwrap_or("");
str_slice.to_owned()
}
/// Creates a new buffer with the given metadata.
pub fn create_buffer(
&self,