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

Side by Side Diff: ui/gfx/linux/client_native_pixmap_factory_dmabuf.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/gfx/linux/client_native_pixmap_factory_dmabuf.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 "base/trace_event/trace_event.h"
11 #include "ui/gfx/client_native_pixmap_factory.h" 12 #include "ui/gfx/client_native_pixmap_factory.h"
12 #include "ui/gfx/native_pixmap_handle.h" 13 #include "ui/gfx/native_pixmap_handle.h"
13 #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h" 14
15 #if defined(OS_CHROMEOS)
16 // This can be enabled on all linux but it is not a requirement to support
17 // glCreateImageChromium+Dmabuf since it uses gfx::BufferUsage::SCANOUT and
18 // the pixmap does not need to be mappable on the client side.
19 #include "ui/gfx/linux/client_native_pixmap_dmabuf.h"
20 #endif
14 21
15 namespace ui { 22 namespace ui {
16 23
17 namespace { 24 namespace {
18 25
19 class ClientNativePixmapGbm : public ClientNativePixmap { 26 class ClientNativePixmapOpaque : public ClientNativePixmap {
20 public: 27 public:
21 ClientNativePixmapGbm() {} 28 ClientNativePixmapOpaque() {}
22 ~ClientNativePixmapGbm() override {} 29 ~ClientNativePixmapOpaque() override {}
23 30
24 bool Map() override { 31 bool Map() override {
25 NOTREACHED(); 32 NOTREACHED();
26 return false; 33 return false;
27 } 34 }
28 void Unmap() override { NOTREACHED(); } 35 void Unmap() override { NOTREACHED(); }
29 void* GetMemoryAddress(size_t plane) const override { 36 void* GetMemoryAddress(size_t plane) const override {
30 NOTREACHED(); 37 NOTREACHED();
31 return nullptr; 38 return nullptr;
32 } 39 }
33 int GetStride(size_t plane) const override { 40 int GetStride(size_t plane) const override {
34 NOTREACHED(); 41 NOTREACHED();
35 return 0; 42 return 0;
36 } 43 }
37 }; 44 };
38 45
39 } // namespace 46 } // namespace
40 47
41 class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { 48 class ClientNativePixmapFactoryDmabuf : public ClientNativePixmapFactory {
42 public: 49 public:
43 ClientNativePixmapFactoryGbm() {} 50 ClientNativePixmapFactoryDmabuf() {}
44 ~ClientNativePixmapFactoryGbm() override {} 51 ~ClientNativePixmapFactoryDmabuf() override {}
45 52
46 // ClientNativePixmapFactory: 53 // ClientNativePixmapFactory:
47 bool IsConfigurationSupported(gfx::BufferFormat format, 54 bool IsConfigurationSupported(gfx::BufferFormat format,
48 gfx::BufferUsage usage) const override { 55 gfx::BufferUsage usage) const override {
49 switch (usage) { 56 switch (usage) {
50 case gfx::BufferUsage::GPU_READ: 57 case gfx::BufferUsage::GPU_READ:
51 return format == gfx::BufferFormat::BGR_565 || 58 return format == gfx::BufferFormat::BGR_565 ||
52 format == gfx::BufferFormat::RGBA_8888 || 59 format == gfx::BufferFormat::RGBA_8888 ||
53 format == gfx::BufferFormat::RGBX_8888 || 60 format == gfx::BufferFormat::RGBX_8888 ||
54 format == gfx::BufferFormat::BGRA_8888 || 61 format == gfx::BufferFormat::BGRA_8888 ||
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return ClientNativePixmapDmaBuf::ImportFromDmabuf(handle, size); 101 return ClientNativePixmapDmaBuf::ImportFromDmabuf(handle, size);
95 #else 102 #else
96 NOTREACHED(); 103 NOTREACHED();
97 return nullptr; 104 return nullptr;
98 #endif 105 #endif
99 case gfx::BufferUsage::GPU_READ: 106 case gfx::BufferUsage::GPU_READ:
100 case gfx::BufferUsage::SCANOUT: 107 case gfx::BufferUsage::SCANOUT:
101 // Close all the fds. 108 // Close all the fds.
102 for (const auto& fd : handle.fds) 109 for (const auto& fd : handle.fds)
103 base::ScopedFD scoped_fd(fd.fd); 110 base::ScopedFD scoped_fd(fd.fd);
104 return base::WrapUnique(new ClientNativePixmapGbm); 111 return base::WrapUnique(new ClientNativePixmapOpaque);
105 } 112 }
106 NOTREACHED(); 113 NOTREACHED();
107 return nullptr; 114 return nullptr;
108 } 115 }
109 116
110 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); 117 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryDmabuf);
111 }; 118 };
112 119
113 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { 120 // static
114 return new ClientNativePixmapFactoryGbm(); 121 ClientNativePixmapFactory* CreateClientNativePixmapFactoryDmabuf() {
122 return new ClientNativePixmapFactoryDmabuf();
123 }
124
125 // static
126 std::unique_ptr<ClientNativePixmapFactory> ClientNativePixmapFactory::Create() {
127 TRACE_EVENT1("linux", "ClientNativePixmapFactory::Create", "plaform",
128 "dmabuf");
129 return base::WrapUnique(CreateClientNativePixmapFactoryDmabuf());
115 } 130 }
116 131
117 } // namespace ui 132 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698