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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 context, | 531 context, |
532 !surface_id(), | 532 !surface_id(), |
533 initial_size_, | 533 initial_size_, |
534 disallowed_features_, | 534 disallowed_features_, |
535 requested_attribs_)) { | 535 requested_attribs_)) { |
536 DLOG(ERROR) << "Failed to initialize decoder."; | 536 DLOG(ERROR) << "Failed to initialize decoder."; |
537 OnInitializeFailed(reply_message); | 537 OnInitializeFailed(reply_message); |
538 return; | 538 return; |
539 } | 539 } |
540 | 540 |
541 gpu_control_.reset( | 541 gpu_control_service_.reset( |
542 new gpu::GpuControlService(context_group_->image_manager(), | 542 new gpu::GpuControlService(context_group_->image_manager(), NULL)); |
543 NULL, | |
544 context_group_->mailbox_manager(), | |
545 NULL, | |
546 decoder_->GetCapabilities())); | |
547 | 543 |
548 if (CommandLine::ForCurrentProcess()->HasSwitch( | 544 if (CommandLine::ForCurrentProcess()->HasSwitch( |
549 switches::kEnableGPUServiceLogging)) { | 545 switches::kEnableGPUServiceLogging)) { |
550 decoder_->set_log_commands(true); | 546 decoder_->set_log_commands(true); |
551 } | 547 } |
552 | 548 |
553 decoder_->GetLogger()->SetMsgCallback( | 549 decoder_->GetLogger()->SetMsgCallback( |
554 base::Bind(&GpuCommandBufferStub::SendConsoleMessage, | 550 base::Bind(&GpuCommandBufferStub::SendConsoleMessage, |
555 base::Unretained(this))); | 551 base::Unretained(this))); |
556 decoder_->SetShaderCacheCallback( | 552 decoder_->SetShaderCacheCallback( |
(...skipping 23 matching lines...) Expand all Loading... |
580 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); | 576 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); |
581 if (!shared_state_shm->Map(kSharedStateSize)) { | 577 if (!shared_state_shm->Map(kSharedStateSize)) { |
582 DLOG(ERROR) << "Failed to map shared state buffer."; | 578 DLOG(ERROR) << "Failed to map shared state buffer."; |
583 OnInitializeFailed(reply_message); | 579 OnInitializeFailed(reply_message); |
584 return; | 580 return; |
585 } | 581 } |
586 command_buffer_->SetSharedStateBuffer(gpu::MakeBackingFromSharedMemory( | 582 command_buffer_->SetSharedStateBuffer(gpu::MakeBackingFromSharedMemory( |
587 shared_state_shm.Pass(), kSharedStateSize)); | 583 shared_state_shm.Pass(), kSharedStateSize)); |
588 | 584 |
589 GpuCommandBufferMsg_Initialize::WriteReplyParams( | 585 GpuCommandBufferMsg_Initialize::WriteReplyParams( |
590 reply_message, true, gpu_control_->GetCapabilities()); | 586 reply_message, true, decoder_->GetCapabilities()); |
591 Send(reply_message); | 587 Send(reply_message); |
592 | 588 |
593 if (handle_.is_null() && !active_url_.is_empty()) { | 589 if (handle_.is_null() && !active_url_.is_empty()) { |
594 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 590 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
595 gpu_channel_manager->Send(new GpuHostMsg_DidCreateOffscreenContext( | 591 gpu_channel_manager->Send(new GpuHostMsg_DidCreateOffscreenContext( |
596 active_url_)); | 592 active_url_)); |
597 } | 593 } |
598 } | 594 } |
599 | 595 |
600 void GpuCommandBufferStub::OnSetLatencyInfo( | 596 void GpuCommandBufferStub::OnSetLatencyInfo( |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer"); | 931 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer"); |
936 #if defined(OS_ANDROID) | 932 #if defined(OS_ANDROID) |
937 // Verify that renderer is not trying to use a surface texture it doesn't own. | 933 // Verify that renderer is not trying to use a surface texture it doesn't own. |
938 if (gpu_memory_buffer.type == gfx::SURFACE_TEXTURE_BUFFER && | 934 if (gpu_memory_buffer.type == gfx::SURFACE_TEXTURE_BUFFER && |
939 gpu_memory_buffer.surface_texture_id.secondary_id != | 935 gpu_memory_buffer.surface_texture_id.secondary_id != |
940 channel()->client_id()) { | 936 channel()->client_id()) { |
941 LOG(ERROR) << "Illegal surface texture ID for renderer."; | 937 LOG(ERROR) << "Illegal surface texture ID for renderer."; |
942 return; | 938 return; |
943 } | 939 } |
944 #endif | 940 #endif |
945 if (gpu_control_) { | 941 if (gpu_control_service_) { |
946 gpu_control_->RegisterGpuMemoryBuffer(id, | 942 gpu_control_service_->RegisterGpuMemoryBuffer( |
947 gpu_memory_buffer, | 943 id, gpu_memory_buffer, width, height, internalformat); |
948 width, | |
949 height, | |
950 internalformat); | |
951 } | 944 } |
952 } | 945 } |
953 | 946 |
954 void GpuCommandBufferStub::OnDestroyGpuMemoryBuffer(int32 id) { | 947 void GpuCommandBufferStub::OnDestroyGpuMemoryBuffer(int32 id) { |
955 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyGpuMemoryBuffer"); | 948 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyGpuMemoryBuffer"); |
956 if (gpu_control_) | 949 if (gpu_control_service_) |
957 gpu_control_->DestroyGpuMemoryBuffer(id); | 950 gpu_control_service_->UnregisterGpuMemoryBuffer(id); |
958 } | 951 } |
959 | 952 |
960 void GpuCommandBufferStub::SendConsoleMessage( | 953 void GpuCommandBufferStub::SendConsoleMessage( |
961 int32 id, | 954 int32 id, |
962 const std::string& message) { | 955 const std::string& message) { |
963 GPUCommandBufferConsoleMessage console_message; | 956 GPUCommandBufferConsoleMessage console_message; |
964 console_message.id = id; | 957 console_message.id = id; |
965 console_message.message = message; | 958 console_message.message = message; |
966 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( | 959 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( |
967 route_id_, console_message); | 960 route_id_, console_message); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 if (decoder_) | 1042 if (decoder_) |
1050 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 1043 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); |
1051 command_buffer_->SetParseError(gpu::error::kLostContext); | 1044 command_buffer_->SetParseError(gpu::error::kLostContext); |
1052 } | 1045 } |
1053 | 1046 |
1054 uint64 GpuCommandBufferStub::GetMemoryUsage() const { | 1047 uint64 GpuCommandBufferStub::GetMemoryUsage() const { |
1055 return GetMemoryManager()->GetClientMemoryUsage(this); | 1048 return GetMemoryManager()->GetClientMemoryUsage(this); |
1056 } | 1049 } |
1057 | 1050 |
1058 } // namespace content | 1051 } // namespace content |
OLD | NEW |