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 ca150e5d56c78d153ab489185dd7716d85758f91..a8fb59d27d7b236663e2be7f0d7549a17ff49f65 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,16 @@ namespace { |
| class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { |
| public: |
| - ClientNativePixmapFactoryGbm() {} |
| + ClientNativePixmapFactoryGbm() { |
| + // TODO(dshwang): remove ad-hoc file open. crrev.com/1248713002 |
|
dshwang
2015/08/05 12:33:16
as spang requested in https://codereview.chromium.
|
| + 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); |
| + } |
| ~ClientNativePixmapFactoryGbm() override {} |
| // ClientNativePixmapFactory: |
| @@ -23,6 +35,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) { |
| + configurations.push_back( |
| + {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::MAP}); |
| + } |
| +#endif |
| return configurations; |
| } |
| scoped_ptr<ClientNativePixmap> ImportNativePixmap( |
| @@ -30,11 +49,20 @@ class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { |
| const gfx::Size& size, |
| gfx::BufferFormat format, |
| gfx::BufferUsage usage) override { |
| - NOTIMPLEMENTED(); |
| - return nullptr; |
| + if (vgem_fd_.get() < 0) |
| + return nullptr; |
| + scoped_ptr<ClientNativePixmapVgem> pixmap(new ClientNativePixmapVgem( |
| + handle, base::FileDescriptor(vgem_fd_.get(), false), size, format, |
| + usage)); |
| + if (!pixmap->Initialize()) |
| + return nullptr; |
| + |
| + return pixmap.Pass(); |
| } |
| private: |
| + base::ScopedFD vgem_fd_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); |
| }; |