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/hash.h" | 8 #include "base/hash.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 OnRetireSyncPoint(sync_points_.front()); | 414 OnRetireSyncPoint(sync_points_.front()); |
415 | 415 |
416 if (decoder_) | 416 if (decoder_) |
417 decoder_->set_engine(NULL); | 417 decoder_->set_engine(NULL); |
418 | 418 |
419 // The scheduler has raw references to the decoder and the command buffer so | 419 // The scheduler has raw references to the decoder and the command buffer so |
420 // destroy it before those. | 420 // destroy it before those. |
421 scheduler_.reset(); | 421 scheduler_.reset(); |
422 | 422 |
423 bool have_context = false; | 423 bool have_context = false; |
424 if (decoder_ && command_buffer_ && | 424 if (decoder_) { |
425 command_buffer_->GetLastState().error != gpu::error::kLostContext) | 425 // Try to make the context current regardless of whether it was lost, so we |
426 have_context = decoder_->MakeCurrent(); | 426 // don't leak resources. |
Ken Russell (switch to Gerrit)
2015/04/27 22:35:33
Presumably if the driver has actually lost the con
no sievers
2015/04/27 23:24:41
But it's a problem if we forced the context to be
| |
427 have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get()); | |
428 } | |
427 FOR_EACH_OBSERVER(DestructionObserver, | 429 FOR_EACH_OBSERVER(DestructionObserver, |
428 destruction_observers_, | 430 destruction_observers_, |
429 OnWillDestroyStub()); | 431 OnWillDestroyStub()); |
430 | 432 |
431 if (decoder_) { | 433 if (decoder_) { |
432 decoder_->Destroy(have_context); | 434 decoder_->Destroy(have_context); |
433 decoder_.reset(); | 435 decoder_.reset(); |
434 } | 436 } |
435 | 437 |
436 command_buffer_.reset(); | 438 command_buffer_.reset(); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
664 } | 666 } |
665 | 667 |
666 decoder_->ProduceFrontBuffer(mailbox); | 668 decoder_->ProduceFrontBuffer(mailbox); |
667 } | 669 } |
668 | 670 |
669 void GpuCommandBufferStub::OnParseError() { | 671 void GpuCommandBufferStub::OnParseError() { |
670 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnParseError"); | 672 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnParseError"); |
671 DCHECK(command_buffer_.get()); | 673 DCHECK(command_buffer_.get()); |
672 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 674 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
673 IPC::Message* msg = new GpuCommandBufferMsg_Destroyed( | 675 IPC::Message* msg = new GpuCommandBufferMsg_Destroyed( |
674 route_id_, state.context_lost_reason); | 676 route_id_, state.context_lost_reason, state.error); |
675 msg->set_unblock(true); | 677 msg->set_unblock(true); |
676 Send(msg); | 678 Send(msg); |
677 | 679 |
678 // Tell the browser about this context loss as well, so it can | 680 // Tell the browser about this context loss as well, so it can |
679 // determine whether client APIs like WebGL need to be immediately | 681 // determine whether client APIs like WebGL need to be immediately |
680 // blocked from automatically running. | 682 // blocked from automatically running. |
681 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 683 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
682 gpu_channel_manager->Send(new GpuHostMsg_DidLoseContext( | 684 gpu_channel_manager->Send(new GpuHostMsg_DidLoseContext( |
683 handle_.is_null(), state.context_lost_reason, active_url_)); | 685 handle_.is_null(), state.context_lost_reason, active_url_)); |
684 | 686 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1082 return was_lost; | 1084 return was_lost; |
1083 } | 1085 } |
1084 | 1086 |
1085 void GpuCommandBufferStub::MarkContextLost() { | 1087 void GpuCommandBufferStub::MarkContextLost() { |
1086 if (!command_buffer_ || | 1088 if (!command_buffer_ || |
1087 command_buffer_->GetLastState().error == gpu::error::kLostContext) | 1089 command_buffer_->GetLastState().error == gpu::error::kLostContext) |
1088 return; | 1090 return; |
1089 | 1091 |
1090 command_buffer_->SetContextLostReason(gpu::error::kUnknown); | 1092 command_buffer_->SetContextLostReason(gpu::error::kUnknown); |
1091 if (decoder_) | 1093 if (decoder_) |
1092 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 1094 decoder_->MarkContextLost(gpu::error::kUnknown); |
1093 command_buffer_->SetParseError(gpu::error::kLostContext); | 1095 command_buffer_->SetParseError(gpu::error::kLostContext); |
1094 } | 1096 } |
1095 | 1097 |
1096 uint64 GpuCommandBufferStub::GetMemoryUsage() const { | 1098 uint64 GpuCommandBufferStub::GetMemoryUsage() const { |
1097 return GetMemoryManager()->GetClientMemoryUsage(this); | 1099 return GetMemoryManager()->GetClientMemoryUsage(this); |
1098 } | 1100 } |
1099 | 1101 |
1100 void GpuCommandBufferStub::SendSwapBuffersCompleted( | 1102 void GpuCommandBufferStub::SendSwapBuffersCompleted( |
1101 const std::vector<ui::LatencyInfo>& latency_info) { | 1103 const std::vector<ui::LatencyInfo>& latency_info) { |
1102 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info)); | 1104 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info)); |
1103 } | 1105 } |
1104 | 1106 |
1105 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1107 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
1106 base::TimeDelta interval) { | 1108 base::TimeDelta interval) { |
1107 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1109 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
1108 interval)); | 1110 interval)); |
1109 } | 1111 } |
1110 | 1112 |
1111 } // namespace content | 1113 } // namespace content |
OLD | NEW |