OLD | NEW |
---|---|
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> | |
8 | |
7 #include "base/file_descriptor_posix.h" | 9 #include "base/file_descriptor_posix.h" |
8 #include "ui/ozone/public/client_native_pixmap_factory.h" | 10 #include "ui/ozone/public/client_native_pixmap_factory.h" |
9 | 11 |
12 #if defined(OZONE_USE_VGEM_MAP) | |
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 if (vgem_fd < 0) { | |
28 PLOG(ERROR) << "Failed to open: " << kVgemPath; | |
29 return; | |
30 } | |
31 vgem_fd_.reset(vgem_fd); | |
32 #endif | |
33 } | |
17 ~ClientNativePixmapFactoryGbm() override {} | 34 ~ClientNativePixmapFactoryGbm() override {} |
18 | 35 |
19 // ClientNativePixmapFactory: | 36 // ClientNativePixmapFactory: |
20 std::vector<Configuration> GetSupportedConfigurations() const override { | 37 std::vector<Configuration> GetSupportedConfigurations() const override { |
21 const Configuration kConfiguratioins[] = { | 38 const Configuration kConfiguratioins[] = { |
22 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::SCANOUT}, | 39 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::SCANOUT}, |
23 {gfx::BufferFormat::RGBX_8888, gfx::BufferUsage::SCANOUT}}; | 40 {gfx::BufferFormat::RGBX_8888, gfx::BufferUsage::SCANOUT}}; |
24 std::vector<Configuration> configurations( | 41 std::vector<Configuration> configurations( |
25 kConfiguratioins, kConfiguratioins + arraysize(kConfiguratioins)); | 42 kConfiguratioins, kConfiguratioins + arraysize(kConfiguratioins)); |
43 #if defined(OZONE_USE_VGEM_MAP) | |
44 // Map requires VGEM supports. | |
45 if (vgem_fd_.get() >= 0) { | |
46 configurations.push_back( | |
47 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::MAP}); | |
48 } | |
49 #endif | |
26 return configurations; | 50 return configurations; |
27 } | 51 } |
28 scoped_ptr<ClientNativePixmap> ImportFromHandle( | 52 scoped_ptr<ClientNativePixmap> ImportFromHandle( |
29 const gfx::NativePixmapHandle& handle, | 53 const gfx::NativePixmapHandle& handle, |
30 const gfx::Size& size, | 54 const gfx::Size& size, |
31 gfx::BufferFormat format, | 55 gfx::BufferFormat format, |
32 gfx::BufferUsage usage) override { | 56 gfx::BufferUsage usage) override { |
33 NOTIMPLEMENTED(); | 57 if (usage == gfx::BufferUsage::SCANOUT) |
reveman
2015/08/07 14:35:16
would it hurt to still create the client pixmap?
dshwang
2015/08/07 15:36:46
Upstream linux cannot create vgem pixmap because v
| |
58 return nullptr; | |
59 #if defined(OZONE_USE_VGEM_MAP) | |
60 DCHECK_GE(vgem_fd_.get(), 0); | |
61 return ClientNativePixmapVgem::Create( | |
62 handle, base::FileDescriptor(vgem_fd_.get(), false), size, format, | |
63 usage); | |
64 #else | |
34 return nullptr; | 65 return nullptr; |
66 #endif | |
35 } | 67 } |
36 | 68 |
37 private: | 69 private: |
70 base::ScopedFD vgem_fd_; | |
71 | |
38 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); | 72 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); |
39 }; | 73 }; |
40 | 74 |
41 } // namespace | 75 } // namespace |
42 | 76 |
43 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { | 77 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { |
44 return new ClientNativePixmapFactoryGbm(); | 78 return new ClientNativePixmapFactoryGbm(); |
45 } | 79 } |
46 | 80 |
47 } // namespace ui | 81 } // namespace ui |
OLD | NEW |