Chromium Code Reviews| Index: ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.cc |
| diff --git a/ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.cc b/ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.cc |
| index 1dbb94d7908b85242ff3ed265b1be00733eed640..7aecafa27292c12095606a0c57600e664a13042b 100644 |
| --- a/ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.cc |
| +++ b/ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.cc |
| @@ -4,7 +4,10 @@ |
| #include "ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.h" |
| +#include <fcntl.h> |
| + |
| #include "base/file_descriptor_posix.h" |
| +#include "ui/ozone/platform/drm/gpu/client_native_pixmap_vgem.h" |
| #include "ui/ozone/public/client_native_pixmap_factory.h" |
| namespace ui { |
| @@ -13,7 +16,18 @@ namespace { |
| class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { |
| public: |
| - ClientNativePixmapFactoryGbm() {} |
| + ClientNativePixmapFactoryGbm() { |
| +#if defined(OZONE_USE_VGEM_MAP) |
| + // TODO(dshwang): remove ad-hoc file open. crrev.com/1248713002 |
| + static const char kVgemPath[] = "/dev/dri/renderD129"; |
| + int vgem_fd = open(kVgemPath, O_RDWR | O_CLOEXEC); |
| + if (vgem_fd < 0) { |
| + PLOG(ERROR) << "Failed to open: " << kVgemPath; |
| + return; |
| + } |
| + vgem_fd_.reset(vgem_fd); |
| +#endif |
| + } |
| ~ClientNativePixmapFactoryGbm() override {} |
| // ClientNativePixmapFactory: |
| @@ -23,6 +37,13 @@ class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { |
| {gfx::BufferFormat::RGBX_8888, gfx::BufferUsage::SCANOUT}}; |
| std::vector<Configuration> configurations( |
| kConfiguratioins, kConfiguratioins + arraysize(kConfiguratioins)); |
| +#if defined(OZONE_USE_VGEM_MAP) |
| + // Map requires VGEM supports. |
| + if (vgem_fd_.get() >= 0) { |
|
reveman
2015/08/06 12:08:35
why would this fail?
dshwang
2015/08/06 13:59:17
upstream linux doens't have vgem device. In additi
|
| + configurations.push_back( |
| + {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::MAP}); |
| + } |
| +#endif |
| return configurations; |
| } |
| scoped_ptr<ClientNativePixmap> ImportFromHandle( |
| @@ -30,11 +51,20 @@ class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { |
| const gfx::Size& size, |
| gfx::BufferFormat format, |
| gfx::BufferUsage usage) override { |
| - NOTIMPLEMENTED(); |
| - return nullptr; |
| + DCHECK(usage == gfx::BufferUsage::MAP); |
|
reveman
2015/08/06 12:08:35
why do we care what the usage is?
dshwang
2015/08/06 13:59:17
Either GpuMemoryBufferImplOzoneNativePixmap or Cli
|
| + if (vgem_fd_.get() < 0) |
| + return nullptr; |
| + scoped_ptr<ClientNativePixmapVgem> pixmap(new ClientNativePixmapVgem( |
| + handle, base::FileDescriptor(vgem_fd_.get(), false), size, format)); |
| + if (!pixmap->Initialize()) |
|
reveman
2015/08/06 12:08:35
can you move the work done in Initialize out here
dshwang
2015/08/06 13:59:17
do you mean that this function call directly "drmP
|
| + return nullptr; |
| + |
| + return pixmap.Pass(); |
| } |
| private: |
| + base::ScopedFD vgem_fd_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); |
| }; |