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

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

Issue 2316733002: gpu: Delete unnecessary code. (Closed)
Patch Set: . Created 4 years, 3 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 | « gpu/ipc/common/gpu_memory_buffer_support.cc ('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/gpu_service_internal.h"
13 13
14 namespace ui { 14 namespace ui {
15 15
16 namespace {
17
18 bool IsNativeGpuMemoryBufferFactoryConfigurationSupported(
19 gfx::BufferFormat format,
20 gfx::BufferUsage usage) {
21 switch (gpu::GetNativeGpuMemoryBufferType()) {
22 case gfx::SHARED_MEMORY_BUFFER:
23 return false;
24 case gfx::IO_SURFACE_BUFFER:
25 case gfx::SURFACE_TEXTURE_BUFFER:
26 case gfx::OZONE_NATIVE_PIXMAP:
27 return gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage);
28 default:
29 NOTREACHED();
30 return false;
31 }
32 }
33
34 } // namespace
35
36 namespace ws { 16 namespace ws {
37 17
38 MusGpuMemoryBufferManager::MusGpuMemoryBufferManager( 18 MusGpuMemoryBufferManager::MusGpuMemoryBufferManager(
39 GpuServiceInternal* gpu_service, 19 GpuServiceInternal* gpu_service,
40 int client_id) 20 int client_id)
41 : gpu_service_(gpu_service), client_id_(client_id), weak_factory_(this) {} 21 : gpu_service_(gpu_service), client_id_(client_id), weak_factory_(this) {}
42 22
43 MusGpuMemoryBufferManager::~MusGpuMemoryBufferManager() {} 23 MusGpuMemoryBufferManager::~MusGpuMemoryBufferManager() {}
44 24
45 std::unique_ptr<gfx::GpuMemoryBuffer> 25 std::unique_ptr<gfx::GpuMemoryBuffer>
46 MusGpuMemoryBufferManager::AllocateGpuMemoryBuffer( 26 MusGpuMemoryBufferManager::AllocateGpuMemoryBuffer(
47 const gfx::Size& size, 27 const gfx::Size& size,
48 gfx::BufferFormat format, 28 gfx::BufferFormat format,
49 gfx::BufferUsage usage, 29 gfx::BufferUsage usage,
50 gpu::SurfaceHandle surface_handle) { 30 gpu::SurfaceHandle surface_handle) {
51 gfx::GpuMemoryBufferId id = GetNextGenericSharedMemoryId(); 31 gfx::GpuMemoryBufferId id = GetNextGenericSharedMemoryId();
52 const bool is_native = 32 const bool is_native =
53 IsNativeGpuMemoryBufferFactoryConfigurationSupported(format, usage); 33 gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage);
54 if (is_native) { 34 if (is_native) {
55 gfx::GpuMemoryBufferHandle handle = gpu_service_->CreateGpuMemoryBuffer( 35 gfx::GpuMemoryBufferHandle handle = gpu_service_->CreateGpuMemoryBuffer(
56 id, size, format, usage, client_id_, surface_handle); 36 id, size, format, usage, client_id_, surface_handle);
57 if (handle.is_null()) 37 if (handle.is_null())
58 return nullptr; 38 return nullptr;
59 return gpu::GpuMemoryBufferImpl::CreateFromHandle( 39 return gpu::GpuMemoryBufferImpl::CreateFromHandle(
60 handle, size, format, usage, 40 handle, size, format, usage,
61 base::Bind(&MusGpuMemoryBufferManager::DestroyGpuMemoryBuffer, 41 base::Bind(&MusGpuMemoryBufferManager::DestroyGpuMemoryBuffer,
62 weak_factory_.GetWeakPtr(), id, client_id_, is_native)); 42 weak_factory_.GetWeakPtr(), id, client_id_, is_native));
63 } 43 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 int client_id, 77 int client_id,
98 bool is_native, 78 bool is_native,
99 const gpu::SyncToken& sync_token) { 79 const gpu::SyncToken& sync_token) {
100 if (is_native) { 80 if (is_native) {
101 gpu_service_->DestroyGpuMemoryBuffer(id, client_id, sync_token); 81 gpu_service_->DestroyGpuMemoryBuffer(id, client_id, sync_token);
102 } 82 }
103 } 83 }
104 84
105 } // namespace ws 85 } // namespace ws
106 } // namespace ui 86 } // namespace ui
OLDNEW
« no previous file with comments | « gpu/ipc/common/gpu_memory_buffer_support.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698