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

Side by Side Diff: services/ui/ws/mus_gpu_memory_buffer_manager.cc

Issue 2360203003: services/ui: Add mojom API for creating/destroying gpu memory buffer. (Closed)
Patch Set: . Created 4 years, 2 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
« no previous file with comments | « services/ui/ws/mus_gpu_memory_buffer_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/ui/ws/mus_gpu_memory_buffer_manager.h" 5 #include "services/ui/ws/mus_gpu_memory_buffer_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "gpu/ipc/client/gpu_memory_buffer_impl.h" 8 #include "gpu/ipc/client/gpu_memory_buffer_impl.h"
9 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" 9 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h"
10 #include "gpu/ipc/common/gpu_memory_buffer_support.h" 10 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
11 #include "services/ui/common/generic_shared_memory_id_generator.h" 11 #include "services/ui/common/generic_shared_memory_id_generator.h"
12 #include "services/ui/gpu/gpu_service_internal.h" 12 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h"
13 13
14 namespace ui { 14 namespace ui {
15 15
16 namespace ws { 16 namespace ws {
17 17
18 MusGpuMemoryBufferManager::MusGpuMemoryBufferManager( 18 MusGpuMemoryBufferManager::MusGpuMemoryBufferManager(
19 GpuServiceInternal* gpu_service, 19 mojom::GpuServiceInternal* gpu_service,
20 int client_id) 20 int client_id)
21 : gpu_service_(gpu_service), client_id_(client_id), weak_factory_(this) {} 21 : gpu_service_(gpu_service), client_id_(client_id), weak_factory_(this) {}
22 22
23 MusGpuMemoryBufferManager::~MusGpuMemoryBufferManager() {} 23 MusGpuMemoryBufferManager::~MusGpuMemoryBufferManager() {}
24 24
25 std::unique_ptr<gfx::GpuMemoryBuffer> 25 std::unique_ptr<gfx::GpuMemoryBuffer>
26 MusGpuMemoryBufferManager::AllocateGpuMemoryBuffer( 26 MusGpuMemoryBufferManager::AllocateGpuMemoryBuffer(
27 const gfx::Size& size, 27 const gfx::Size& size,
28 gfx::BufferFormat format, 28 gfx::BufferFormat format,
29 gfx::BufferUsage usage, 29 gfx::BufferUsage usage,
30 gpu::SurfaceHandle surface_handle) { 30 gpu::SurfaceHandle surface_handle) {
31 gfx::GpuMemoryBufferId id = GetNextGenericSharedMemoryId(); 31 gfx::GpuMemoryBufferId id = GetNextGenericSharedMemoryId();
32 const bool is_native = 32 const bool is_native =
33 gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage); 33 gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage);
34 if (is_native) { 34 if (is_native) {
35 gfx::GpuMemoryBufferHandle handle = gpu_service_->CreateGpuMemoryBuffer( 35 gfx::GpuMemoryBufferHandle handle;
36 id, size, format, usage, client_id_, surface_handle); 36 gpu_service_->CreateGpuMemoryBuffer(id, size, format, usage, client_id_,
37 surface_handle, &handle);
37 if (handle.is_null()) 38 if (handle.is_null())
38 return nullptr; 39 return nullptr;
39 return gpu::GpuMemoryBufferImpl::CreateFromHandle( 40 return gpu::GpuMemoryBufferImpl::CreateFromHandle(
40 handle, size, format, usage, 41 handle, size, format, usage,
41 base::Bind(&MusGpuMemoryBufferManager::DestroyGpuMemoryBuffer, 42 base::Bind(&MusGpuMemoryBufferManager::DestroyGpuMemoryBuffer,
42 weak_factory_.GetWeakPtr(), id, client_id_, is_native)); 43 weak_factory_.GetWeakPtr(), id, client_id_, is_native));
43 } 44 }
44 45
45 DCHECK(gpu::GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage)) 46 DCHECK(gpu::GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage))
46 << static_cast<int>(usage); 47 << static_cast<int>(usage);
(...skipping 30 matching lines...) Expand all
77 int client_id, 78 int client_id,
78 bool is_native, 79 bool is_native,
79 const gpu::SyncToken& sync_token) { 80 const gpu::SyncToken& sync_token) {
80 if (is_native) { 81 if (is_native) {
81 gpu_service_->DestroyGpuMemoryBuffer(id, client_id, sync_token); 82 gpu_service_->DestroyGpuMemoryBuffer(id, client_id, sync_token);
82 } 83 }
83 } 84 }
84 85
85 } // namespace ws 86 } // namespace ws
86 } // namespace ui 87 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/mus_gpu_memory_buffer_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698