Chromium Code Reviews| 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 17:59:44
what happens if we simply ignore this check here?
dshwang
2015/08/11 17:44:56
ImportFromHandle() doesn't create pixmap, so GpuMe
reveman
2015/08/11 18:53:53
Why doesn't ImportFromHandle() create a pixmap? an
dshwang
2015/08/11 19:36:06
I didn't fully understand your question "what happ
reveman
2015/08/11 20:15:16
I'm just trying to understand the motivation for t
dshwang
2015/08/12 08:57:35
crrev.com/1263323004 returns ClientNativePixmapGbm
| |
| 58 DCHECK(handle.fd.auto_close); | |
| 59 base::ScopedFD close_fd(handle.fd.fd); | |
| 60 return nullptr; | |
| 61 } | |
| 62 #if defined(OZONE_USE_VGEM_MAP) | |
| 63 DCHECK_GE(vgem_fd_.get(), 0); | |
| 64 DCHECK(format == gfx::BufferFormat::BGRA_8888); | |
|
reveman
2015/08/07 17:59:44
DCHECK_EQ and move outside the ifdef as we might a
dshwang
2015/08/11 17:44:56
I tried DCHECK_EQ but compile fail because DCHECK_
| |
| 65 DCHECK(usage == gfx::BufferUsage::MAP); | |
|
reveman
2015/08/07 17:59:44
can we instead check that the configuration is ret
dshwang
2015/08/11 17:44:56
Look at line 47 in GetSupportedConfigurations(). G
reveman
2015/08/11 18:53:53
All the code being in the same file is why I'm que
dshwang
2015/08/11 19:36:06
Done. now I understand your request correctly. I c
| |
| 66 return ClientNativePixmapVgem::Create( | |
| 67 handle, base::FileDescriptor(vgem_fd_.get(), false), size); | |
| 68 #else | |
| 69 NOTREACHED(); | |
| 34 return nullptr; | 70 return nullptr; |
| 71 #endif | |
| 35 } | 72 } |
| 36 | 73 |
| 37 private: | 74 private: |
| 75 base::ScopedFD vgem_fd_; | |
| 76 | |
| 38 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); | 77 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); |
| 39 }; | 78 }; |
| 40 | 79 |
| 41 } // namespace | 80 } // namespace |
| 42 | 81 |
| 43 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { | 82 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { |
| 44 return new ClientNativePixmapFactoryGbm(); | 83 return new ClientNativePixmapFactoryGbm(); |
| 45 } | 84 } |
| 46 | 85 |
| 47 } // namespace ui | 86 } // namespace ui |
| OLD | NEW |