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