| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "ui/gfx/linux/client_native_pixmap_factory_dmabuf.h" | 5 #include "ui/gfx/linux/client_native_pixmap_factory_dmabuf.h" | 
| 6 | 6 | 
| 7 #include <utility> | 7 #include <utility> | 
| 8 | 8 | 
| 9 #include "base/macros.h" | 9 #include "base/macros.h" | 
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 76             // Currently only Intel driver (i.e. minigbm and Mesa) supports R_8 | 76             // Currently only Intel driver (i.e. minigbm and Mesa) supports R_8 | 
| 77             // and RG_88. crbug.com/356871 | 77             // and RG_88. crbug.com/356871 | 
| 78             format == gfx::BufferFormat::R_8 || | 78             format == gfx::BufferFormat::R_8 || | 
| 79             format == gfx::BufferFormat::RG_88 || | 79             format == gfx::BufferFormat::RG_88 || | 
| 80 #endif | 80 #endif | 
| 81             format == gfx::BufferFormat::BGRA_8888; | 81             format == gfx::BufferFormat::BGRA_8888; | 
| 82 #else | 82 #else | 
| 83         return false; | 83         return false; | 
| 84 #endif | 84 #endif | 
| 85       } | 85       } | 
|  | 86       case gfx::BufferUsage::SCANOUT_ASYNC: | 
|  | 87         break; | 
| 86     } | 88     } | 
| 87     NOTREACHED(); | 89     NOTREACHED(); | 
| 88     return false; | 90     return false; | 
| 89   } | 91   } | 
| 90   std::unique_ptr<ClientNativePixmap> ImportFromHandle( | 92   std::unique_ptr<ClientNativePixmap> ImportFromHandle( | 
| 91       const gfx::NativePixmapHandle& handle, | 93       const gfx::NativePixmapHandle& handle, | 
| 92       const gfx::Size& size, | 94       const gfx::Size& size, | 
| 93       gfx::BufferUsage usage) override { | 95       gfx::BufferUsage usage) override { | 
| 94     DCHECK(!handle.fds.empty()); | 96     DCHECK(!handle.fds.empty()); | 
| 95     switch (usage) { | 97     switch (usage) { | 
| 96       case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE: | 98       case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE: | 
| 97       case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | 99       case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | 
| 98       case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: | 100       case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: | 
| 99 #if defined(OS_CHROMEOS) | 101 #if defined(OS_CHROMEOS) | 
| 100         return ClientNativePixmapDmaBuf::ImportFromDmabuf(handle, size); | 102         return ClientNativePixmapDmaBuf::ImportFromDmabuf(handle, size); | 
| 101 #else | 103 #else | 
| 102         NOTREACHED(); | 104         NOTREACHED(); | 
| 103         return nullptr; | 105         return nullptr; | 
| 104 #endif | 106 #endif | 
| 105       case gfx::BufferUsage::GPU_READ: | 107       case gfx::BufferUsage::GPU_READ: | 
| 106       case gfx::BufferUsage::SCANOUT: | 108       case gfx::BufferUsage::SCANOUT: | 
| 107         // Close all the fds. | 109         // Close all the fds. | 
| 108         for (const auto& fd : handle.fds) | 110         for (const auto& fd : handle.fds) | 
| 109           base::ScopedFD scoped_fd(fd.fd); | 111           base::ScopedFD scoped_fd(fd.fd); | 
| 110         return base::WrapUnique(new ClientNativePixmapOpaque); | 112         return base::WrapUnique(new ClientNativePixmapOpaque); | 
|  | 113       case gfx::BufferUsage::SCANOUT_ASYNC: | 
|  | 114         break; | 
| 111     } | 115     } | 
| 112     NOTREACHED(); | 116     NOTREACHED(); | 
| 113     return nullptr; | 117     return nullptr; | 
| 114   } | 118   } | 
| 115 | 119 | 
| 116   DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryDmabuf); | 120   DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryDmabuf); | 
| 117 }; | 121 }; | 
| 118 | 122 | 
| 119 ClientNativePixmapFactory* CreateClientNativePixmapFactoryDmabuf() { | 123 ClientNativePixmapFactory* CreateClientNativePixmapFactoryDmabuf() { | 
| 120   return new ClientNativePixmapFactoryDmabuf(); | 124   return new ClientNativePixmapFactoryDmabuf(); | 
| 121 } | 125 } | 
| 122 | 126 | 
| 123 }  // namespace gfx | 127 }  // namespace gfx | 
| OLD | NEW | 
|---|