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

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, 10 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"
12 #include "ui/gfx/client_native_pixmap_factory.h"
11 #include "ui/gfx/native_pixmap_handle.h" 13 #include "ui/gfx/native_pixmap_handle.h"
12 #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h" 14
13 #include "ui/ozone/public/client_native_pixmap_factory.h" 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return ClientNativePixmapDmaBuf::ImportFromDmabuf(handle, size); 95 return ClientNativePixmapDmaBuf::ImportFromDmabuf(handle, size);
89 #else 96 #else
90 NOTREACHED(); 97 NOTREACHED();
91 return nullptr; 98 return nullptr;
92 #endif 99 #endif
93 case gfx::BufferUsage::GPU_READ: 100 case gfx::BufferUsage::GPU_READ:
94 case gfx::BufferUsage::SCANOUT: 101 case gfx::BufferUsage::SCANOUT:
95 // Close all the fds. 102 // Close all the fds.
96 for (const auto& fd : handle.fds) 103 for (const auto& fd : handle.fds)
97 base::ScopedFD scoped_fd(fd.fd); 104 base::ScopedFD scoped_fd(fd.fd);
98 return base::WrapUnique(new ClientNativePixmapGbm); 105 return base::WrapUnique(new ClientNativePixmapOpaque);
99 } 106 }
100 NOTREACHED(); 107 NOTREACHED();
101 return nullptr; 108 return nullptr;
102 } 109 }
103 110
104 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); 111 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryDmabuf);
105 }; 112 };
106 113
107 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { 114 // static
108 return new ClientNativePixmapFactoryGbm(); 115 ClientNativePixmapFactory* CreateClientNativePixmapFactoryDmabuf() {
116 return new ClientNativePixmapFactoryDmabuf();
117 }
118
119 // static
120 std::unique_ptr<ClientNativePixmapFactory> ClientNativePixmapFactory::Create() {
121 TRACE_EVENT1("linux", "ClientNativePixmapFactory::Create", "plaform",
122 "dmabuf");
123 return base::WrapUnique(CreateClientNativePixmapFactoryDmabuf());
109 } 124 }
110 125
111 } // namespace ui 126 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698