OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/renderer/gpu/command_buffer_proxy.h" | 5 #include "content/renderer/gpu/command_buffer_proxy.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 new GpuVideoDecodeAcceleratorHost(channel_, decoder_route_id, client); | 385 new GpuVideoDecodeAcceleratorHost(channel_, decoder_route_id, client); |
386 bool inserted = video_decoder_hosts_.insert(std::make_pair( | 386 bool inserted = video_decoder_hosts_.insert(std::make_pair( |
387 decoder_route_id, decoder_host)).second; | 387 decoder_route_id, decoder_host)).second; |
388 DCHECK(inserted); | 388 DCHECK(inserted); |
389 | 389 |
390 channel_->AddRoute(decoder_route_id, decoder_host->AsWeakPtr()); | 390 channel_->AddRoute(decoder_route_id, decoder_host->AsWeakPtr()); |
391 | 391 |
392 return decoder_host; | 392 return decoder_host; |
393 } | 393 } |
394 | 394 |
| 395 gpu::error::Error CommandBufferProxy::GetLastError() { |
| 396 return last_state_.error; |
| 397 } |
| 398 |
395 bool CommandBufferProxy::Send(IPC::Message* msg) { | 399 bool CommandBufferProxy::Send(IPC::Message* msg) { |
396 // Caller should not intentionally send a message if the context is lost. | 400 // Caller should not intentionally send a message if the context is lost. |
397 DCHECK(last_state_.error == gpu::error::kNoError); | 401 DCHECK(last_state_.error == gpu::error::kNoError); |
398 | 402 |
399 if (channel_) { | 403 if (channel_) { |
400 if (channel_->Send(msg)) { | 404 if (channel_->Send(msg)) { |
401 return true; | 405 return true; |
402 } else { | 406 } else { |
403 // Flag the command buffer as lost. Defer deleting the channel until | 407 // Flag the command buffer as lost. Defer deleting the channel until |
404 // OnChannelError is called after returning to the message loop in case | 408 // OnChannelError is called after returning to the message loop in case |
405 // it is referenced elsewhere. | 409 // it is referenced elsewhere. |
406 last_state_.error = gpu::error::kLostContext; | 410 last_state_.error = gpu::error::kLostContext; |
407 return false; | 411 return false; |
408 } | 412 } |
409 } | 413 } |
410 | 414 |
411 // Callee takes ownership of message, regardless of whether Send is | 415 // Callee takes ownership of message, regardless of whether Send is |
412 // successful. See IPC::Message::Sender. | 416 // successful. See IPC::Message::Sender. |
413 delete msg; | 417 delete msg; |
414 return false; | 418 return false; |
415 } | 419 } |
416 | 420 |
417 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) { | 421 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) { |
418 // Handle wraparound. It works as long as we don't have more than 2B state | 422 // Handle wraparound. It works as long as we don't have more than 2B state |
419 // updates in flight across which reordering occurs. | 423 // updates in flight across which reordering occurs. |
420 if (state.generation - last_state_.generation < 0x80000000U) | 424 if (state.generation - last_state_.generation < 0x80000000U) |
421 last_state_ = state; | 425 last_state_ = state; |
422 } | 426 } |
OLD | NEW |