| OLD | NEW |
| 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/common/mus_gpu_memory_buffer_manager.h" | 5 #include "services/ui/common/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/gpu/interfaces/gpu_service_internal.mojom.h" | 11 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 | 14 |
| 15 MusGpuMemoryBufferManager::MusGpuMemoryBufferManager( | 15 MusGpuMemoryBufferManager::MusGpuMemoryBufferManager( |
| 16 mojom::GpuServiceInternal* gpu_service, | 16 mojom::GpuServiceInternal* gpu_service, |
| 17 int client_id) | 17 int client_id) |
| 18 : gpu_service_(gpu_service), client_id_(client_id), weak_factory_(this) {} | 18 : gpu_service_(gpu_service), |
| 19 client_id_(client_id), |
| 20 native_configurations_(gpu::GetNativeGpuMemoryBufferConfigurations()), |
| 21 weak_factory_(this) {} |
| 19 | 22 |
| 20 MusGpuMemoryBufferManager::~MusGpuMemoryBufferManager() {} | 23 MusGpuMemoryBufferManager::~MusGpuMemoryBufferManager() {} |
| 21 | 24 |
| 22 gfx::GpuMemoryBufferHandle | 25 gfx::GpuMemoryBufferHandle |
| 23 MusGpuMemoryBufferManager::CreateGpuMemoryBufferHandle( | 26 MusGpuMemoryBufferManager::CreateGpuMemoryBufferHandle( |
| 24 gfx::GpuMemoryBufferId id, | 27 gfx::GpuMemoryBufferId id, |
| 25 int client_id, | 28 int client_id, |
| 26 const gfx::Size& size, | 29 const gfx::Size& size, |
| 27 gfx::BufferFormat format, | 30 gfx::BufferFormat format, |
| 28 gfx::BufferUsage usage, | 31 gfx::BufferUsage usage, |
| 29 gpu::SurfaceHandle surface_handle) { | 32 gpu::SurfaceHandle surface_handle) { |
| 30 DCHECK(CalledOnValidThread()); | 33 DCHECK(CalledOnValidThread()); |
| 31 if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) { | 34 if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) { |
| 32 const bool is_native = | 35 const bool is_native = native_configurations_.find(std::make_pair( |
| 33 gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage); | 36 format, usage)) != native_configurations_.end(); |
| 34 if (is_native) { | 37 if (is_native) { |
| 35 gfx::GpuMemoryBufferHandle handle; | 38 gfx::GpuMemoryBufferHandle handle; |
| 36 gpu_service_->CreateGpuMemoryBuffer(id, size, format, usage, client_id, | 39 gpu_service_->CreateGpuMemoryBuffer(id, size, format, usage, client_id, |
| 37 surface_handle, &handle); | 40 surface_handle, &handle); |
| 38 if (!handle.is_null()) | 41 if (!handle.is_null()) |
| 39 native_buffers_[client_id].insert(handle.id); | 42 native_buffers_[client_id].insert(handle.id); |
| 40 return handle; | 43 return handle; |
| 41 } | 44 } |
| 42 } | 45 } |
| 43 | 46 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 95 |
| 93 void MusGpuMemoryBufferManager::DestroyAllGpuMemoryBufferForClient( | 96 void MusGpuMemoryBufferManager::DestroyAllGpuMemoryBufferForClient( |
| 94 int client_id) { | 97 int client_id) { |
| 95 DCHECK(CalledOnValidThread()); | 98 DCHECK(CalledOnValidThread()); |
| 96 for (gfx::GpuMemoryBufferId id : native_buffers_[client_id]) | 99 for (gfx::GpuMemoryBufferId id : native_buffers_[client_id]) |
| 97 gpu_service_->DestroyGpuMemoryBuffer(id, client_id, gpu::SyncToken()); | 100 gpu_service_->DestroyGpuMemoryBuffer(id, client_id, gpu::SyncToken()); |
| 98 native_buffers_.erase(client_id); | 101 native_buffers_.erase(client_id); |
| 99 } | 102 } |
| 100 | 103 |
| 101 } // namespace ui | 104 } // namespace ui |
| OLD | NEW |