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

Side by Side Diff: ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc

Issue 2711933002: Rename ClientNativePixmapFactoryGbm to ClientNativePixmapFactoryDmabuf amd move to ui/gfx (Closed)
Patch Set: Addressed sadrul's remark Created 3 years, 9 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/client_native_pixmap_factory_gbm.h" 5 #include "ui/ozone/platform/drm/client_native_pixmap_factory_gbm.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "ui/gfx/client_native_pixmap_factory.h" 11 #include "ui/gfx/linux/client_native_pixmap_factory_dmabuf.h"
12 #include "ui/gfx/native_pixmap_handle.h" 12 #include "ui/gfx/native_pixmap_handle.h"
13 #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h"
14 13
15 namespace ui { 14 namespace ui {
16 15
17 namespace {
18
19 class ClientNativePixmapGbm : public gfx::ClientNativePixmap {
20 public:
21 ClientNativePixmapGbm() {}
22 ~ClientNativePixmapGbm() override {}
23
24 bool Map() override {
25 NOTREACHED();
26 return false;
27 }
28 void Unmap() override { NOTREACHED(); }
29 void* GetMemoryAddress(size_t plane) const override {
30 NOTREACHED();
31 return nullptr;
32 }
33 int GetStride(size_t plane) const override {
34 NOTREACHED();
35 return 0;
36 }
37 };
38
39 } // namespace
40
41 class ClientNativePixmapFactoryGbm : public gfx::ClientNativePixmapFactory {
42 public:
43 ClientNativePixmapFactoryGbm() {}
44 ~ClientNativePixmapFactoryGbm() override {}
45
46 // ClientNativePixmapFactory:
47 bool IsConfigurationSupported(gfx::BufferFormat format,
48 gfx::BufferUsage usage) const override {
49 switch (usage) {
50 case gfx::BufferUsage::GPU_READ:
51 return format == gfx::BufferFormat::BGR_565 ||
52 format == gfx::BufferFormat::RGBA_8888 ||
53 format == gfx::BufferFormat::RGBX_8888 ||
54 format == gfx::BufferFormat::BGRA_8888 ||
55 format == gfx::BufferFormat::BGRX_8888 ||
56 format == gfx::BufferFormat::YVU_420;
57 case gfx::BufferUsage::SCANOUT:
58 return format == gfx::BufferFormat::BGRX_8888 ||
59 format == gfx::BufferFormat::RGBX_8888;
60 case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE:
61 return format == gfx::BufferFormat::BGRX_8888 ||
62 format == gfx::BufferFormat::BGRA_8888 ||
63 format == gfx::BufferFormat::RGBX_8888 ||
64 format == gfx::BufferFormat::RGBA_8888;
65 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE:
66 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: {
67 #if defined(OS_CHROMEOS)
68 return
69 #if defined(ARCH_CPU_X86_FAMILY)
70 // Currently only Intel driver (i.e. minigbm and Mesa) supports R_8
71 // and RG_88. crbug.com/356871
72 format == gfx::BufferFormat::R_8 ||
73 format == gfx::BufferFormat::RG_88 ||
74 #endif
75 format == gfx::BufferFormat::BGRA_8888;
76 #else
77 return false;
78 #endif
79 }
80 }
81 NOTREACHED();
82 return false;
83 }
84 std::unique_ptr<gfx::ClientNativePixmap> ImportFromHandle(
85 const gfx::NativePixmapHandle& handle,
86 const gfx::Size& size,
87 gfx::BufferUsage usage) override {
88 DCHECK(!handle.fds.empty());
89 switch (usage) {
90 case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE:
91 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE:
92 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT:
93 #if defined(OS_CHROMEOS)
94 return ClientNativePixmapDmaBuf::ImportFromDmabuf(handle, size);
95 #else
96 NOTREACHED();
97 return nullptr;
98 #endif
99 case gfx::BufferUsage::GPU_READ:
100 case gfx::BufferUsage::SCANOUT:
101 // Close all the fds.
102 for (const auto& fd : handle.fds)
103 base::ScopedFD scoped_fd(fd.fd);
104 return base::WrapUnique(new ClientNativePixmapGbm);
105 }
106 NOTREACHED();
107 return nullptr;
108 }
109
110 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm);
111 };
112
113 gfx::ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { 16 gfx::ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() {
114 return new ClientNativePixmapFactoryGbm(); 17 return gfx::CreateClientNativePixmapFactoryDmabuf();
115 } 18 }
116 19
117 } // namespace ui 20 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/BUILD.gn ('k') | ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698