| 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/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" |
| 11 #include "ui/gfx/client_native_pixmap_factory.h" | 11 #include "base/trace_event/trace_event.h" |
| 12 #include "ui/gfx/native_pixmap_handle.h" | 12 #include "ui/gfx/native_pixmap_handle.h" |
| 13 #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h" | |
| 14 | 13 |
| 15 namespace ui { | 14 #if defined(OS_CHROMEOS) |
| 15 // This can be enabled on all linux but it is not a requirement to support |
| 16 // glCreateImageChromium+Dmabuf since it uses gfx::BufferUsage::SCANOUT and |
| 17 // the pixmap does not need to be mappable on the client side. |
| 18 #include "ui/gfx/linux/client_native_pixmap_dmabuf.h" |
| 19 #endif |
| 20 |
| 21 namespace gfx { |
| 16 | 22 |
| 17 namespace { | 23 namespace { |
| 18 | 24 |
| 19 class ClientNativePixmapGbm : public gfx::ClientNativePixmap { | 25 class ClientNativePixmapOpaque : public ClientNativePixmap { |
| 20 public: | 26 public: |
| 21 ClientNativePixmapGbm() {} | 27 ClientNativePixmapOpaque() {} |
| 22 ~ClientNativePixmapGbm() override {} | 28 ~ClientNativePixmapOpaque() override {} |
| 23 | 29 |
| 24 bool Map() override { | 30 bool Map() override { |
| 25 NOTREACHED(); | 31 NOTREACHED(); |
| 26 return false; | 32 return false; |
| 27 } | 33 } |
| 28 void Unmap() override { NOTREACHED(); } | 34 void Unmap() override { NOTREACHED(); } |
| 29 void* GetMemoryAddress(size_t plane) const override { | 35 void* GetMemoryAddress(size_t plane) const override { |
| 30 NOTREACHED(); | 36 NOTREACHED(); |
| 31 return nullptr; | 37 return nullptr; |
| 32 } | 38 } |
| 33 int GetStride(size_t plane) const override { | 39 int GetStride(size_t plane) const override { |
| 34 NOTREACHED(); | 40 NOTREACHED(); |
| 35 return 0; | 41 return 0; |
| 36 } | 42 } |
| 37 }; | 43 }; |
| 38 | 44 |
| 39 } // namespace | 45 } // namespace |
| 40 | 46 |
| 41 class ClientNativePixmapFactoryGbm : public gfx::ClientNativePixmapFactory { | 47 class ClientNativePixmapFactoryDmabuf : public ClientNativePixmapFactory { |
| 42 public: | 48 public: |
| 43 ClientNativePixmapFactoryGbm() {} | 49 ClientNativePixmapFactoryDmabuf() {} |
| 44 ~ClientNativePixmapFactoryGbm() override {} | 50 ~ClientNativePixmapFactoryDmabuf() override {} |
| 45 | 51 |
| 46 // ClientNativePixmapFactory: | 52 // ClientNativePixmapFactory: |
| 47 bool IsConfigurationSupported(gfx::BufferFormat format, | 53 bool IsConfigurationSupported(gfx::BufferFormat format, |
| 48 gfx::BufferUsage usage) const override { | 54 gfx::BufferUsage usage) const override { |
| 49 switch (usage) { | 55 switch (usage) { |
| 50 case gfx::BufferUsage::GPU_READ: | 56 case gfx::BufferUsage::GPU_READ: |
| 51 return format == gfx::BufferFormat::BGR_565 || | 57 return format == gfx::BufferFormat::BGR_565 || |
| 52 format == gfx::BufferFormat::RGBA_8888 || | 58 format == gfx::BufferFormat::RGBA_8888 || |
| 53 format == gfx::BufferFormat::RGBX_8888 || | 59 format == gfx::BufferFormat::RGBX_8888 || |
| 54 format == gfx::BufferFormat::BGRA_8888 || | 60 format == gfx::BufferFormat::BGRA_8888 || |
| (...skipping 19 matching lines...) Expand all Loading... |
| 74 #endif | 80 #endif |
| 75 format == gfx::BufferFormat::BGRA_8888; | 81 format == gfx::BufferFormat::BGRA_8888; |
| 76 #else | 82 #else |
| 77 return false; | 83 return false; |
| 78 #endif | 84 #endif |
| 79 } | 85 } |
| 80 } | 86 } |
| 81 NOTREACHED(); | 87 NOTREACHED(); |
| 82 return false; | 88 return false; |
| 83 } | 89 } |
| 84 std::unique_ptr<gfx::ClientNativePixmap> ImportFromHandle( | 90 std::unique_ptr<ClientNativePixmap> ImportFromHandle( |
| 85 const gfx::NativePixmapHandle& handle, | 91 const gfx::NativePixmapHandle& handle, |
| 86 const gfx::Size& size, | 92 const gfx::Size& size, |
| 87 gfx::BufferUsage usage) override { | 93 gfx::BufferUsage usage) override { |
| 88 DCHECK(!handle.fds.empty()); | 94 DCHECK(!handle.fds.empty()); |
| 89 switch (usage) { | 95 switch (usage) { |
| 90 case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE: | 96 case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE: |
| 91 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | 97 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: |
| 92 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: | 98 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: |
| 93 #if defined(OS_CHROMEOS) | 99 #if defined(OS_CHROMEOS) |
| 94 return ClientNativePixmapDmaBuf::ImportFromDmabuf(handle, size); | 100 return ClientNativePixmapDmaBuf::ImportFromDmabuf(handle, size); |
| 95 #else | 101 #else |
| 96 NOTREACHED(); | 102 NOTREACHED(); |
| 97 return nullptr; | 103 return nullptr; |
| 98 #endif | 104 #endif |
| 99 case gfx::BufferUsage::GPU_READ: | 105 case gfx::BufferUsage::GPU_READ: |
| 100 case gfx::BufferUsage::SCANOUT: | 106 case gfx::BufferUsage::SCANOUT: |
| 101 // Close all the fds. | 107 // Close all the fds. |
| 102 for (const auto& fd : handle.fds) | 108 for (const auto& fd : handle.fds) |
| 103 base::ScopedFD scoped_fd(fd.fd); | 109 base::ScopedFD scoped_fd(fd.fd); |
| 104 return base::WrapUnique(new ClientNativePixmapGbm); | 110 return base::WrapUnique(new ClientNativePixmapOpaque); |
| 105 } | 111 } |
| 106 NOTREACHED(); | 112 NOTREACHED(); |
| 107 return nullptr; | 113 return nullptr; |
| 108 } | 114 } |
| 109 | 115 |
| 110 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); | 116 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryDmabuf); |
| 111 }; | 117 }; |
| 112 | 118 |
| 113 gfx::ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { | 119 ClientNativePixmapFactory* CreateClientNativePixmapFactoryDmabuf() { |
| 114 return new ClientNativePixmapFactoryGbm(); | 120 return new ClientNativePixmapFactoryDmabuf(); |
| 115 } | 121 } |
| 116 | 122 |
| 117 } // namespace ui | 123 } // namespace gfx |
| OLD | NEW |