summary refs log tree commit diff
path: root/resources/src/gpu_allocator.rs
diff options
context:
space:
mode:
authorZach Reizner <zachr@google.com>2018-10-03 10:22:32 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-10-09 21:14:05 -0700
commit55a9e504beef368bd97e51ffd5a7fa6c034eb8ad (patch)
tree894d8685e2fdfa105ea35d1cb6cfceee06502c7a /resources/src/gpu_allocator.rs
parent046df60760f3b0691f23c27a7f24a96c9afe8c05 (diff)
downloadcrosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.gz
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.bz2
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.lz
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.xz
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.zst
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.zip
cargo fmt all source code
Now that cargo fmt has landed, run it over everything at once to bring
rust source to the standard formatting.

TEST=cargo test
BUG=None

Change-Id: Ic95a48725e5a40dcbd33ba6d5aef2bd01e91865b
Reviewed-on: https://chromium-review.googlesource.com/1259287
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'resources/src/gpu_allocator.rs')
-rw-r--r--resources/src/gpu_allocator.rs30
1 files changed, 20 insertions, 10 deletions
diff --git a/resources/src/gpu_allocator.rs b/resources/src/gpu_allocator.rs
index ea38ba4..9f98bcf 100644
--- a/resources/src/gpu_allocator.rs
+++ b/resources/src/gpu_allocator.rs
@@ -42,8 +42,12 @@ pub trait GpuMemoryAllocator {
     /// * `width` - Width of buffer.
     /// * `height` - Height of buffer.
     /// * `format` - Fourcc format of buffer.
-    fn allocate(&self, width: u32, height: u32, format: u32)
-        -> sys_util::Result<(File, GpuMemoryDesc)>;
+    fn allocate(
+        &self,
+        width: u32,
+        height: u32,
+        format: u32,
+    ) -> sys_util::Result<(File, GpuMemoryDesc)>;
 }
 
 #[cfg(feature = "wl-dmabuf")]
@@ -53,9 +57,12 @@ pub struct GpuBufferDevice {
 
 #[cfg(feature = "wl-dmabuf")]
 impl GpuMemoryAllocator for GpuBufferDevice {
-    fn allocate(&self, width: u32, height: u32, format: u32) ->
-        sys_util::Result<(File, GpuMemoryDesc)>
-    {
+    fn allocate(
+        &self,
+        width: u32,
+        height: u32,
+        format: u32,
+    ) -> sys_util::Result<(File, GpuMemoryDesc)> {
         let buffer = match self.device.create_buffer(
             width,
             height,
@@ -66,7 +73,8 @@ impl GpuMemoryAllocator for GpuBufferDevice {
             // fall-back to a less efficient meachnisms for presentation if
             // neccesary. In practice, linear buffers for commonly used formats
             // will also support scanout and texturing.
-            gpu_buffer::Flags::empty().use_linear(true)) {
+            gpu_buffer::Flags::empty().use_linear(true),
+        ) {
             Ok(v) => v,
             Err(_) => return Err(sys_util::Error::new(EINVAL)),
         };
@@ -81,8 +89,10 @@ impl GpuMemoryAllocator for GpuBufferDevice {
         for i in 0..buffer.num_planes() {
             // Use stride and offset for plane if handle matches first plane.
             if buffer.plane_handle(i) == buffer.plane_handle(0) {
-                desc.planes[i] = GpuMemoryPlaneDesc { stride: buffer.plane_stride(i),
-                                                      offset: buffer.plane_offset(i) }
+                desc.planes[i] = GpuMemoryPlaneDesc {
+                    stride: buffer.plane_stride(i),
+                    offset: buffer.plane_offset(i),
+                }
             }
         }
 
@@ -95,8 +105,8 @@ pub fn create_gpu_memory_allocator() -> Result<Option<Box<GpuMemoryAllocator>>,
     let undesired: &[&str] = &["vgem", "pvr"];
     let fd = gpu_buffer::rendernode::open_device(undesired)
         .map_err(|_| GpuAllocatorError::OpenGpuBufferDevice)?;
-    let device = gpu_buffer::Device::new(fd)
-        .map_err(|_| GpuAllocatorError::CreateGpuBufferDevice)?;
+    let device =
+        gpu_buffer::Device::new(fd).map_err(|_| GpuAllocatorError::CreateGpuBufferDevice)?;
     Ok(Some(Box::new(GpuBufferDevice { device })))
 }