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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/hash.h" | 9 #include "base/hash.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 context, | 532 context, |
533 !surface_id(), | 533 !surface_id(), |
534 initial_size_, | 534 initial_size_, |
535 disallowed_features_, | 535 disallowed_features_, |
536 requested_attribs_)) { | 536 requested_attribs_)) { |
537 DLOG(ERROR) << "Failed to initialize decoder."; | 537 DLOG(ERROR) << "Failed to initialize decoder."; |
538 OnInitializeFailed(reply_message); | 538 OnInitializeFailed(reply_message); |
539 return; | 539 return; |
540 } | 540 } |
541 | 541 |
542 gpu_control_.reset( | 542 gpu_control_service_.reset( |
543 new gpu::GpuControlService(context_group_->image_manager(), | 543 new gpu::GpuControlService(context_group_->image_manager(), |
544 NULL, | |
545 context_group_->mailbox_manager(), | 544 context_group_->mailbox_manager(), |
546 NULL, | 545 NULL)); |
547 decoder_->GetCapabilities())); | |
548 | 546 |
549 if (CommandLine::ForCurrentProcess()->HasSwitch( | 547 if (CommandLine::ForCurrentProcess()->HasSwitch( |
550 switches::kEnableGPUServiceLogging)) { | 548 switches::kEnableGPUServiceLogging)) { |
551 decoder_->set_log_commands(true); | 549 decoder_->set_log_commands(true); |
552 } | 550 } |
553 | 551 |
554 decoder_->GetLogger()->SetMsgCallback( | 552 decoder_->GetLogger()->SetMsgCallback( |
555 base::Bind(&GpuCommandBufferStub::SendConsoleMessage, | 553 base::Bind(&GpuCommandBufferStub::SendConsoleMessage, |
556 base::Unretained(this))); | 554 base::Unretained(this))); |
557 decoder_->SetShaderCacheCallback( | 555 decoder_->SetShaderCacheCallback( |
(...skipping 23 matching lines...) Expand all Loading... |
581 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); | 579 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); |
582 if (!shared_state_shm->Map(kSharedStateSize)) { | 580 if (!shared_state_shm->Map(kSharedStateSize)) { |
583 DLOG(ERROR) << "Failed to map shared state buffer."; | 581 DLOG(ERROR) << "Failed to map shared state buffer."; |
584 OnInitializeFailed(reply_message); | 582 OnInitializeFailed(reply_message); |
585 return; | 583 return; |
586 } | 584 } |
587 command_buffer_->SetSharedStateBuffer(gpu::MakeBackingFromSharedMemory( | 585 command_buffer_->SetSharedStateBuffer(gpu::MakeBackingFromSharedMemory( |
588 shared_state_shm.Pass(), kSharedStateSize)); | 586 shared_state_shm.Pass(), kSharedStateSize)); |
589 | 587 |
590 GpuCommandBufferMsg_Initialize::WriteReplyParams( | 588 GpuCommandBufferMsg_Initialize::WriteReplyParams( |
591 reply_message, true, gpu_control_->GetCapabilities()); | 589 reply_message, true, decoder_->GetCapabilities()); |
592 Send(reply_message); | 590 Send(reply_message); |
593 | 591 |
594 if (handle_.is_null() && !active_url_.is_empty()) { | 592 if (handle_.is_null() && !active_url_.is_empty()) { |
595 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 593 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
596 gpu_channel_manager->Send(new GpuHostMsg_DidCreateOffscreenContext( | 594 gpu_channel_manager->Send(new GpuHostMsg_DidCreateOffscreenContext( |
597 active_url_)); | 595 active_url_)); |
598 } | 596 } |
599 } | 597 } |
600 | 598 |
601 void GpuCommandBufferStub::OnSetLatencyInfo( | 599 void GpuCommandBufferStub::OnSetLatencyInfo( |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer"); | 947 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer"); |
950 #if defined(OS_ANDROID) | 948 #if defined(OS_ANDROID) |
951 // Verify that renderer is not trying to use a surface texture it doesn't own. | 949 // Verify that renderer is not trying to use a surface texture it doesn't own. |
952 if (gpu_memory_buffer.type == gfx::SURFACE_TEXTURE_BUFFER && | 950 if (gpu_memory_buffer.type == gfx::SURFACE_TEXTURE_BUFFER && |
953 gpu_memory_buffer.surface_texture_id.secondary_id != | 951 gpu_memory_buffer.surface_texture_id.secondary_id != |
954 channel()->client_id()) { | 952 channel()->client_id()) { |
955 LOG(ERROR) << "Illegal surface texture ID for renderer."; | 953 LOG(ERROR) << "Illegal surface texture ID for renderer."; |
956 return; | 954 return; |
957 } | 955 } |
958 #endif | 956 #endif |
959 if (gpu_control_) { | 957 if (gpu_control_service_) { |
960 gpu_control_->RegisterGpuMemoryBuffer(id, | 958 gpu_control_service_->RegisterGpuMemoryBuffer( |
961 gpu_memory_buffer, | 959 id, gpu_memory_buffer, width, height, internalformat); |
962 width, | |
963 height, | |
964 internalformat); | |
965 } | 960 } |
966 } | 961 } |
967 | 962 |
968 void GpuCommandBufferStub::OnDestroyGpuMemoryBuffer(int32 id) { | 963 void GpuCommandBufferStub::OnDestroyGpuMemoryBuffer(int32 id) { |
969 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyGpuMemoryBuffer"); | 964 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyGpuMemoryBuffer"); |
970 if (gpu_control_) | 965 if (gpu_control_service_) |
971 gpu_control_->DestroyGpuMemoryBuffer(id); | 966 gpu_control_service_->DestroyGpuMemoryBuffer(id); |
972 } | 967 } |
973 | 968 |
974 void GpuCommandBufferStub::SendConsoleMessage( | 969 void GpuCommandBufferStub::SendConsoleMessage( |
975 int32 id, | 970 int32 id, |
976 const std::string& message) { | 971 const std::string& message) { |
977 GPUCommandBufferConsoleMessage console_message; | 972 GPUCommandBufferConsoleMessage console_message; |
978 console_message.id = id; | 973 console_message.id = id; |
979 console_message.message = message; | 974 console_message.message = message; |
980 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( | 975 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( |
981 route_id_, console_message); | 976 route_id_, console_message); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 if (decoder_) | 1058 if (decoder_) |
1064 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 1059 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); |
1065 command_buffer_->SetParseError(gpu::error::kLostContext); | 1060 command_buffer_->SetParseError(gpu::error::kLostContext); |
1066 } | 1061 } |
1067 | 1062 |
1068 uint64 GpuCommandBufferStub::GetMemoryUsage() const { | 1063 uint64 GpuCommandBufferStub::GetMemoryUsage() const { |
1069 return GetMemoryManager()->GetClientMemoryUsage(this); | 1064 return GetMemoryManager()->GetClientMemoryUsage(this); |
1070 } | 1065 } |
1071 | 1066 |
1072 } // namespace content | 1067 } // namespace content |
OLD | NEW |