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" |
| 10 #include "ui/ozone/platform/drm/gpu/client_native_pixmap_vgem.h" | |
| 8 #include "ui/ozone/public/client_native_pixmap_factory.h" | 11 #include "ui/ozone/public/client_native_pixmap_factory.h" |
| 9 | 12 |
| 10 namespace ui { | 13 namespace ui { |
| 11 | 14 |
| 12 namespace { | 15 namespace { |
| 13 | 16 |
| 14 class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { | 17 class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { |
| 15 public: | 18 public: |
| 16 ClientNativePixmapFactoryGbm() {} | 19 ClientNativePixmapFactoryGbm() { |
| 20 // TODO(dshwang): remove ad-hoc file open. crrev.com/1248713002 | |
|
dshwang
2015/08/05 12:33:16
as spang requested in https://codereview.chromium.
| |
| 21 static const char kVgemPath[] = "/dev/dri/renderD129"; | |
| 22 int vgem_fd = open(kVgemPath, O_RDWR | O_CLOEXEC); | |
| 23 if (vgem_fd < 0) { | |
| 24 PLOG(ERROR) << "Failed to open: " << kVgemPath; | |
| 25 return; | |
| 26 } | |
| 27 vgem_fd_.reset(vgem_fd); | |
| 28 } | |
| 17 ~ClientNativePixmapFactoryGbm() override {} | 29 ~ClientNativePixmapFactoryGbm() override {} |
| 18 | 30 |
| 19 // ClientNativePixmapFactory: | 31 // ClientNativePixmapFactory: |
| 20 std::vector<Configuration> GetSupportedConfigurations() const override { | 32 std::vector<Configuration> GetSupportedConfigurations() const override { |
| 21 const Configuration kConfiguratioins[] = { | 33 const Configuration kConfiguratioins[] = { |
| 22 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::SCANOUT}, | 34 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::SCANOUT}, |
| 23 {gfx::BufferFormat::RGBX_8888, gfx::BufferUsage::SCANOUT}}; | 35 {gfx::BufferFormat::RGBX_8888, gfx::BufferUsage::SCANOUT}}; |
| 24 std::vector<Configuration> configurations( | 36 std::vector<Configuration> configurations( |
| 25 kConfiguratioins, kConfiguratioins + arraysize(kConfiguratioins)); | 37 kConfiguratioins, kConfiguratioins + arraysize(kConfiguratioins)); |
| 38 #if defined(OZONE_USE_VGEM_MAP) | |
| 39 // Map requires VGEM supports. | |
| 40 if (vgem_fd_.get() >= 0) { | |
| 41 configurations.push_back( | |
| 42 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::MAP}); | |
| 43 } | |
| 44 #endif | |
| 26 return configurations; | 45 return configurations; |
| 27 } | 46 } |
| 28 scoped_ptr<ClientNativePixmap> ImportNativePixmap( | 47 scoped_ptr<ClientNativePixmap> ImportNativePixmap( |
| 29 const base::FileDescriptor& handle, | 48 const base::FileDescriptor& handle, |
| 30 const gfx::Size& size, | 49 const gfx::Size& size, |
| 31 gfx::BufferFormat format, | 50 gfx::BufferFormat format, |
| 32 gfx::BufferUsage usage) override { | 51 gfx::BufferUsage usage) override { |
| 33 NOTIMPLEMENTED(); | 52 if (vgem_fd_.get() < 0) |
| 34 return nullptr; | 53 return nullptr; |
| 54 scoped_ptr<ClientNativePixmapVgem> pixmap(new ClientNativePixmapVgem( | |
| 55 handle, base::FileDescriptor(vgem_fd_.get(), false), size, format, | |
| 56 usage)); | |
| 57 if (!pixmap->Initialize()) | |
| 58 return nullptr; | |
| 59 | |
| 60 return pixmap.Pass(); | |
| 35 } | 61 } |
| 36 | 62 |
| 37 private: | 63 private: |
| 64 base::ScopedFD vgem_fd_; | |
| 65 | |
| 38 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); | 66 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); |
| 39 }; | 67 }; |
| 40 | 68 |
| 41 } // namespace | 69 } // namespace |
| 42 | 70 |
| 43 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { | 71 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { |
| 44 return new ClientNativePixmapFactoryGbm(); | 72 return new ClientNativePixmapFactoryGbm(); |
| 45 } | 73 } |
| 46 | 74 |
| 47 } // namespace ui | 75 } // namespace ui |
| OLD | NEW |