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_GpuMemoryBufferCreated, |
| 566 OnGpuMemoryBufferCreated) |
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::CreateGpuMemoryBuffer( |
| 673 size_t width, |
| 674 size_t height, |
| 675 unsigned internalformat, |
| 676 unsigned usage, |
| 677 const gfx::GpuMemoryBufferHandle& handle, |
| 678 const CreateGpuMemoryBufferCallback& callback) { |
| 679 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); |
| 680 |
| 681 DCHECK(CalledOnValidThread()); |
| 682 |
| 683 if (Send(new GpuMsg_CreateGpuMemoryBuffer( |
| 684 width, height, internalformat, usage, handle))) { |
| 685 create_gpu_memory_buffer_requests_.push(callback); |
| 686 } else { |
| 687 callback.Run(gfx::GpuMemoryBufferHandle()); |
| 688 } |
| 689 } |
| 690 |
| 691 void GpuProcessHost::DeleteGpuMemoryBuffer( |
| 692 const gfx::GpuMemoryBufferHandle& handle, |
| 693 int sync_point) { |
| 694 TRACE_EVENT0("gpu", "GpuProcessHost::DeleteGpuMemoryBuffer"); |
| 695 |
| 696 DCHECK(CalledOnValidThread()); |
| 697 |
| 698 Send(new GpuMsg_DeleteGpuMemoryBuffer(handle, sync_point)); |
| 699 } |
| 700 |
670 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { | 701 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { |
671 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); | 702 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); |
672 initialized_ = result; | 703 initialized_ = result; |
673 | 704 |
674 if (!initialized_) | 705 if (!initialized_) |
675 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); | 706 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); |
676 else if (!in_process_) | 707 else if (!in_process_) |
677 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 708 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
678 } | 709 } |
679 | 710 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated"); | 764 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated"); |
734 | 765 |
735 if (create_image_requests_.empty()) | 766 if (create_image_requests_.empty()) |
736 return; | 767 return; |
737 | 768 |
738 CreateImageCallback callback = create_image_requests_.front(); | 769 CreateImageCallback callback = create_image_requests_.front(); |
739 create_image_requests_.pop(); | 770 create_image_requests_.pop(); |
740 callback.Run(size); | 771 callback.Run(size); |
741 } | 772 } |
742 | 773 |
| 774 void GpuProcessHost::OnGpuMemoryBufferCreated( |
| 775 const gfx::GpuMemoryBufferHandle& handle) { |
| 776 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); |
| 777 |
| 778 if (create_gpu_memory_buffer_requests_.empty()) |
| 779 return; |
| 780 |
| 781 CreateGpuMemoryBufferCallback callback = |
| 782 create_gpu_memory_buffer_requests_.front(); |
| 783 create_gpu_memory_buffer_requests_.pop(); |
| 784 callback.Run(handle); |
| 785 } |
| 786 |
743 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { | 787 void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { |
744 urls_with_live_offscreen_contexts_.insert(url); | 788 urls_with_live_offscreen_contexts_.insert(url); |
745 } | 789 } |
746 | 790 |
747 void GpuProcessHost::OnDidLoseContext(bool offscreen, | 791 void GpuProcessHost::OnDidLoseContext(bool offscreen, |
748 gpu::error::ContextLostReason reason, | 792 gpu::error::ContextLostReason reason, |
749 const GURL& url) { | 793 const GURL& url) { |
750 // TODO(kbr): would be nice to see the "offscreen" flag too. | 794 // TODO(kbr): would be nice to see the "offscreen" flag too. |
751 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", | 795 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext", |
752 "reason", reason, | 796 "reason", reason, |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1109 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1066 ClientIdToShaderCacheMap::iterator iter = | 1110 ClientIdToShaderCacheMap::iterator iter = |
1067 client_id_to_shader_cache_.find(client_id); | 1111 client_id_to_shader_cache_.find(client_id); |
1068 // If the cache doesn't exist then this is an off the record profile. | 1112 // If the cache doesn't exist then this is an off the record profile. |
1069 if (iter == client_id_to_shader_cache_.end()) | 1113 if (iter == client_id_to_shader_cache_.end()) |
1070 return; | 1114 return; |
1071 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1115 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1072 } | 1116 } |
1073 | 1117 |
1074 } // namespace content | 1118 } // namespace content |
OLD | NEW |