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/ozone/platform/drm/client_native_pixmap_factory_gbm.h" | 5 #include "ui/ozone/platform/drm/client_native_pixmap_factory_gbm.h" |
6 | 6 |
7 #include "ui/gfx/native_pixmap_handle_ozone.h" | 7 #include "ui/gfx/native_pixmap_handle_ozone.h" |
8 #include "ui/ozone/public/client_native_pixmap_factory.h" | 8 #include "ui/ozone/public/client_native_pixmap_factory.h" |
9 | 9 |
10 #if defined(USE_VGEM_MAP) | 10 #if defined(USE_VGEM_MAP) |
(...skipping 30 matching lines...) Expand all Loading... |
41 // It's called in IO thread. We rely on clients for thread-safety. | 41 // It's called in IO thread. We rely on clients for thread-safety. |
42 // Switching to an IPC message filter ensures thread-safety. | 42 // Switching to an IPC message filter ensures thread-safety. |
43 DCHECK_LT(vgem_fd_.get(), 0); | 43 DCHECK_LT(vgem_fd_.get(), 0); |
44 vgem_fd_ = device_fd.Pass(); | 44 vgem_fd_ = device_fd.Pass(); |
45 #endif | 45 #endif |
46 } | 46 } |
47 bool IsConfigurationSupported(gfx::BufferFormat format, | 47 bool IsConfigurationSupported(gfx::BufferFormat format, |
48 gfx::BufferUsage usage) const override { | 48 gfx::BufferUsage usage) const override { |
49 switch (usage) { | 49 switch (usage) { |
50 case gfx::BufferUsage::GPU_READ: | 50 case gfx::BufferUsage::GPU_READ: |
51 case gfx::BufferUsage::GPU_READ_WRITE: | 51 case gfx::BufferUsage::SCANOUT: |
52 return format == gfx::BufferFormat::RGBA_8888 || | 52 return format == gfx::BufferFormat::RGBA_8888 || |
53 format == gfx::BufferFormat::BGRA_8888 || | 53 format == gfx::BufferFormat::BGRA_8888 || |
54 format == gfx::BufferFormat::BGRX_8888; | 54 format == gfx::BufferFormat::BGRX_8888; |
55 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | 55 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: |
56 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: { | 56 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: { |
57 #if defined(USE_VGEM_MAP) | 57 #if defined(USE_VGEM_MAP) |
58 return vgem_fd_.is_valid() && format == gfx::BufferFormat::BGRA_8888; | 58 return vgem_fd_.is_valid() && format == gfx::BufferFormat::BGRA_8888; |
59 #else | 59 #else |
60 return false; | 60 return false; |
61 #endif | 61 #endif |
(...skipping 14 matching lines...) Expand all Loading... |
76 #if defined(USE_VGEM_MAP) | 76 #if defined(USE_VGEM_MAP) |
77 // A valid |vgem_fd_| is required to acquire a VGEM bo. |vgem_fd_| is | 77 // A valid |vgem_fd_| is required to acquire a VGEM bo. |vgem_fd_| is |
78 // set before a widget is created. | 78 // set before a widget is created. |
79 DCHECK_GE(vgem_fd_.get(), 0); | 79 DCHECK_GE(vgem_fd_.get(), 0); |
80 return ClientNativePixmapVgem::ImportFromDmabuf( | 80 return ClientNativePixmapVgem::ImportFromDmabuf( |
81 vgem_fd_.get(), scoped_fd.get(), size, handle.stride); | 81 vgem_fd_.get(), scoped_fd.get(), size, handle.stride); |
82 #endif | 82 #endif |
83 NOTREACHED(); | 83 NOTREACHED(); |
84 return nullptr; | 84 return nullptr; |
85 case gfx::BufferUsage::GPU_READ: | 85 case gfx::BufferUsage::GPU_READ: |
86 case gfx::BufferUsage::GPU_READ_WRITE: | 86 case gfx::BufferUsage::SCANOUT: |
87 return make_scoped_ptr<ClientNativePixmapGbm>( | 87 return make_scoped_ptr<ClientNativePixmapGbm>( |
88 new ClientNativePixmapGbm); | 88 new ClientNativePixmapGbm); |
89 } | 89 } |
90 NOTREACHED(); | 90 NOTREACHED(); |
91 return nullptr; | 91 return nullptr; |
92 } | 92 } |
93 | 93 |
94 private: | 94 private: |
95 #if defined(USE_VGEM_MAP) | 95 #if defined(USE_VGEM_MAP) |
96 base::ScopedFD vgem_fd_; | 96 base::ScopedFD vgem_fd_; |
97 #endif | 97 #endif |
98 | 98 |
99 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); | 99 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); |
100 }; | 100 }; |
101 | 101 |
102 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { | 102 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { |
103 return new ClientNativePixmapFactoryGbm(); | 103 return new ClientNativePixmapFactoryGbm(); |
104 } | 104 } |
105 | 105 |
106 } // namespace ui | 106 } // namespace ui |
OLD | NEW |