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 34a941da3ed824f35ffc0ebaa78fb85b1cbab567..eab38cb4b74a077d32719536fde7567aa754c0c3 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 |
@@ -8,6 +8,11 @@ |
#include "ui/gfx/native_pixmap_handle_ozone.h" |
#include "ui/ozone/public/client_native_pixmap_factory.h" |
+#if defined(USE_VGEM_MAP) |
+#include <fcntl.h> |
+#include "ui/ozone/platform/drm/gpu/client_native_pixmap_vgem.h" |
+#endif |
+ |
namespace ui { |
namespace { |
@@ -17,9 +22,9 @@ class ClientNativePixmapGbm : public ClientNativePixmap { |
ClientNativePixmapGbm() {} |
~ClientNativePixmapGbm() override {} |
- bool Map(void** data) override { |
+ void* Map() override { |
NOTREACHED(); |
- return false; |
+ return nullptr; |
} |
void Unmap() override { NOTREACHED(); } |
void GetStride(int* stride) const override { NOTREACHED(); } |
@@ -27,7 +32,15 @@ class ClientNativePixmapGbm : public ClientNativePixmap { |
class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { |
public: |
- ClientNativePixmapFactoryGbm() {} |
+ ClientNativePixmapFactoryGbm() { |
+#if defined(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); |
+ vgem_fd_.reset(vgem_fd); |
+ DCHECK_GE(vgem_fd_.get(), 0) << "Failed to open: " << kVgemPath; |
+#endif |
+ } |
~ClientNativePixmapFactoryGbm() override {} |
// ClientNativePixmapFactory: |
@@ -37,18 +50,42 @@ class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { |
{gfx::BufferFormat::RGBX_8888, gfx::BufferUsage::SCANOUT}}; |
std::vector<Configuration> configurations( |
kConfigurations, kConfigurations + arraysize(kConfigurations)); |
+#if defined(USE_VGEM_MAP) |
+ configurations.push_back( |
+ {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::MAP}); |
+#endif |
return configurations; |
} |
scoped_ptr<ClientNativePixmap> ImportFromHandle( |
const gfx::NativePixmapHandle& handle, |
const gfx::Size& size, |
- gfx::BufferFormat format, |
gfx::BufferUsage usage) override { |
base::ScopedFD scoped_fd(handle.fd.fd); |
- return make_scoped_ptr<ClientNativePixmapGbm>(new ClientNativePixmapGbm); |
+ |
+ switch (usage) { |
+ case gfx::BufferUsage::MAP: |
+#if defined(USE_VGEM_MAP) |
+ return ClientNativePixmapVgem::ImportFromDmabuf( |
+ vgem_fd_.get(), scoped_fd.get(), size, handle.stride); |
+#endif |
+ NOTREACHED(); |
+ return nullptr; |
+ case gfx::BufferUsage::PERSISTENT_MAP: |
+ NOTREACHED(); |
+ return nullptr; |
+ case gfx::BufferUsage::SCANOUT: |
+ return make_scoped_ptr<ClientNativePixmapGbm>( |
+ new ClientNativePixmapGbm); |
+ } |
+ NOTREACHED(); |
+ return nullptr; |
} |
private: |
+#if defined(USE_VGEM_MAP) |
+ base::ScopedFD vgem_fd_; |
+#endif |
+ |
DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); |
}; |