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

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: rebase on crrev.com/1263323004 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>
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 #if defined(OZONE_USE_VGEM_MAP)
21 // TODO(dshwang): remove ad-hoc file open. crrev.com/1248713002
22 static const char kVgemPath[] = "/dev/dri/renderD129";
23 int vgem_fd = open(kVgemPath, O_RDWR | O_CLOEXEC);
24 if (vgem_fd < 0) {
25 PLOG(ERROR) << "Failed to open: " << kVgemPath;
26 return;
27 }
28 vgem_fd_.reset(vgem_fd);
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 if (vgem_fd_.get() >= 0) {
reveman 2015/08/06 12:08:35 why would this fail?
dshwang 2015/08/06 13:59:17 upstream linux doens't have vgem device. In additi
43 configurations.push_back(
44 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::MAP});
45 }
46 #endif
26 return configurations; 47 return configurations;
27 } 48 }
28 scoped_ptr<ClientNativePixmap> ImportFromHandle( 49 scoped_ptr<ClientNativePixmap> ImportFromHandle(
29 const gfx::NativePixmapHandle& handle, 50 const gfx::NativePixmapHandle& handle,
30 const gfx::Size& size, 51 const gfx::Size& size,
31 gfx::BufferFormat format, 52 gfx::BufferFormat format,
32 gfx::BufferUsage usage) override { 53 gfx::BufferUsage usage) override {
33 NOTIMPLEMENTED(); 54 DCHECK(usage == gfx::BufferUsage::MAP);
reveman 2015/08/06 12:08:35 why do we care what the usage is?
dshwang 2015/08/06 13:59:17 Either GpuMemoryBufferImplOzoneNativePixmap or Cli
34 return nullptr; 55 if (vgem_fd_.get() < 0)
56 return nullptr;
57 scoped_ptr<ClientNativePixmapVgem> pixmap(new ClientNativePixmapVgem(
58 handle, base::FileDescriptor(vgem_fd_.get(), false), size, format));
59 if (!pixmap->Initialize())
reveman 2015/08/06 12:08:35 can you move the work done in Initialize out here
dshwang 2015/08/06 13:59:17 do you mean that this function call directly "drmP
60 return nullptr;
61
62 return pixmap.Pass();
35 } 63 }
36 64
37 private: 65 private:
66 base::ScopedFD vgem_fd_;
67
38 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); 68 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm);
39 }; 69 };
40 70
41 } // namespace 71 } // namespace
42 72
43 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { 73 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() {
44 return new ClientNativePixmapFactoryGbm(); 74 return new ClientNativePixmapFactoryGbm();
45 } 75 }
46 76
47 } // namespace ui 77 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698