| 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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 } | 559 } |
| 560 | 560 |
| 561 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { | 561 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { |
| 562 DCHECK(CalledOnValidThread()); | 562 DCHECK(CalledOnValidThread()); |
| 563 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 563 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
| 564 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) | 564 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) |
| 565 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 565 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
| 566 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) | 566 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) |
| 567 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) | 567 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) |
| 568 IPC_MESSAGE_HANDLER(GpuHostMsg_ImageCreated, OnImageCreated) | 568 IPC_MESSAGE_HANDLER(GpuHostMsg_ImageCreated, OnImageCreated) |
| 569 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated, |
| 570 OnGpuMemoryBufferCreated) |
| 569 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, | 571 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, |
| 570 OnDidCreateOffscreenContext) | 572 OnDidCreateOffscreenContext) |
| 571 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) | 573 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) |
| 572 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, | 574 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, |
| 573 OnDidDestroyOffscreenContext) | 575 OnDidDestroyOffscreenContext) |
| 574 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, | 576 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, |
| 575 OnGpuMemoryUmaStatsReceived) | 577 OnGpuMemoryUmaStatsReceived) |
| 576 #if defined(OS_MACOSX) | 578 #if defined(OS_MACOSX) |
| 577 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 579 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 578 OnAcceleratedSurfaceBuffersSwapped) | 580 OnAcceleratedSurfaceBuffersSwapped) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 void GpuProcessHost::DeleteImage(int client_id, | 666 void GpuProcessHost::DeleteImage(int client_id, |
| 665 int image_id, | 667 int image_id, |
| 666 int sync_point) { | 668 int sync_point) { |
| 667 TRACE_EVENT0("gpu", "GpuProcessHost::DeleteImage"); | 669 TRACE_EVENT0("gpu", "GpuProcessHost::DeleteImage"); |
| 668 | 670 |
| 669 DCHECK(CalledOnValidThread()); | 671 DCHECK(CalledOnValidThread()); |
| 670 | 672 |
| 671 Send(new GpuMsg_DeleteImage(client_id, image_id, sync_point)); | 673 Send(new GpuMsg_DeleteImage(client_id, image_id, sync_point)); |
| 672 } | 674 } |
| 673 | 675 |
| 676 void GpuProcessHost::CreateGpuMemoryBuffer( |
| 677 const gfx::GpuMemoryBufferHandle& handle, |
| 678 size_t width, |
| 679 size_t height, |
| 680 unsigned internalformat, |
| 681 unsigned usage, |
| 682 const CreateGpuMemoryBufferCallback& callback) { |
| 683 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); |
| 684 |
| 685 DCHECK(CalledOnValidThread()); |
| 686 |
| 687 if (Send(new GpuMsg_CreateGpuMemoryBuffer( |
| 688 handle, width, height, internalformat, usage))) { |
| 689 create_gpu_memory_buffer_requests_.push(callback); |
| 690 } else { |
| 691 callback.Run(gfx::GpuMemoryBufferHandle()); |
| 692 } |
| 693 } |
| 694 |
| 695 void GpuProcessHost::DestroyGpuMemoryBuffer( |
| 696 const gfx::GpuMemoryBufferHandle& handle, |
| 697 int sync_point) { |
| 698 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); |
| 699 |
| 700 DCHECK(CalledOnValidThread()); |
| 701 |
| 702 Send(new GpuMsg_DestroyGpuMemoryBuffer(handle, sync_point)); |
| 703 } |
| 704 |
| 674 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { | 705 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { |
| 675 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); | 706 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); |
| 676 initialized_ = result; | 707 initialized_ = result; |
| 677 | 708 |
| 678 if (!initialized_) | 709 if (!initialized_) |
| 679 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); | 710 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); |
| 680 else if (!in_process_) | 711 else if (!in_process_) |
| 681 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 712 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
| 682 } | 713 } |
| 683 | 714 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated"); | 768 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated"); |
| 738 | 769 |
| 739 if (create_image_requests_.empty()) | 770 if (create_image_requests_.empty()) |
| 740 return; | 771 return; |
| 741 | 772 |
| 742 CreateImageCallback callback = create_image_requests_.front(); | 773 CreateImageCallback callback = create_image_requests_.front(); |
| 743 create_image_requests_.pop(); | 774 create_image_requests_.pop(); |
| 744 callback.Run(size); | 775 callback.Run(size); |
| 745 } | 776 } |
| 746 | 777 |
| 778 void GpuProcessHost::OnGpuMemoryBufferCreated( |
| 779 const gfx::GpuMemoryBufferHandle& handle) { |
| 780 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); |
| 781 |
| 782 if (create_gpu_memory_buffer_requests_.empty()) |
| 783 return; |
| 784 |
| 785 CreateGpuMemoryBufferCallback callback = |
| 786 create_gpu_memory_buffer_requests_.front(); |
| 787 create_gpu_memory_buffer_requests_.pop(); |
| 788 callback.Run(handle); |
| 789 } |
| 790 |
| 747 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { | 791 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { |
| 748 urls_with_live_offscreen_contexts_.insert(url); | 792 urls_with_live_offscreen_contexts_.insert(url); |
| 749 } | 793 } |
| 750 | 794 |
| 751 void GpuProcessHost::OnDidLoseContext(bool offscreen, | 795 void GpuProcessHost::OnDidLoseContext(bool offscreen, |
| 752 gpu::error::ContextLostReason reason, | 796 gpu::error::ContextLostReason reason, |
| 753 const GURL& url) { | 797 const GURL& url) { |
| 754 // TODO(kbr): would be nice to see the "offscreen" flag too. | 798 // TODO(kbr): would be nice to see the "offscreen" flag too. |
| 755 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", | 799 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", |
| 756 "reason", reason, | 800 "reason", reason, |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1113 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1070 ClientIdToShaderCacheMap::iterator iter = | 1114 ClientIdToShaderCacheMap::iterator iter = |
| 1071 client_id_to_shader_cache_.find(client_id); | 1115 client_id_to_shader_cache_.find(client_id); |
| 1072 // If the cache doesn't exist then this is an off the record profile. | 1116 // If the cache doesn't exist then this is an off the record profile. |
| 1073 if (iter == client_id_to_shader_cache_.end()) | 1117 if (iter == client_id_to_shader_cache_.end()) |
| 1074 return; | 1118 return; |
| 1075 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1119 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1076 } | 1120 } |
| 1077 | 1121 |
| 1078 } // namespace content | 1122 } // namespace content |
| OLD | NEW |