Chromium Code Reviews| 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 <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" |
| 11 #include "ui/gfx/native_pixmap_handle.h" | 11 #include "ui/gfx/native_pixmap_handle.h" |
| 12 #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h" | 12 #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h" |
| 13 #include "ui/ozone/public/client_native_pixmap_factory.h" | 13 #include "ui/ozone/public/client_native_pixmap_factory.h" |
| 14 | 14 |
| 15 namespace ui { | 15 namespace ui { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 class ClientNativePixmapGbm : public ClientNativePixmap { | 19 class ClientNativePixmapGbm : public ClientNativePixmap { |
| 20 public: | 20 public: |
| 21 ClientNativePixmapGbm() {} | 21 ClientNativePixmapGbm() {} |
| 22 ~ClientNativePixmapGbm() override {} | 22 ~ClientNativePixmapGbm() override {} |
| 23 | 23 |
| 24 void* Map() override { | 24 bool Map() override { |
| 25 NOTREACHED(); | |
| 26 return false; | |
| 27 } | |
| 28 void Unmap() override { NOTREACHED(); } | |
| 29 void* GetMemoryAddress(size_t plane) const override { | |
| 25 NOTREACHED(); | 30 NOTREACHED(); |
| 26 return nullptr; | 31 return nullptr; |
| 27 } | 32 } |
| 28 void Unmap() override { NOTREACHED(); } | 33 int GetStride(size_t plane) const override { |
| 29 void GetStride(int* stride) const override { NOTREACHED(); } | 34 NOTREACHED(); |
| 35 return 0; | |
| 36 } | |
| 30 }; | 37 }; |
| 31 | 38 |
| 32 } // namespace | 39 } // namespace |
| 33 | 40 |
| 34 class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { | 41 class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { |
| 35 public: | 42 public: |
| 36 ClientNativePixmapFactoryGbm() {} | 43 ClientNativePixmapFactoryGbm() {} |
| 37 ~ClientNativePixmapFactoryGbm() override {} | 44 ~ClientNativePixmapFactoryGbm() override {} |
| 38 | 45 |
| 39 // ClientNativePixmapFactory: | 46 // ClientNativePixmapFactory: |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 66 } | 73 } |
| 67 } | 74 } |
| 68 NOTREACHED(); | 75 NOTREACHED(); |
| 69 return false; | 76 return false; |
| 70 } | 77 } |
| 71 std::unique_ptr<ClientNativePixmap> ImportFromHandle( | 78 std::unique_ptr<ClientNativePixmap> ImportFromHandle( |
| 72 const gfx::NativePixmapHandle& handle, | 79 const gfx::NativePixmapHandle& handle, |
| 73 const gfx::Size& size, | 80 const gfx::Size& size, |
| 74 gfx::BufferUsage usage) override { | 81 gfx::BufferUsage usage) override { |
| 75 DCHECK(!handle.fds.empty()); | 82 DCHECK(!handle.fds.empty()); |
| 76 base::ScopedFD scoped_fd(handle.fds[0].fd); | |
| 77 switch (usage) { | 83 switch (usage) { |
| 78 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | 84 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: |
| 79 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: | 85 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: |
| 80 #if defined(OS_CHROMEOS) | 86 #if defined(OS_CHROMEOS) |
|
dnicoara
2016/09/14 21:47:40
On the non-CrOS case this would be leaking the FDs
Daniele Castagna
2016/09/19 18:26:39
True, but the non-CrOS case should never be reache
| |
| 81 // TODO(dcastagna): Add support for pixmaps with multiple FDs for non | 87 return ClientNativePixmapDmaBuf::ImportFromDmabuf(handle, size); |
| 82 // scanout buffers. | |
| 83 return ClientNativePixmapDmaBuf::ImportFromDmabuf( | |
| 84 scoped_fd.release(), size, handle.planes[0].stride); | |
| 85 #else | 88 #else |
| 86 NOTREACHED(); | 89 NOTREACHED(); |
| 87 return nullptr; | 90 return nullptr; |
| 88 #endif | 91 #endif |
| 89 case gfx::BufferUsage::GPU_READ: | 92 case gfx::BufferUsage::GPU_READ: |
| 90 case gfx::BufferUsage::SCANOUT: | 93 case gfx::BufferUsage::SCANOUT: |
| 94 // Close all the fds. | |
| 95 for (const auto& fd : handle.fds) | |
| 96 base::ScopedFD scoped_fd(fd.fd); | |
| 91 return base::WrapUnique(new ClientNativePixmapGbm); | 97 return base::WrapUnique(new ClientNativePixmapGbm); |
| 92 } | 98 } |
| 93 NOTREACHED(); | 99 NOTREACHED(); |
| 94 return nullptr; | 100 return nullptr; |
| 95 } | 101 } |
| 96 | 102 |
| 97 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); | 103 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); |
| 98 }; | 104 }; |
| 99 | 105 |
| 100 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { | 106 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { |
| 101 return new ClientNativePixmapFactoryGbm(); | 107 return new ClientNativePixmapFactoryGbm(); |
| 102 } | 108 } |
| 103 | 109 |
| 104 } // namespace ui | 110 } // namespace ui |
| OLD | NEW |