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..237fbd3c0c22ab42220eba8375d93997c21d8df4 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,16 +4,33 @@ |
| #include "ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.h" |
| +#include <fcntl.h> |
| + |
| #include "base/file_descriptor_posix.h" |
| #include "ui/ozone/public/client_native_pixmap_factory.h" |
| +#if defined(OZONE_USE_VGEM_MAP) |
| +#include "ui/ozone/platform/drm/gpu/client_native_pixmap_vgem.h" |
| +#endif |
| + |
| namespace ui { |
| 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 +40,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> ImportFromHandle( |
| @@ -30,11 +54,21 @@ class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { |
| const gfx::Size& size, |
| gfx::BufferFormat format, |
| gfx::BufferUsage usage) override { |
| - NOTIMPLEMENTED(); |
| + if (usage == gfx::BufferUsage::SCANOUT) |
|
reveman
2015/08/07 14:35:16
would it hurt to still create the client pixmap?
dshwang
2015/08/07 15:36:46
Upstream linux cannot create vgem pixmap because v
|
| + return nullptr; |
| +#if defined(OZONE_USE_VGEM_MAP) |
| + DCHECK_GE(vgem_fd_.get(), 0); |
| + return ClientNativePixmapVgem::Create( |
| + handle, base::FileDescriptor(vgem_fd_.get(), false), size, format, |
| + usage); |
| +#else |
| return nullptr; |
| +#endif |
| } |
| private: |
| + base::ScopedFD vgem_fd_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); |
| }; |