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

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

Issue 2572703004: exo: Directly create GpuMemoryBufferImpl when a handle is available. (Closed)
Patch Set: null callback 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 | « cc/test/test_gpu_memory_buffer_manager.cc ('k') | components/exo/shared_memory.cc » ('j') | no next file with comments »
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_ozone_native_pixmap.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
33 namespace exo { 32 namespace exo {
34 33
35 //////////////////////////////////////////////////////////////////////////////// 34 ////////////////////////////////////////////////////////////////////////////////
36 // Display, public: 35 // Display, public:
37 36
38 Display::Display() : notification_surface_manager_(nullptr) {} 37 Display::Display() : notification_surface_manager_(nullptr) {}
39 38
40 Display::Display(NotificationSurfaceManager* notification_surface_manager) 39 Display::Display(NotificationSurfaceManager* notification_surface_manager)
(...skipping 29 matching lines...) Expand all
70 69
71 gfx::GpuMemoryBufferHandle handle; 70 gfx::GpuMemoryBufferHandle handle;
72 handle.type = gfx::OZONE_NATIVE_PIXMAP; 71 handle.type = gfx::OZONE_NATIVE_PIXMAP;
73 for (auto& fd : fds) 72 for (auto& fd : fds)
74 handle.native_pixmap_handle.fds.emplace_back(std::move(fd)); 73 handle.native_pixmap_handle.fds.emplace_back(std::move(fd));
75 74
76 for (auto& plane : planes) 75 for (auto& plane : planes)
77 handle.native_pixmap_handle.planes.push_back(plane); 76 handle.native_pixmap_handle.planes.push_back(plane);
78 77
79 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = 78 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer =
80 aura::Env::GetInstance() 79 gpu::GpuMemoryBufferImplOzoneNativePixmap::CreateFromHandle(
81 ->context_factory() 80 handle, size, format, gfx::BufferUsage::GPU_READ,
82 ->GetGpuMemoryBufferManager() 81 gpu::GpuMemoryBufferImpl::DestructionCallback());
83 ->CreateGpuMemoryBufferFromHandle(handle, size, format);
84 if (!gpu_memory_buffer) { 82 if (!gpu_memory_buffer) {
85 LOG(ERROR) << "Failed to create GpuMemoryBuffer from handle"; 83 LOG(ERROR) << "Failed to create GpuMemoryBuffer from handle";
86 return nullptr; 84 return nullptr;
87 } 85 }
88 86
89 // Using zero-copy for optimal performance. 87 // Using zero-copy for optimal performance.
90 bool use_zero_copy = true; 88 bool use_zero_copy = true;
91 89
92 // List of overlay formats that are known to be supported. 90 // List of overlay formats that are known to be supported.
93 // TODO(reveman): Determine this at runtime. 91 // 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)) { 194 notification_surface_manager_->GetSurface(notification_id)) {
197 DLOG(ERROR) << "Invalid notification id, id=" << notification_id; 195 DLOG(ERROR) << "Invalid notification id, id=" << notification_id;
198 return nullptr; 196 return nullptr;
199 } 197 }
200 198
201 return base::MakeUnique<NotificationSurface>(notification_surface_manager_, 199 return base::MakeUnique<NotificationSurface>(notification_surface_manager_,
202 surface, notification_id); 200 surface, notification_id);
203 } 201 }
204 202
205 } // namespace exo 203 } // namespace exo
OLDNEW
« no previous file with comments | « cc/test/test_gpu_memory_buffer_manager.cc ('k') | components/exo/shared_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698