Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Unified Diff: ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.cc

Issue 1134993003: ozone: Implement zero/one-copy texture for Ozone GBM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: check that the configuration is returned by GetSupportedConfigurations() Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..22988ea88cd64c9061fa826cd14b7d06286c84b5 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
@@ -5,15 +5,29 @@
#include "ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.h"
#include "base/file_descriptor_posix.h"
+#include "ui/gfx/native_pixmap_handle_ozone.h"
#include "ui/ozone/public/client_native_pixmap_factory.h"
+#if defined(OZONE_USE_VGEM_MAP)
+#include <fcntl.h>
+#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);
+ vgem_fd_.reset(vgem_fd);
+ DCHECK_GE(vgem_fd_.get(), 0) << "Failed to open: " << kVgemPath;
+#endif
+ }
~ClientNativePixmapFactoryGbm() override {}
// ClientNativePixmapFactory:
@@ -23,6 +37,12 @@ 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.
+ DCHECK_GE(vgem_fd_.get(), 0);
+ configurations.push_back(
+ {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::MAP});
+#endif
return configurations;
}
scoped_ptr<ClientNativePixmap> ImportFromHandle(
@@ -30,11 +50,38 @@ class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory {
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage) override {
- NOTIMPLEMENTED();
+ DCHECK(IsConfigurationSupported(format, usage));
+ DCHECK(handle.fd.auto_close);
+ base::ScopedFD close_fd(handle.fd.fd);
reveman 2015/08/11 20:15:16 it's a bit weird to reach into the fd and check au
dshwang 2015/08/12 08:57:35 It's being handled in https://codereview.chromium.
+
+ if (usage == gfx::BufferUsage::SCANOUT)
+ 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);
+#else
+ NOTREACHED();
return nullptr;
+#endif
}
private:
+ bool IsConfigurationSupported(gfx::BufferFormat format,
+ gfx::BufferUsage usage) {
+ std::vector<Configuration> configurations(GetSupportedConfigurations());
+ for (auto& configuration : configurations) {
+ if (configuration.format == format && configuration.usage == usage)
+ return true;
+ }
+ return false;
+ }
+
+#if defined(OZONE_USE_VGEM_MAP)
+ base::ScopedFD vgem_fd_;
+#endif
+
DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm);
};

Powered by Google App Engine
This is Rietveld 408576698