Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.cc

Issue 253943002: Remove CommandBuffer::GetState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: I forgot Poland^Wmojo Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // here. This is so the reply can be delayed if the scheduler is unscheduled. 203 // here. This is so the reply can be delayed if the scheduler is unscheduled.
204 bool handled = true; 204 bool handled = true;
205 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) 205 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message)
206 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, 206 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize,
207 OnInitialize); 207 OnInitialize);
208 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer, 208 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer,
209 OnSetGetBuffer); 209 OnSetGetBuffer);
210 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ProduceFrontBuffer, 210 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ProduceFrontBuffer,
211 OnProduceFrontBuffer); 211 OnProduceFrontBuffer);
212 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Echo, OnEcho); 212 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Echo, OnEcho);
213 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState);
214 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForTokenInRange, 213 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForTokenInRange,
215 OnWaitForTokenInRange); 214 OnWaitForTokenInRange);
216 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForGetOffsetInRange, 215 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForGetOffsetInRange,
217 OnWaitForGetOffsetInRange); 216 OnWaitForGetOffsetInRange);
218 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); 217 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush);
219 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetLatencyInfo, OnSetLatencyInfo); 218 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetLatencyInfo, OnSetLatencyInfo);
220 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); 219 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled);
221 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterTransferBuffer, 220 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterTransferBuffer,
222 OnRegisterTransferBuffer); 221 OnRegisterTransferBuffer);
223 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer, 222 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer,
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 386
388 if (decoder_) 387 if (decoder_)
389 decoder_->set_engine(NULL); 388 decoder_->set_engine(NULL);
390 389
391 // The scheduler has raw references to the decoder and the command buffer so 390 // The scheduler has raw references to the decoder and the command buffer so
392 // destroy it before those. 391 // destroy it before those.
393 scheduler_.reset(); 392 scheduler_.reset();
394 393
395 bool have_context = false; 394 bool have_context = false;
396 if (decoder_ && command_buffer_ && 395 if (decoder_ && command_buffer_ &&
397 command_buffer_->GetState().error != gpu::error::kLostContext) 396 command_buffer_->GetLastState().error != gpu::error::kLostContext)
398 have_context = decoder_->MakeCurrent(); 397 have_context = decoder_->MakeCurrent();
399 FOR_EACH_OBSERVER(DestructionObserver, 398 FOR_EACH_OBSERVER(DestructionObserver,
400 destruction_observers_, 399 destruction_observers_,
401 OnWillDestroyStub()); 400 OnWillDestroyStub());
402 401
403 if (decoder_) { 402 if (decoder_) {
404 decoder_->Destroy(have_context); 403 decoder_->Destroy(have_context);
405 decoder_.reset(); 404 decoder_.reset();
406 } 405 }
407 406
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 void GpuCommandBufferStub::OnProduceFrontBuffer(const gpu::Mailbox& mailbox) { 643 void GpuCommandBufferStub::OnProduceFrontBuffer(const gpu::Mailbox& mailbox) {
645 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnProduceFrontBuffer"); 644 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnProduceFrontBuffer");
646 if (!decoder_) { 645 if (!decoder_) {
647 LOG(ERROR) << "Can't produce front buffer before initialization."; 646 LOG(ERROR) << "Can't produce front buffer before initialization.";
648 return; 647 return;
649 } 648 }
650 649
651 decoder_->ProduceFrontBuffer(mailbox); 650 decoder_->ProduceFrontBuffer(mailbox);
652 } 651 }
653 652
654 void GpuCommandBufferStub::OnGetState(IPC::Message* reply_message) {
655 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnGetState");
656 if (command_buffer_) {
657 gpu::CommandBuffer::State state = command_buffer_->GetState();
658 CheckContextLost();
659 GpuCommandBufferMsg_GetState::WriteReplyParams(reply_message, state);
660 } else {
661 DLOG(ERROR) << "no command_buffer.";
662 reply_message->set_reply_error();
663 }
664 Send(reply_message);
665 }
666
667 void GpuCommandBufferStub::OnParseError() { 653 void GpuCommandBufferStub::OnParseError() {
668 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnParseError"); 654 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnParseError");
669 DCHECK(command_buffer_.get()); 655 DCHECK(command_buffer_.get());
670 gpu::CommandBuffer::State state = command_buffer_->GetState(); 656 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
671 IPC::Message* msg = new GpuCommandBufferMsg_Destroyed( 657 IPC::Message* msg = new GpuCommandBufferMsg_Destroyed(
672 route_id_, state.context_lost_reason); 658 route_id_, state.context_lost_reason);
673 msg->set_unblock(true); 659 msg->set_unblock(true);
674 Send(msg); 660 Send(msg);
675 661
676 // Tell the browser about this context loss as well, so it can 662 // Tell the browser about this context loss as well, so it can
677 // determine whether client APIs like WebGL need to be immediately 663 // determine whether client APIs like WebGL need to be immediately
678 // blocked from automatically running. 664 // blocked from automatically running.
679 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); 665 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
680 gpu_channel_manager->Send(new GpuHostMsg_DidLoseContext( 666 gpu_channel_manager->Send(new GpuHostMsg_DidLoseContext(
(...skipping 26 matching lines...) Expand all
707 LOG(ERROR) 693 LOG(ERROR)
708 << "Got WaitForGetOffset command while currently waiting for offset."; 694 << "Got WaitForGetOffset command while currently waiting for offset.";
709 } 695 }
710 wait_for_get_offset_ = 696 wait_for_get_offset_ =
711 make_scoped_ptr(new WaitForCommandState(start, end, reply_message)); 697 make_scoped_ptr(new WaitForCommandState(start, end, reply_message));
712 CheckCompleteWaits(); 698 CheckCompleteWaits();
713 } 699 }
714 700
715 void GpuCommandBufferStub::CheckCompleteWaits() { 701 void GpuCommandBufferStub::CheckCompleteWaits() {
716 if (wait_for_token_ || wait_for_get_offset_) { 702 if (wait_for_token_ || wait_for_get_offset_) {
717 gpu::CommandBuffer::State state = command_buffer_->GetState(); 703 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
718 if (wait_for_token_ && 704 if (wait_for_token_ &&
719 (gpu::CommandBuffer::InRange( 705 (gpu::CommandBuffer::InRange(
720 wait_for_token_->start, wait_for_token_->end, state.token) || 706 wait_for_token_->start, wait_for_token_->end, state.token) ||
721 state.error != gpu::error::kNoError)) { 707 state.error != gpu::error::kNoError)) {
722 ReportState(); 708 ReportState();
723 GpuCommandBufferMsg_WaitForTokenInRange::WriteReplyParams( 709 GpuCommandBufferMsg_WaitForTokenInRange::WriteReplyParams(
724 wait_for_token_->reply.get(), state); 710 wait_for_token_->reply.get(), state);
725 Send(wait_for_token_->reply.release()); 711 Send(wait_for_token_->reply.release());
726 wait_for_token_.reset(); 712 wait_for_token_.reset();
727 } 713 }
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 void GpuCommandBufferStub::SuggestHaveFrontBuffer( 1021 void GpuCommandBufferStub::SuggestHaveFrontBuffer(
1036 bool suggest_have_frontbuffer) { 1022 bool suggest_have_frontbuffer) {
1037 // This can be called outside of OnMessageReceived, so the context needs 1023 // This can be called outside of OnMessageReceived, so the context needs
1038 // to be made current before calling methods on the surface. 1024 // to be made current before calling methods on the surface.
1039 if (surface_.get() && MakeCurrent()) 1025 if (surface_.get() && MakeCurrent())
1040 surface_->SetFrontbufferAllocation(suggest_have_frontbuffer); 1026 surface_->SetFrontbufferAllocation(suggest_have_frontbuffer);
1041 } 1027 }
1042 1028
1043 bool GpuCommandBufferStub::CheckContextLost() { 1029 bool GpuCommandBufferStub::CheckContextLost() {
1044 DCHECK(command_buffer_); 1030 DCHECK(command_buffer_);
1045 gpu::CommandBuffer::State state = command_buffer_->GetState(); 1031 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
1046 bool was_lost = state.error == gpu::error::kLostContext; 1032 bool was_lost = state.error == gpu::error::kLostContext;
1047 // Lose all other contexts if the reset was triggered by the robustness 1033 // Lose all other contexts if the reset was triggered by the robustness
1048 // extension instead of being synthetic. 1034 // extension instead of being synthetic.
1049 if (was_lost && decoder_ && decoder_->WasContextLostByRobustnessExtension() && 1035 if (was_lost && decoder_ && decoder_->WasContextLostByRobustnessExtension() &&
1050 (gfx::GLContext::LosesAllContextsOnContextLost() || 1036 (gfx::GLContext::LosesAllContextsOnContextLost() ||
1051 use_virtualized_gl_context_)) 1037 use_virtualized_gl_context_))
1052 channel_->LoseAllContexts(); 1038 channel_->LoseAllContexts();
1053 CheckCompleteWaits(); 1039 CheckCompleteWaits();
1054 return was_lost; 1040 return was_lost;
1055 } 1041 }
1056 1042
1057 void GpuCommandBufferStub::MarkContextLost() { 1043 void GpuCommandBufferStub::MarkContextLost() {
1058 if (!command_buffer_ || 1044 if (!command_buffer_ ||
1059 command_buffer_->GetState().error == gpu::error::kLostContext) 1045 command_buffer_->GetLastState().error == gpu::error::kLostContext)
1060 return; 1046 return;
1061 1047
1062 command_buffer_->SetContextLostReason(gpu::error::kUnknown); 1048 command_buffer_->SetContextLostReason(gpu::error::kUnknown);
1063 if (decoder_) 1049 if (decoder_)
1064 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); 1050 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB);
1065 command_buffer_->SetParseError(gpu::error::kLostContext); 1051 command_buffer_->SetParseError(gpu::error::kLostContext);
1066 } 1052 }
1067 1053
1068 uint64 GpuCommandBufferStub::GetMemoryUsage() const { 1054 uint64 GpuCommandBufferStub::GetMemoryUsage() const {
1069 return GetMemoryManager()->GetClientMemoryUsage(this); 1055 return GetMemoryManager()->GetClientMemoryUsage(this);
1070 } 1056 }
1071 1057
1072 } // namespace content 1058 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/command_buffer_proxy_impl.cc ('k') | content/common/gpu/gpu_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698