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

Side by Side 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 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 "base/file_descriptor_posix.h" 7 #include "base/file_descriptor_posix.h"
8 #include "ui/gfx/native_pixmap_handle_ozone.h"
8 #include "ui/ozone/public/client_native_pixmap_factory.h" 9 #include "ui/ozone/public/client_native_pixmap_factory.h"
9 10
11 #if defined(OZONE_USE_VGEM_MAP)
12 #include <fcntl.h>
13 #include "ui/ozone/platform/drm/gpu/client_native_pixmap_vgem.h"
14 #endif
15
10 namespace ui { 16 namespace ui {
11 17
12 namespace { 18 namespace {
13 19
14 class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { 20 class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory {
15 public: 21 public:
16 ClientNativePixmapFactoryGbm() {} 22 ClientNativePixmapFactoryGbm() {
23 #if defined(OZONE_USE_VGEM_MAP)
24 // TODO(dshwang): remove ad-hoc file open. crrev.com/1248713002
25 static const char kVgemPath[] = "/dev/dri/renderD129";
26 int vgem_fd = open(kVgemPath, O_RDWR | O_CLOEXEC);
27 vgem_fd_.reset(vgem_fd);
28 DCHECK_GE(vgem_fd_.get(), 0) << "Failed to open: " << kVgemPath;
29 #endif
30 }
17 ~ClientNativePixmapFactoryGbm() override {} 31 ~ClientNativePixmapFactoryGbm() override {}
18 32
19 // ClientNativePixmapFactory: 33 // ClientNativePixmapFactory:
20 std::vector<Configuration> GetSupportedConfigurations() const override { 34 std::vector<Configuration> GetSupportedConfigurations() const override {
21 const Configuration kConfiguratioins[] = { 35 const Configuration kConfiguratioins[] = {
22 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::SCANOUT}, 36 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::SCANOUT},
23 {gfx::BufferFormat::RGBX_8888, gfx::BufferUsage::SCANOUT}}; 37 {gfx::BufferFormat::RGBX_8888, gfx::BufferUsage::SCANOUT}};
24 std::vector<Configuration> configurations( 38 std::vector<Configuration> configurations(
25 kConfiguratioins, kConfiguratioins + arraysize(kConfiguratioins)); 39 kConfiguratioins, kConfiguratioins + arraysize(kConfiguratioins));
40 #if defined(OZONE_USE_VGEM_MAP)
41 // Map requires VGEM supports.
42 DCHECK_GE(vgem_fd_.get(), 0);
43 configurations.push_back(
44 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::MAP});
45 #endif
26 return configurations; 46 return configurations;
27 } 47 }
28 scoped_ptr<ClientNativePixmap> ImportFromHandle( 48 scoped_ptr<ClientNativePixmap> ImportFromHandle(
29 const gfx::NativePixmapHandle& handle, 49 const gfx::NativePixmapHandle& handle,
30 const gfx::Size& size, 50 const gfx::Size& size,
31 gfx::BufferFormat format, 51 gfx::BufferFormat format,
32 gfx::BufferUsage usage) override { 52 gfx::BufferUsage usage) override {
33 NOTIMPLEMENTED(); 53 DCHECK(IsConfigurationSupported(format, usage));
54 DCHECK(handle.fd.auto_close);
55 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.
56
57 if (usage == gfx::BufferUsage::SCANOUT)
58 return nullptr;
59
60 #if defined(OZONE_USE_VGEM_MAP)
61 DCHECK_GE(vgem_fd_.get(), 0);
62 return ClientNativePixmapVgem::Create(
63 handle, base::FileDescriptor(vgem_fd_.get(), false), size);
64 #else
65 NOTREACHED();
34 return nullptr; 66 return nullptr;
67 #endif
35 } 68 }
36 69
37 private: 70 private:
71 bool IsConfigurationSupported(gfx::BufferFormat format,
72 gfx::BufferUsage usage) {
73 std::vector<Configuration> configurations(GetSupportedConfigurations());
74 for (auto& configuration : configurations) {
75 if (configuration.format == format && configuration.usage == usage)
76 return true;
77 }
78 return false;
79 }
80
81 #if defined(OZONE_USE_VGEM_MAP)
82 base::ScopedFD vgem_fd_;
83 #endif
84
38 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); 85 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm);
39 }; 86 };
40 87
41 } // namespace 88 } // namespace
42 89
43 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { 90 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() {
44 return new ClientNativePixmapFactoryGbm(); 91 return new ClientNativePixmapFactoryGbm();
45 } 92 }
46 93
47 } // namespace ui 94 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698