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

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: Rebase 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/linux/client_native_pixmap_factory_dmabuf.h"
11 #include "ui/gfx/native_pixmap_handle.h" 12 #include "ui/gfx/native_pixmap_handle.h"
12 #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h"
13 #include "ui/ozone/public/client_native_pixmap_factory.h"
14 13
15 namespace ui { 14 namespace ui {
16 15
17 namespace {
18
19 class ClientNativePixmapGbm : public 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 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::GPU_READ_CPU_READ_WRITE:
61 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: {
62 #if defined(OS_CHROMEOS)
63 return
64 #if defined(ARCH_CPU_X86_FAMILY)
65 // Currently only Intel driver (i.e. minigbm and Mesa) supports R_8
66 // and RG_88. crbug.com/356871
67 format == gfx::BufferFormat::R_8 ||
68 format == gfx::BufferFormat::RG_88 ||
69 #endif
70 format == gfx::BufferFormat::BGRA_8888;
71 #else
72 return false;
73 #endif
74 }
75 }
76 NOTREACHED();
77 return false;
78 }
79 std::unique_ptr<ClientNativePixmap> ImportFromHandle(
80 const gfx::NativePixmapHandle& handle,
81 const gfx::Size& size,
82 gfx::BufferUsage usage) override {
83 DCHECK(!handle.fds.empty());
84 switch (usage) {
85 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE:
86 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT:
87 #if defined(OS_CHROMEOS)
88 return ClientNativePixmapDmaBuf::ImportFromDmabuf(handle, size);
89 #else
90 NOTREACHED();
91 return nullptr;
92 #endif
93 case gfx::BufferUsage::GPU_READ:
94 case gfx::BufferUsage::SCANOUT:
95 // Close all the fds.
96 for (const auto& fd : handle.fds)
97 base::ScopedFD scoped_fd(fd.fd);
98 return base::WrapUnique(new ClientNativePixmapGbm);
99 }
100 NOTREACHED();
101 return nullptr;
102 }
103
104 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm);
105 };
106
107 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { 16 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() {
108 return new ClientNativePixmapFactoryGbm(); 17 return CreateClientNativePixmapFactoryDmabuf();
109 } 18 }
110 19
111 } // namespace ui 20 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698