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

Side by Side Diff: components/exo/display.cc

Issue 2572703004: exo: Directly create GpuMemoryBufferImpl when a handle is available. (Closed)
Patch Set: fix non-ozone build Created 4 years 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
« no previous file with comments | « no previous file | components/exo/shared_memory.cc » ('j') | components/exo/shared_memory.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/exo/display.h" 5 #include "components/exo/display.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/trace_event/trace_event.h" 13 #include "base/trace_event/trace_event.h"
14 #include "base/trace_event/trace_event_argument.h" 14 #include "base/trace_event/trace_event_argument.h"
15 #include "components/exo/notification_surface.h" 15 #include "components/exo/notification_surface.h"
16 #include "components/exo/notification_surface_manager.h" 16 #include "components/exo/notification_surface_manager.h"
17 #include "components/exo/shared_memory.h" 17 #include "components/exo/shared_memory.h"
18 #include "components/exo/shell_surface.h" 18 #include "components/exo/shell_surface.h"
19 #include "components/exo/sub_surface.h" 19 #include "components/exo/sub_surface.h"
20 #include "components/exo/surface.h" 20 #include "components/exo/surface.h"
21 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
22 #include "ui/wm/core/coordinate_conversion.h" 22 #include "ui/wm/core/coordinate_conversion.h"
23 23
24 #if defined(USE_OZONE) 24 #if defined(USE_OZONE)
25 #include <GLES2/gl2extchromium.h> 25 #include <GLES2/gl2extchromium.h>
26 #include "components/exo/buffer.h" 26 #include "components/exo/buffer.h"
27 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 27 #include "gpu/ipc/client/gpu_memory_buffer_impl.h"
28 #include "third_party/khronos/GLES2/gl2.h" 28 #include "third_party/khronos/GLES2/gl2.h"
29 #include "third_party/khronos/GLES2/gl2ext.h" 29 #include "third_party/khronos/GLES2/gl2ext.h"
30 #include "ui/aura/env.h"
31 #endif 30 #endif
32 31
32 #if defined(USE_OZONE)
33 namespace {
34
35 void DoNothing(const gpu::SyncToken& sync) {}
36
37 } // namespace
38 #endif // defined(USE_OZONE)
39
33 namespace exo { 40 namespace exo {
34 41
35 //////////////////////////////////////////////////////////////////////////////// 42 ////////////////////////////////////////////////////////////////////////////////
36 // Display, public: 43 // Display, public:
37 44
38 Display::Display() : notification_surface_manager_(nullptr) {} 45 Display::Display() : notification_surface_manager_(nullptr) {}
39 46
40 Display::Display(NotificationSurfaceManager* notification_surface_manager) 47 Display::Display(NotificationSurfaceManager* notification_surface_manager)
41 : notification_surface_manager_(notification_surface_manager) {} 48 : notification_surface_manager_(notification_surface_manager) {}
42 49
(...skipping 26 matching lines...) Expand all
69 size.ToString()); 76 size.ToString());
70 77
71 gfx::GpuMemoryBufferHandle handle; 78 gfx::GpuMemoryBufferHandle handle;
72 handle.type = gfx::OZONE_NATIVE_PIXMAP; 79 handle.type = gfx::OZONE_NATIVE_PIXMAP;
73 for (auto& fd : fds) 80 for (auto& fd : fds)
74 handle.native_pixmap_handle.fds.emplace_back(std::move(fd)); 81 handle.native_pixmap_handle.fds.emplace_back(std::move(fd));
75 82
76 for (auto& plane : planes) 83 for (auto& plane : planes)
77 handle.native_pixmap_handle.planes.push_back(plane); 84 handle.native_pixmap_handle.planes.push_back(plane);
78 85
79 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = 86 auto gpu_memory_buffer = gpu::GpuMemoryBufferImpl::CreateFromHandle(
reveman 2016/12/13 21:30:53 Can you use gpu::GpuMemoryBufferImplOzoneNativePix
sadrul 2016/12/14 01:41:30 Done.
80 aura::Env::GetInstance() 87 handle, size, format, gfx::BufferUsage::GPU_READ, base::Bind(&DoNothing));
81 ->context_factory()
82 ->GetGpuMemoryBufferManager()
83 ->CreateGpuMemoryBufferFromHandle(handle, size, format);
84 if (!gpu_memory_buffer) { 88 if (!gpu_memory_buffer) {
85 LOG(ERROR) << "Failed to create GpuMemoryBuffer from handle"; 89 LOG(ERROR) << "Failed to create GpuMemoryBuffer from handle";
86 return nullptr; 90 return nullptr;
87 } 91 }
88 92
89 // Using zero-copy for optimal performance. 93 // Using zero-copy for optimal performance.
90 bool use_zero_copy = true; 94 bool use_zero_copy = true;
91 95
92 // List of overlay formats that are known to be supported. 96 // List of overlay formats that are known to be supported.
93 // TODO(reveman): Determine this at runtime. 97 // TODO(reveman): Determine this at runtime.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 notification_surface_manager_->GetSurface(notification_id)) { 200 notification_surface_manager_->GetSurface(notification_id)) {
197 DLOG(ERROR) << "Invalid notification id, id=" << notification_id; 201 DLOG(ERROR) << "Invalid notification id, id=" << notification_id;
198 return nullptr; 202 return nullptr;
199 } 203 }
200 204
201 return base::MakeUnique<NotificationSurface>(notification_surface_manager_, 205 return base::MakeUnique<NotificationSurface>(notification_surface_manager_,
202 surface, notification_id); 206 surface, notification_id);
203 } 207 }
204 208
205 } // namespace exo 209 } // namespace exo
OLDNEW
« no previous file with comments | « no previous file | components/exo/shared_memory.cc » ('j') | components/exo/shared_memory.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698