| 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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 return true; | 294 return true; |
| 295 DLOG(ERROR) << "Context lost because MakeCurrent failed."; | 295 DLOG(ERROR) << "Context lost because MakeCurrent failed."; |
| 296 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); | 296 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); |
| 297 command_buffer_->SetParseError(gpu::error::kLostContext); | 297 command_buffer_->SetParseError(gpu::error::kLostContext); |
| 298 if (gfx::GLContext::LosesAllContextsOnContextLost()) | 298 if (gfx::GLContext::LosesAllContextsOnContextLost()) |
| 299 channel_->LoseAllContexts(); | 299 channel_->LoseAllContexts(); |
| 300 return false; | 300 return false; |
| 301 } | 301 } |
| 302 | 302 |
| 303 void GpuCommandBufferStub::Destroy() { | 303 void GpuCommandBufferStub::Destroy() { |
| 304 if (handle_.is_null() && !active_url_.is_empty()) { |
| 305 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
| 306 gpu_channel_manager->Send(new GpuHostMsg_DidDestroyOffscreenContext( |
| 307 active_url_)); |
| 308 } |
| 309 |
| 304 GetMemoryManager()->RemoveClient(this); | 310 GetMemoryManager()->RemoveClient(this); |
| 305 | 311 |
| 306 while (!sync_points_.empty()) | 312 while (!sync_points_.empty()) |
| 307 OnRetireSyncPoint(sync_points_.front()); | 313 OnRetireSyncPoint(sync_points_.front()); |
| 308 | 314 |
| 309 // The scheduler has raw references to the decoder and the command buffer so | 315 // The scheduler has raw references to the decoder and the command buffer so |
| 310 // destroy it before those. | 316 // destroy it before those. |
| 311 scheduler_.reset(); | 317 scheduler_.reset(); |
| 312 | 318 |
| 313 while (!delayed_echos_.empty()) { | 319 while (!delayed_echos_.empty()) { |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 506 |
| 501 if (parent_stub_for_initialization_) { | 507 if (parent_stub_for_initialization_) { |
| 502 decoder_->SetParent(parent_stub_for_initialization_->decoder_.get(), | 508 decoder_->SetParent(parent_stub_for_initialization_->decoder_.get(), |
| 503 parent_texture_for_initialization_); | 509 parent_texture_for_initialization_); |
| 504 parent_stub_for_initialization_.reset(); | 510 parent_stub_for_initialization_.reset(); |
| 505 parent_texture_for_initialization_ = 0; | 511 parent_texture_for_initialization_ = 0; |
| 506 } | 512 } |
| 507 | 513 |
| 508 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true); | 514 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true); |
| 509 Send(reply_message); | 515 Send(reply_message); |
| 516 |
| 517 if (handle_.is_null() && !active_url_.is_empty()) { |
| 518 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
| 519 gpu_channel_manager->Send(new GpuHostMsg_DidCreateOffscreenContext( |
| 520 active_url_)); |
| 521 } |
| 510 } | 522 } |
| 511 | 523 |
| 512 void GpuCommandBufferStub::OnSetGetBuffer( | 524 void GpuCommandBufferStub::OnSetGetBuffer( |
| 513 int32 shm_id, IPC::Message* reply_message) { | 525 int32 shm_id, IPC::Message* reply_message) { |
| 514 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSetGetBuffer"); | 526 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSetGetBuffer"); |
| 515 if (command_buffer_.get()) { | 527 if (command_buffer_.get()) { |
| 516 command_buffer_->SetGetBuffer(shm_id); | 528 command_buffer_->SetGetBuffer(shm_id); |
| 517 } else { | 529 } else { |
| 518 DLOG(ERROR) << "no command_buffer."; | 530 DLOG(ERROR) << "no command_buffer."; |
| 519 reply_message->set_reply_error(); | 531 reply_message->set_reply_error(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 } | 588 } |
| 577 | 589 |
| 578 void GpuCommandBufferStub::OnParseError() { | 590 void GpuCommandBufferStub::OnParseError() { |
| 579 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnParseError"); | 591 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnParseError"); |
| 580 DCHECK(command_buffer_.get()); | 592 DCHECK(command_buffer_.get()); |
| 581 gpu::CommandBuffer::State state = command_buffer_->GetState(); | 593 gpu::CommandBuffer::State state = command_buffer_->GetState(); |
| 582 IPC::Message* msg = new GpuCommandBufferMsg_Destroyed( | 594 IPC::Message* msg = new GpuCommandBufferMsg_Destroyed( |
| 583 route_id_, state.context_lost_reason); | 595 route_id_, state.context_lost_reason); |
| 584 msg->set_unblock(true); | 596 msg->set_unblock(true); |
| 585 Send(msg); | 597 Send(msg); |
| 598 |
| 599 // Tell the browser about this context loss as well, so it can |
| 600 // determine whether client APIs like WebGL need to be immediately |
| 601 // blocked from automatically running. |
| 602 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
| 603 gpu_channel_manager->Send(new GpuHostMsg_DidLoseContext( |
| 604 handle_.is_null(), state.context_lost_reason, active_url_)); |
| 586 } | 605 } |
| 587 | 606 |
| 588 void GpuCommandBufferStub::OnGetStateFast(IPC::Message* reply_message) { | 607 void GpuCommandBufferStub::OnGetStateFast(IPC::Message* reply_message) { |
| 589 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnGetStateFast"); | 608 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnGetStateFast"); |
| 590 DCHECK(command_buffer_.get()); | 609 DCHECK(command_buffer_.get()); |
| 591 gpu::CommandBuffer::State state = command_buffer_->GetState(); | 610 gpu::CommandBuffer::State state = command_buffer_->GetState(); |
| 592 if (state.error == gpu::error::kLostContext && | 611 if (state.error == gpu::error::kLostContext && |
| 593 gfx::GLContext::LosesAllContextsOnContextLost()) | 612 gfx::GLContext::LosesAllContextsOnContextLost()) |
| 594 channel_->LoseAllContexts(); | 613 channel_->LoseAllContexts(); |
| 595 | 614 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 // made current before calling methods on the surface. | 913 // made current before calling methods on the surface. |
| 895 if (!surface_ || !MakeCurrent()) | 914 if (!surface_ || !MakeCurrent()) |
| 896 return; | 915 return; |
| 897 surface_->SetFrontbufferAllocation( | 916 surface_->SetFrontbufferAllocation( |
| 898 allocation.browser_allocation.suggest_have_frontbuffer); | 917 allocation.browser_allocation.suggest_have_frontbuffer); |
| 899 } | 918 } |
| 900 | 919 |
| 901 } // namespace content | 920 } // namespace content |
| 902 | 921 |
| 903 #endif // defined(ENABLE_GPU) | 922 #endif // defined(ENABLE_GPU) |
| OLD | NEW |