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

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

Issue 1248713002: ozone: ClientPixmapManager passes VGEM fd from browser to renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove waitable_event 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 eda2a31acab43f00bbe4d7325c4e43629f4f50e1..c4b529963dbd3172cfd1de8d0c04acc3edca800f 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,12 +4,11 @@
#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(USE_VGEM_MAP)
-#include <fcntl.h>
+#include "base/synchronization/lock.h"
#include "ui/ozone/platform/drm/gpu/client_native_pixmap_vgem.h"
#endif
@@ -30,20 +29,23 @@ class ClientNativePixmapGbm : public ClientNativePixmap {
void GetStride(int* stride) const override { NOTREACHED(); }
};
+} // namespace
+
class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory {
public:
- 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() {}
~ClientNativePixmapFactoryGbm() override {}
// ClientNativePixmapFactory:
+ void Initialize(base::ScopedFD device_fd) override {
+#if defined(USE_VGEM_MAP)
+ {
+ base::AutoLock lock(vgem_fd_lock_);
+ DCHECK_LT(vgem_fd_.get(), 0);
+ vgem_fd_ = device_fd.Pass();
+ }
+#endif
+ }
std::vector<Configuration> GetSupportedConfigurations() const override {
const Configuration kConfigurations[] = {
{gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::SCANOUT},
@@ -65,8 +67,18 @@ class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory {
switch (usage) {
case gfx::BufferUsage::MAP:
#if defined(USE_VGEM_MAP)
- return ClientNativePixmapVgem::ImportFromDmabuf(
- vgem_fd_.get(), scoped_fd.get(), size, handle.stride);
+ // A valid |vgem_fd_| is required to acquire a VGEM bo. |vgem_fd_| is
+ // set before a widget is created.
+ {
+ int vgem_fd = -1;
+ {
+ base::AutoLock lock(vgem_fd_lock_);
+ DCHECK_GE(vgem_fd_.get(), 0);
+ vgem_fd = vgem_fd_.get();
+ }
+ return ClientNativePixmapVgem::ImportFromDmabuf(
+ vgem_fd, scoped_fd.get(), size, handle.stride);
+ }
#endif
NOTREACHED();
return nullptr;
@@ -84,13 +96,12 @@ class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory {
private:
#if defined(USE_VGEM_MAP)
base::ScopedFD vgem_fd_;
+ base::Lock vgem_fd_lock_;
#endif
DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm);
};
-} // namespace
-
ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() {
return new ClientNativePixmapFactoryGbm();
}

Powered by Google App Engine
This is Rietveld 408576698