| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/gpu/gpu_process_host.h" | 5 #include "content/browser/gpu/gpu_process_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 // it for 'gpu thread' mode and only create one instance of host and thread. | 505 // it for 'gpu thread' mode and only create one instance of host and thread. |
| 506 DCHECK(!in_process_ || g_gpu_process_hosts[kind] == NULL); | 506 DCHECK(!in_process_ || g_gpu_process_hosts[kind] == NULL); |
| 507 | 507 |
| 508 g_gpu_process_hosts[kind] = this; | 508 g_gpu_process_hosts[kind] = this; |
| 509 | 509 |
| 510 process_.reset(new BrowserChildProcessHostImpl( | 510 process_.reset(new BrowserChildProcessHostImpl( |
| 511 PROCESS_TYPE_GPU, this, mojom::kGpuServiceName)); | 511 PROCESS_TYPE_GPU, this, mojom::kGpuServiceName)); |
| 512 } | 512 } |
| 513 | 513 |
| 514 GpuProcessHost::~GpuProcessHost() { | 514 GpuProcessHost::~GpuProcessHost() { |
| 515 DCHECK(CalledOnValidThread()); | 515 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 516 | 516 |
| 517 SendOutstandingReplies(); | 517 SendOutstandingReplies(); |
| 518 | 518 |
| 519 // In case we never started, clean up. | 519 // In case we never started, clean up. |
| 520 while (!queued_messages_.empty()) { | 520 while (!queued_messages_.empty()) { |
| 521 delete queued_messages_.front(); | 521 delete queued_messages_.front(); |
| 522 queued_messages_.pop(); | 522 queued_messages_.pop(); |
| 523 } | 523 } |
| 524 | 524 |
| 525 // This is only called on the IO thread so no race against the constructor | 525 // This is only called on the IO thread so no race against the constructor |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 ->OnGpuProcessLaunched( | 652 ->OnGpuProcessLaunched( |
| 653 host_id_, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), | 653 host_id_, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), |
| 654 base::ThreadTaskRunnerHandle::Get(), | 654 base::ThreadTaskRunnerHandle::Get(), |
| 655 base::Bind(&SendGpuProcessMessage, weak_ptr_factory_.GetWeakPtr())); | 655 base::Bind(&SendGpuProcessMessage, weak_ptr_factory_.GetWeakPtr())); |
| 656 #endif | 656 #endif |
| 657 | 657 |
| 658 return true; | 658 return true; |
| 659 } | 659 } |
| 660 | 660 |
| 661 bool GpuProcessHost::Send(IPC::Message* msg) { | 661 bool GpuProcessHost::Send(IPC::Message* msg) { |
| 662 DCHECK(CalledOnValidThread()); | 662 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 663 if (process_->GetHost()->IsChannelOpening()) { | 663 if (process_->GetHost()->IsChannelOpening()) { |
| 664 queued_messages_.push(msg); | 664 queued_messages_.push(msg); |
| 665 return true; | 665 return true; |
| 666 } | 666 } |
| 667 | 667 |
| 668 bool result = process_->Send(msg); | 668 bool result = process_->Send(msg); |
| 669 if (!result) { | 669 if (!result) { |
| 670 // Channel is hosed, but we may not get destroyed for a while. Send | 670 // Channel is hosed, but we may not get destroyed for a while. Send |
| 671 // outstanding channel creation failures now so that the caller can restart | 671 // outstanding channel creation failures now so that the caller can restart |
| 672 // with a new process/channel without waiting. | 672 // with a new process/channel without waiting. |
| 673 SendOutstandingReplies(); | 673 SendOutstandingReplies(); |
| 674 } | 674 } |
| 675 return result; | 675 return result; |
| 676 } | 676 } |
| 677 | 677 |
| 678 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { | 678 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { |
| 679 DCHECK(CalledOnValidThread()); | 679 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 680 #if defined(USE_OZONE) | 680 #if defined(USE_OZONE) |
| 681 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 681 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 682 base::Bind(&RouteMessageToOzoneOnUI, message)); | 682 base::Bind(&RouteMessageToOzoneOnUI, message)); |
| 683 #endif | 683 #endif |
| 684 return true; | 684 return true; |
| 685 } | 685 } |
| 686 | 686 |
| 687 void GpuProcessHost::OnChannelConnected(int32_t peer_pid) { | 687 void GpuProcessHost::OnChannelConnected(int32_t peer_pid) { |
| 688 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); | 688 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); |
| 689 | 689 |
| 690 while (!queued_messages_.empty()) { | 690 while (!queued_messages_.empty()) { |
| 691 Send(queued_messages_.front()); | 691 Send(queued_messages_.front()); |
| 692 queued_messages_.pop(); | 692 queued_messages_.pop(); |
| 693 } | 693 } |
| 694 } | 694 } |
| 695 | 695 |
| 696 void GpuProcessHost::EstablishGpuChannel( | 696 void GpuProcessHost::EstablishGpuChannel( |
| 697 int client_id, | 697 int client_id, |
| 698 uint64_t client_tracing_id, | 698 uint64_t client_tracing_id, |
| 699 bool preempts, | 699 bool preempts, |
| 700 bool allow_view_command_buffers, | 700 bool allow_view_command_buffers, |
| 701 bool allow_real_time_streams, | 701 bool allow_real_time_streams, |
| 702 const EstablishChannelCallback& callback) { | 702 const EstablishChannelCallback& callback) { |
| 703 DCHECK(CalledOnValidThread()); | 703 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 704 TRACE_EVENT0("gpu", "GpuProcessHost::EstablishGpuChannel"); | 704 TRACE_EVENT0("gpu", "GpuProcessHost::EstablishGpuChannel"); |
| 705 | 705 |
| 706 // If GPU features are already blacklisted, no need to establish the channel. | 706 // If GPU features are already blacklisted, no need to establish the channel. |
| 707 if (!GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { | 707 if (!GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { |
| 708 DVLOG(1) << "GPU blacklisted, refusing to open a GPU channel."; | 708 DVLOG(1) << "GPU blacklisted, refusing to open a GPU channel."; |
| 709 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), | 709 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), |
| 710 EstablishChannelStatus::GPU_ACCESS_DENIED); | 710 EstablishChannelStatus::GPU_ACCESS_DENIED); |
| 711 return; | 711 return; |
| 712 } | 712 } |
| 713 | 713 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 730 void GpuProcessHost::CreateGpuMemoryBuffer( | 730 void GpuProcessHost::CreateGpuMemoryBuffer( |
| 731 gfx::GpuMemoryBufferId id, | 731 gfx::GpuMemoryBufferId id, |
| 732 const gfx::Size& size, | 732 const gfx::Size& size, |
| 733 gfx::BufferFormat format, | 733 gfx::BufferFormat format, |
| 734 gfx::BufferUsage usage, | 734 gfx::BufferUsage usage, |
| 735 int client_id, | 735 int client_id, |
| 736 gpu::SurfaceHandle surface_handle, | 736 gpu::SurfaceHandle surface_handle, |
| 737 const CreateGpuMemoryBufferCallback& callback) { | 737 const CreateGpuMemoryBufferCallback& callback) { |
| 738 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); | 738 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); |
| 739 | 739 |
| 740 DCHECK(CalledOnValidThread()); | 740 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 741 create_gpu_memory_buffer_requests_.push(callback); | 741 create_gpu_memory_buffer_requests_.push(callback); |
| 742 gpu_service_ptr_->CreateGpuMemoryBuffer( | 742 gpu_service_ptr_->CreateGpuMemoryBuffer( |
| 743 id, size, format, usage, client_id, surface_handle, | 743 id, size, format, usage, client_id, surface_handle, |
| 744 base::Bind(&GpuProcessHost::OnGpuMemoryBufferCreated, | 744 base::Bind(&GpuProcessHost::OnGpuMemoryBufferCreated, |
| 745 weak_ptr_factory_.GetWeakPtr())); | 745 weak_ptr_factory_.GetWeakPtr())); |
| 746 } | 746 } |
| 747 | 747 |
| 748 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 748 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
| 749 int client_id, | 749 int client_id, |
| 750 const gpu::SyncToken& sync_token) { | 750 const gpu::SyncToken& sync_token) { |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 if (!cache.get()) | 1207 if (!cache.get()) |
| 1208 return; | 1208 return; |
| 1209 | 1209 |
| 1210 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, | 1210 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, |
| 1211 weak_ptr_factory_.GetWeakPtr())); | 1211 weak_ptr_factory_.GetWeakPtr())); |
| 1212 | 1212 |
| 1213 client_id_to_shader_cache_[client_id] = cache; | 1213 client_id_to_shader_cache_[client_id] = cache; |
| 1214 } | 1214 } |
| 1215 | 1215 |
| 1216 } // namespace content | 1216 } // namespace content |
| OLD | NEW |