| 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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 surface_refs_.insert(std::make_pair(surface_id, | 644 surface_refs_.insert(std::make_pair(surface_id, |
| 645 GpuSurfaceTracker::GetInstance()->GetSurfaceRefForSurface(surface_id))); | 645 GpuSurfaceTracker::GetInstance()->GetSurfaceRefForSurface(surface_id))); |
| 646 } else { | 646 } else { |
| 647 // Could distinguish here between compositing_surface being NULL | 647 // Could distinguish here between compositing_surface being NULL |
| 648 // and Send failing, if desired. | 648 // and Send failing, if desired. |
| 649 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); | 649 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); |
| 650 } | 650 } |
| 651 } | 651 } |
| 652 | 652 |
| 653 void GpuProcessHost::CreateGpuMemoryBuffer( | 653 void GpuProcessHost::CreateGpuMemoryBuffer( |
| 654 const gfx::GpuMemoryBufferHandle& handle, | 654 gfx::GpuMemoryBufferType type, |
| 655 gfx::GpuMemoryBufferId id, |
| 655 const gfx::Size& size, | 656 const gfx::Size& size, |
| 656 gfx::GpuMemoryBuffer::Format format, | 657 gfx::GpuMemoryBuffer::Format format, |
| 657 gfx::GpuMemoryBuffer::Usage usage, | 658 gfx::GpuMemoryBuffer::Usage usage, |
| 659 int client_id, |
| 658 const CreateGpuMemoryBufferCallback& callback) { | 660 const CreateGpuMemoryBufferCallback& callback) { |
| 659 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); | 661 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); |
| 660 | 662 |
| 661 DCHECK(CalledOnValidThread()); | 663 DCHECK(CalledOnValidThread()); |
| 662 | 664 |
| 663 if (Send(new GpuMsg_CreateGpuMemoryBuffer(handle, size, format, usage))) { | 665 GpuMsg_CreateGpuMemoryBuffer_Params params; |
| 666 params.type = type; |
| 667 params.id = id; |
| 668 params.size = size; |
| 669 params.format = format; |
| 670 params.usage = usage; |
| 671 params.client_id = client_id; |
| 672 if (Send(new GpuMsg_CreateGpuMemoryBuffer(params))) { |
| 664 create_gpu_memory_buffer_requests_.push(callback); | 673 create_gpu_memory_buffer_requests_.push(callback); |
| 665 } else { | 674 } else { |
| 666 callback.Run(gfx::GpuMemoryBufferHandle()); | 675 callback.Run(gfx::GpuMemoryBufferHandle()); |
| 667 } | 676 } |
| 668 } | 677 } |
| 669 | 678 |
| 670 void GpuProcessHost::DestroyGpuMemoryBuffer( | 679 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferType type, |
| 671 const gfx::GpuMemoryBufferHandle& handle, | 680 gfx::GpuMemoryBufferId id, |
| 672 int sync_point) { | 681 int client_id, |
| 682 int sync_point) { |
| 673 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); | 683 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); |
| 674 | 684 |
| 675 DCHECK(CalledOnValidThread()); | 685 DCHECK(CalledOnValidThread()); |
| 676 | 686 |
| 677 Send(new GpuMsg_DestroyGpuMemoryBuffer(handle, sync_point)); | 687 Send(new GpuMsg_DestroyGpuMemoryBuffer(type, id, client_id, sync_point)); |
| 678 } | 688 } |
| 679 | 689 |
| 680 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { | 690 void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { |
| 681 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); | 691 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); |
| 682 initialized_ = result; | 692 initialized_ = result; |
| 683 | 693 |
| 684 if (!initialized_) | 694 if (!initialized_) |
| 685 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); | 695 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); |
| 686 else if (!in_process_) | 696 else if (!in_process_) |
| 687 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 697 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1070 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1061 ClientIdToShaderCacheMap::iterator iter = | 1071 ClientIdToShaderCacheMap::iterator iter = |
| 1062 client_id_to_shader_cache_.find(client_id); | 1072 client_id_to_shader_cache_.find(client_id); |
| 1063 // If the cache doesn't exist then this is an off the record profile. | 1073 // If the cache doesn't exist then this is an off the record profile. |
| 1064 if (iter == client_id_to_shader_cache_.end()) | 1074 if (iter == client_id_to_shader_cache_.end()) |
| 1065 return; | 1075 return; |
| 1066 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1076 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1067 } | 1077 } |
| 1068 | 1078 |
| 1069 } // namespace content | 1079 } // namespace content |
| OLD | NEW |