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

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: resolve nits 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 34a941da3ed824f35ffc0ebaa78fb85b1cbab567..82cf12fe430a49000f5f31db73f4e69cb42e8d00 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 {
@@ -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,32 @@ 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 {
+ DCHECK(handle.fd.auto_close);
reveman 2015/08/13 14:03:58 This DCHECK is still inappropriate imo. This funct
dshwang 2015/08/13 14:59:02 Ok, Done.
base::ScopedFD scoped_fd(handle.fd.fd);
+
+#if defined(USE_VGEM_MAP)
+ if (usage == gfx::BufferUsage::MAP)
reveman 2015/08/13 14:03:58 can we remove this if statement? if we need it the
dshwang 2015/08/13 14:59:02 I restored the switch because ClientNativePixmapGb
reveman 2015/08/13 15:15:58 Just curious, why is ClientNativePixmapGbm better
dshwang 2015/08/13 15:45:28 ClientNativePixmapVgem imports handle via drmPrime
reveman 2015/08/13 17:16:43 Why does it consume more battery? Could you explai
dshwang 2015/08/13 18:13:25 I made you confused by ambiguous reply. What I mea
dshwang 2015/08/13 18:22:09 After rethinking, I'm not sure SCANOUT and MAP is
+ return ClientNativePixmapVgem::ImportFromDmabuf(
+ vgem_fd_.get(), scoped_fd.get(), size, handle.stride);
reveman 2015/08/13 14:03:58 nit: {} as multiple lines
+#endif
return make_scoped_ptr<ClientNativePixmapGbm>(new ClientNativePixmapGbm);
}
private:
+#if defined(USE_VGEM_MAP)
+ base::ScopedFD vgem_fd_;
+#endif
+
DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm);
};

Powered by Google App Engine
This is Rietveld 408576698