diff options
author | Kaiyi Li <kaiyili@google.com> | 2020-05-05 14:07:36 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-08 21:11:56 +0000 |
commit | a7469062a2b25541cfe887f55441284553659ea0 (patch) | |
tree | 82f8d581cac17ef3d5b22c630079af4a782a553e /gpu_display | |
parent | 03a54abf852984f696e7a101ff9590f05ebcba5b (diff) | |
download | crosvm-a7469062a2b25541cfe887f55441284553659ea0.tar crosvm-a7469062a2b25541cfe887f55441284553659ea0.tar.gz crosvm-a7469062a2b25541cfe887f55441284553659ea0.tar.bz2 crosvm-a7469062a2b25541cfe887f55441284553659ea0.tar.lz crosvm-a7469062a2b25541cfe887f55441284553659ea0.tar.xz crosvm-a7469062a2b25541cfe887f55441284553659ea0.tar.zst crosvm-a7469062a2b25541cfe887f55441284553659ea0.zip |
Extract the DisplayBackend build process into BackendKind build function
All 3 different virtio gpu backends share the same process of creating the GpuDisplay instance, so move that process out of their separate build functions and put it in the shared BackendKind build function. BUG=None TEST=build_test Change-Id: Ie15bae48c8f1b75df49ba066a677020ec5dbf744 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2182041 Reviewed-by: Jason Macnak <natsu@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Kaiyi Li <kaiyili@google.com>
Diffstat (limited to 'gpu_display')
-rw-r--r-- | gpu_display/src/lib.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/gpu_display/src/lib.rs b/gpu_display/src/lib.rs index 07358a0..dccf1c7 100644 --- a/gpu_display/src/lib.rs +++ b/gpu_display/src/lib.rs @@ -171,6 +171,7 @@ trait DisplayT: AsRawFd { /// descriptor. When the connection is readable, `dispatch_events` can be called to process it. pub struct GpuDisplay { inner: Box<dyn DisplayT>, + is_x: bool, } impl GpuDisplay { @@ -183,7 +184,7 @@ impl GpuDisplay { None => gpu_display_x::DisplayX::open_display(None)?, }; let inner = Box::new(display); - Ok(GpuDisplay { inner }) + Ok(GpuDisplay { inner, is_x: true }) } #[cfg(not(feature = "x"))] Err(GpuDisplayError::Unsupported) @@ -198,13 +199,18 @@ impl GpuDisplay { None => gpu_display_wl::DisplayWl::new(None)?, }; let inner = Box::new(display); - Ok(GpuDisplay { inner }) + Ok(GpuDisplay { inner, is_x: false }) } pub fn open_stub() -> Result<GpuDisplay, GpuDisplayError> { let display = gpu_display_stub::DisplayStub::new()?; let inner = Box::new(display); - Ok(GpuDisplay { inner }) + Ok(GpuDisplay { inner, is_x: false }) + } + + /// Return whether this display is an X display + pub fn is_x(&self) -> bool { + self.is_x } /// Imports a dmabuf to the compositor for use as a surface buffer and returns a handle to it. |