| 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 "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 } | 555 } |
| 556 | 556 |
| 557 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { | 557 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { |
| 558 DCHECK(CalledOnValidThread()); | 558 DCHECK(CalledOnValidThread()); |
| 559 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 559 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
| 560 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) | 560 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) |
| 561 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 561 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
| 562 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) | 562 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) |
| 563 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) | 563 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) |
| 564 IPC_MESSAGE_HANDLER(GpuHostMsg_ImageCreated, OnImageCreated) | 564 IPC_MESSAGE_HANDLER(GpuHostMsg_ImageCreated, OnImageCreated) |
| 565 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferAllocated, |
| 566 OnGpuMemoryBufferAllocated) |
| 565 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, | 567 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, |
| 566 OnDidCreateOffscreenContext) | 568 OnDidCreateOffscreenContext) |
| 567 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) | 569 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) |
| 568 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, | 570 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, |
| 569 OnDidDestroyOffscreenContext) | 571 OnDidDestroyOffscreenContext) |
| 570 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, | 572 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, |
| 571 OnGpuMemoryUmaStatsReceived) | 573 OnGpuMemoryUmaStatsReceived) |
| 572 #if defined(OS_MACOSX) | 574 #if defined(OS_MACOSX) |
| 573 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 575 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 574 OnAcceleratedSurfaceBuffersSwapped) | 576 OnAcceleratedSurfaceBuffersSwapped) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 void GpuProcessHost::DeleteImage(int client_id, | 662 void GpuProcessHost::DeleteImage(int client_id, |
| 661 int image_id, | 663 int image_id, |
| 662 int sync_point) { | 664 int sync_point) { |
| 663 TRACE_EVENT0("gpu", "GpuProcessHost::DeleteImage"); | 665 TRACE_EVENT0("gpu", "GpuProcessHost::DeleteImage"); |
| 664 | 666 |
| 665 DCHECK(CalledOnValidThread()); | 667 DCHECK(CalledOnValidThread()); |
| 666 | 668 |
| 667 Send(new GpuMsg_DeleteImage(client_id, image_id, sync_point)); | 669 Send(new GpuMsg_DeleteImage(client_id, image_id, sync_point)); |
| 668 } | 670 } |
| 669 | 671 |
| 672 void GpuProcessHost::AllocateGpuMemoryBuffer( |
| 673 const gfx::GpuMemoryBufferParams& params, |
| 674 const AllocateGpuMemoryBufferCallback& callback) { |
| 675 TRACE_EVENT0("gpu", "GpuProcessHost::CreateImage"); |
| 676 |
| 677 DCHECK(CalledOnValidThread()); |
| 678 |
| 679 if (Send(new GpuMsg_AllocateGpuMemoryBuffer(params))) { |
| 680 allocate_gpu_memory_buffer_requests_.push(callback); |
| 681 } else { |
| 682 callback.Run(gfx::GpuMemoryBufferHandle()); |
| 683 } |
| 684 } |
| 685 |
| 670 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { | 686 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { |
| 671 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); | 687 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); |
| 672 initialized_ = result; | 688 initialized_ = result; |
| 673 | 689 |
| 674 if (!initialized_) | 690 if (!initialized_) |
| 675 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); | 691 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); |
| 676 else if (!in_process_) | 692 else if (!in_process_) |
| 677 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 693 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
| 678 } | 694 } |
| 679 | 695 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated"); | 749 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated"); |
| 734 | 750 |
| 735 if (create_image_requests_.empty()) | 751 if (create_image_requests_.empty()) |
| 736 return; | 752 return; |
| 737 | 753 |
| 738 CreateImageCallback callback = create_image_requests_.front(); | 754 CreateImageCallback callback = create_image_requests_.front(); |
| 739 create_image_requests_.pop(); | 755 create_image_requests_.pop(); |
| 740 callback.Run(size); | 756 callback.Run(size); |
| 741 } | 757 } |
| 742 | 758 |
| 759 void GpuProcessHost::OnGpuMemoryBufferAllocated( |
| 760 const gfx::GpuMemoryBufferHandle& handle) { |
| 761 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated"); |
| 762 |
| 763 if (allocate_gpu_memory_buffer_requests_.empty()) |
| 764 return; |
| 765 |
| 766 AllocateGpuMemoryBufferCallback callback = |
| 767 allocate_gpu_memory_buffer_requests_.front(); |
| 768 allocate_gpu_memory_buffer_requests_.pop(); |
| 769 callback.Run(handle); |
| 770 } |
| 771 |
| 743 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { | 772 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { |
| 744 urls_with_live_offscreen_contexts_.insert(url); | 773 urls_with_live_offscreen_contexts_.insert(url); |
| 745 } | 774 } |
| 746 | 775 |
| 747 void GpuProcessHost::OnDidLoseContext(bool offscreen, | 776 void GpuProcessHost::OnDidLoseContext(bool offscreen, |
| 748 gpu::error::ContextLostReason reason, | 777 gpu::error::ContextLostReason reason, |
| 749 const GURL& url) { | 778 const GURL& url) { |
| 750 // TODO(kbr): would be nice to see the "offscreen" flag too. | 779 // TODO(kbr): would be nice to see the "offscreen" flag too. |
| 751 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", | 780 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", |
| 752 "reason", reason, | 781 "reason", reason, |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1094 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1066 ClientIdToShaderCacheMap::iterator iter = | 1095 ClientIdToShaderCacheMap::iterator iter = |
| 1067 client_id_to_shader_cache_.find(client_id); | 1096 client_id_to_shader_cache_.find(client_id); |
| 1068 // If the cache doesn't exist then this is an off the record profile. | 1097 // If the cache doesn't exist then this is an off the record profile. |
| 1069 if (iter == client_id_to_shader_cache_.end()) | 1098 if (iter == client_id_to_shader_cache_.end()) |
| 1070 return; | 1099 return; |
| 1071 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1100 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1072 } | 1101 } |
| 1073 | 1102 |
| 1074 } // namespace content | 1103 } // namespace content |
| OLD | NEW |