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

Side by Side Diff: ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.cc

Issue 1071273002: NotForReview: Implement zero/one-copy texture for ozone freon using Intel DRM Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after ClientNativePixmap is introduced 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.h" 5 #include "ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 8
9 #include "base/file_descriptor_posix.h" 9 #include "base/file_descriptor_posix.h"
10 #include "ui/ozone/public/client_native_pixmap_factory.h" 10 #include "ui/ozone/public/client_native_pixmap_factory.h"
11 11
12 #if defined(OZONE_USE_VGEM_MAP) 12 #if defined(OZONE_USE_VGEM_MAP)
13 #include "ui/ozone/platform/drm/gpu/client_native_pixmap_vgem.h" 13 #include "ui/ozone/platform/drm/gpu/client_native_pixmap_vgem.h"
14
15 #include "base/command_line.h"
16 #include "ui/ozone/platform/drm/gpu/intel_drm_pixmap.h"
17 #include "ui/ozone/public/ozone_switches.h"
14 #endif 18 #endif
15 19
16 namespace ui { 20 namespace ui {
17 21
18 namespace { 22 namespace {
19 23
20 class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { 24 class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory {
21 public: 25 public:
22 ClientNativePixmapFactoryGbm() { 26 ClientNativePixmapFactoryGbm() {
23 #if defined(OZONE_USE_VGEM_MAP) 27 #if defined(OZONE_USE_VGEM_MAP)
24 // TODO(dshwang): remove ad-hoc file open. crrev.com/1248713002 28 // TODO(dshwang): remove ad-hoc file open. crrev.com/1248713002
29 static const char kRenderNodePath[] = "/dev/dri/renderD128";
25 static const char kVgemPath[] = "/dev/dri/renderD129"; 30 static const char kVgemPath[] = "/dev/dri/renderD129";
26 int vgem_fd = open(kVgemPath, O_RDWR | O_CLOEXEC); 31 bool enable_intel_drm = base::CommandLine::ForCurrentProcess()->HasSwitch(
32 switches::kOzoneUseIntelDrm);
33 int vgem_fd = open(enable_intel_drm ? kRenderNodePath : kVgemPath,
34 O_RDWR | O_CLOEXEC);
27 if (vgem_fd < 0) { 35 if (vgem_fd < 0) {
28 PLOG(ERROR) << "Failed to open: " << kVgemPath; 36 PLOG(ERROR) << "Failed to open: "
37 << (enable_intel_drm ? kRenderNodePath : kVgemPath);
29 return; 38 return;
30 } 39 }
31 vgem_fd_.reset(vgem_fd); 40 vgem_fd_.reset(vgem_fd);
32 #endif 41 #endif
33 } 42 }
34 ~ClientNativePixmapFactoryGbm() override {} 43 ~ClientNativePixmapFactoryGbm() override {}
35 44
36 // ClientNativePixmapFactory: 45 // ClientNativePixmapFactory:
37 std::vector<Configuration> GetSupportedConfigurations() const override { 46 std::vector<Configuration> GetSupportedConfigurations() const override {
38 const Configuration kConfiguratioins[] = { 47 const Configuration kConfiguratioins[] = {
(...skipping 17 matching lines...) Expand all
56 gfx::BufferUsage usage) override { 65 gfx::BufferUsage usage) override {
57 if (usage == gfx::BufferUsage::SCANOUT) { 66 if (usage == gfx::BufferUsage::SCANOUT) {
58 DCHECK(handle.fd.auto_close); 67 DCHECK(handle.fd.auto_close);
59 base::ScopedFD close_fd(handle.fd.fd); 68 base::ScopedFD close_fd(handle.fd.fd);
60 return nullptr; 69 return nullptr;
61 } 70 }
62 #if defined(OZONE_USE_VGEM_MAP) 71 #if defined(OZONE_USE_VGEM_MAP)
63 DCHECK_GE(vgem_fd_.get(), 0); 72 DCHECK_GE(vgem_fd_.get(), 0);
64 DCHECK(format == gfx::BufferFormat::BGRA_8888); 73 DCHECK(format == gfx::BufferFormat::BGRA_8888);
65 DCHECK(usage == gfx::BufferUsage::MAP); 74 DCHECK(usage == gfx::BufferUsage::MAP);
75
76 bool enable_intel_drm = base::CommandLine::ForCurrentProcess()->HasSwitch(
77 switches::kOzoneUseIntelDrm);
78 if (enable_intel_drm) {
79 return IntelDrmClientPixmap::CreateFromHandle(
80 handle, base::FileDescriptor(vgem_fd_.get(), false), format, size);
81 }
82
66 return ClientNativePixmapVgem::Create( 83 return ClientNativePixmapVgem::Create(
67 handle, base::FileDescriptor(vgem_fd_.get(), false), size); 84 handle, base::FileDescriptor(vgem_fd_.get(), false), size);
68 #else 85 #else
69 NOTREACHED(); 86 NOTREACHED();
70 return nullptr; 87 return nullptr;
71 #endif 88 #endif
72 } 89 }
73 90
74 private: 91 private:
75 base::ScopedFD vgem_fd_; 92 base::ScopedFD vgem_fd_;
76 93
77 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); 94 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm);
78 }; 95 };
79 96
80 } // namespace 97 } // namespace
81 98
82 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { 99 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() {
83 return new ClientNativePixmapFactoryGbm(); 100 return new ClientNativePixmapFactoryGbm();
84 } 101 }
85 102
86 } // namespace ui 103 } // namespace ui
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | ui/ozone/platform/drm/gbm.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698