| 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/gpu/gpu_service.h" | 5 #include "services/ui/gpu/gpu_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 const gpu::SyncToken& sync_token) { | 234 const gpu::SyncToken& sync_token) { |
| 235 if (io_runner_->BelongsToCurrentThread()) { | 235 if (io_runner_->BelongsToCurrentThread()) { |
| 236 main_runner_->PostTask( | 236 main_runner_->PostTask( |
| 237 FROM_HERE, base::Bind(&GpuService::DestroyGpuMemoryBuffer, weak_ptr_, | 237 FROM_HERE, base::Bind(&GpuService::DestroyGpuMemoryBuffer, weak_ptr_, |
| 238 id, client_id, sync_token)); | 238 id, client_id, sync_token)); |
| 239 return; | 239 return; |
| 240 } | 240 } |
| 241 gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token); | 241 gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token); |
| 242 } | 242 } |
| 243 | 243 |
| 244 void GpuService::GetGpuMemoryBufferAttribs( |
| 245 const GetGpuMemoryBufferAttribsCallback& callback) { |
| 246 if (gpu_memory_buffer_attribs_.size() > 0) { |
| 247 callback.Run(gpu_memory_buffer_attribs_); |
| 248 return; |
| 249 } |
| 250 |
| 251 for (int i = 0; i < static_cast<int>(gfx::BufferUsage::LAST); i++) { |
| 252 gfx::GpuMemoryBufferAttribVector tmp = |
| 253 gpu_memory_buffer_factory_->GetGpuMemoryBufferAttribsForUsage( |
| 254 static_cast<gfx::BufferUsage>(i)); |
| 255 if (tmp.size() == 0) |
| 256 continue; |
| 257 |
| 258 gfx::GpuMemoryBufferAttribVector intersection; |
| 259 std::sort(tmp.begin(), tmp.end()); |
| 260 |
| 261 if (gpu_memory_buffer_attribs_.size() == 0) |
| 262 gpu_memory_buffer_attribs_ = std::move(tmp); |
| 263 else { |
| 264 std::set_intersection(gpu_memory_buffer_attribs_.begin(), |
| 265 gpu_memory_buffer_attribs_.end(), |
| 266 tmp.begin(), tmp.end(), |
| 267 std::back_inserter(intersection)); |
| 268 gpu_memory_buffer_attribs_ = std::move(intersection); |
| 269 } |
| 270 } |
| 271 |
| 272 callback.Run(gpu_memory_buffer_attribs_); |
| 273 } |
| 274 |
| 244 void GpuService::GetVideoMemoryUsageStats( | 275 void GpuService::GetVideoMemoryUsageStats( |
| 245 const GetVideoMemoryUsageStatsCallback& callback) { | 276 const GetVideoMemoryUsageStatsCallback& callback) { |
| 246 if (io_runner_->BelongsToCurrentThread()) { | 277 if (io_runner_->BelongsToCurrentThread()) { |
| 247 auto wrap_callback = WrapCallback(io_runner_, callback); | 278 auto wrap_callback = WrapCallback(io_runner_, callback); |
| 248 main_runner_->PostTask( | 279 main_runner_->PostTask( |
| 249 FROM_HERE, base::Bind(&GpuService::GetVideoMemoryUsageStats, weak_ptr_, | 280 FROM_HERE, base::Bind(&GpuService::GetVideoMemoryUsageStats, weak_ptr_, |
| 250 wrap_callback)); | 281 wrap_callback)); |
| 251 return; | 282 return; |
| 252 } | 283 } |
| 253 gpu::VideoMemoryUsageStats video_memory_usage_stats; | 284 gpu::VideoMemoryUsageStats video_memory_usage_stats; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 | 529 |
| 499 void GpuService::Stop(const StopCallback& callback) { | 530 void GpuService::Stop(const StopCallback& callback) { |
| 500 DCHECK(io_runner_->BelongsToCurrentThread()); | 531 DCHECK(io_runner_->BelongsToCurrentThread()); |
| 501 main_runner_->PostTaskAndReply(FROM_HERE, base::Bind([] { | 532 main_runner_->PostTaskAndReply(FROM_HERE, base::Bind([] { |
| 502 base::MessageLoop::current()->QuitWhenIdle(); | 533 base::MessageLoop::current()->QuitWhenIdle(); |
| 503 }), | 534 }), |
| 504 callback); | 535 callback); |
| 505 } | 536 } |
| 506 | 537 |
| 507 } // namespace ui | 538 } // namespace ui |
| OLD | NEW |