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 "content/common/gpu/gpu_command_buffer_stub.h" | 5 #include "content/common/gpu/gpu_command_buffer_stub.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/hash.h" | 12 #include "base/hash.h" |
13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "content/common/gpu/gpu_channel.h" | 19 #include "content/common/gpu/gpu_channel.h" |
20 #include "content/common/gpu/gpu_channel_manager.h" | 20 #include "content/common/gpu/gpu_channel_manager.h" |
| 21 #include "content/common/gpu/gpu_channel_manager_delegate.h" |
21 #include "content/common/gpu/gpu_memory_manager.h" | 22 #include "content/common/gpu/gpu_memory_manager.h" |
22 #include "content/common/gpu/gpu_memory_tracking.h" | 23 #include "content/common/gpu/gpu_memory_tracking.h" |
23 #include "content/common/gpu/gpu_messages.h" | 24 #include "content/common/gpu/gpu_messages.h" |
24 #include "content/common/gpu/gpu_watchdog.h" | 25 #include "content/common/gpu/gpu_watchdog.h" |
25 #include "content/common/gpu/image_transport_surface.h" | 26 #include "content/common/gpu/image_transport_surface.h" |
26 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | 27 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
27 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" | 28 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" |
28 #include "content/public/common/content_client.h" | 29 #include "content/public/common/content_client.h" |
29 #include "content/public/common/content_switches.h" | 30 #include "content/public/common/content_switches.h" |
30 #include "gpu/command_buffer/common/constants.h" | 31 #include "gpu/command_buffer/common/constants.h" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 Send(wait_for_token_->reply.release()); | 461 Send(wait_for_token_->reply.release()); |
461 wait_for_token_.reset(); | 462 wait_for_token_.reset(); |
462 } | 463 } |
463 if (wait_for_get_offset_) { | 464 if (wait_for_get_offset_) { |
464 Send(wait_for_get_offset_->reply.release()); | 465 Send(wait_for_get_offset_->reply.release()); |
465 wait_for_get_offset_.reset(); | 466 wait_for_get_offset_.reset(); |
466 } | 467 } |
467 | 468 |
468 if (initialized_) { | 469 if (initialized_) { |
469 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 470 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
470 if (handle_.is_null() && !active_url_.is_empty()) { | 471 if (handle_.is_null() && !active_url_.is_empty()) |
471 gpu_channel_manager->Send( | 472 gpu_channel_manager->delegate()->DidDestroyOffscreenContext(active_url_); |
472 new GpuHostMsg_DidDestroyOffscreenContext(active_url_)); | |
473 } | |
474 } | 473 } |
475 | 474 |
476 if (decoder_) | 475 if (decoder_) |
477 decoder_->set_engine(NULL); | 476 decoder_->set_engine(NULL); |
478 | 477 |
479 // The scheduler has raw references to the decoder and the command buffer so | 478 // The scheduler has raw references to the decoder and the command buffer so |
480 // destroy it before those. | 479 // destroy it before those. |
481 scheduler_.reset(); | 480 scheduler_.reset(); |
482 | 481 |
483 sync_point_client_.reset(); | 482 sync_point_client_.reset(); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 } | 661 } |
663 command_buffer_->SetSharedStateBuffer(gpu::MakeBackingFromSharedMemory( | 662 command_buffer_->SetSharedStateBuffer(gpu::MakeBackingFromSharedMemory( |
664 std::move(shared_state_shm), kSharedStateSize)); | 663 std::move(shared_state_shm), kSharedStateSize)); |
665 | 664 |
666 gpu::Capabilities capabilities = decoder_->GetCapabilities(); | 665 gpu::Capabilities capabilities = decoder_->GetCapabilities(); |
667 | 666 |
668 GpuCommandBufferMsg_Initialize::WriteReplyParams( | 667 GpuCommandBufferMsg_Initialize::WriteReplyParams( |
669 reply_message, true, capabilities); | 668 reply_message, true, capabilities); |
670 Send(reply_message); | 669 Send(reply_message); |
671 | 670 |
672 if (handle_.is_null() && !active_url_.is_empty()) { | 671 if (handle_.is_null() && !active_url_.is_empty()) |
673 manager->Send(new GpuHostMsg_DidCreateOffscreenContext( | 672 manager->delegate()->DidCreateOffscreenContext(active_url_); |
674 active_url_)); | |
675 } | |
676 | 673 |
677 initialized_ = true; | 674 initialized_ = true; |
678 } | 675 } |
679 | 676 |
680 void GpuCommandBufferStub::OnCreateStreamTexture(uint32_t texture_id, | 677 void GpuCommandBufferStub::OnCreateStreamTexture(uint32_t texture_id, |
681 int32_t stream_id, | 678 int32_t stream_id, |
682 bool* succeeded) { | 679 bool* succeeded) { |
683 #if defined(OS_ANDROID) | 680 #if defined(OS_ANDROID) |
684 *succeeded = StreamTexture::Create(this, texture_id, stream_id); | 681 *succeeded = StreamTexture::Create(this, texture_id, stream_id); |
685 #else | 682 #else |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 725 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
729 IPC::Message* msg = new GpuCommandBufferMsg_Destroyed( | 726 IPC::Message* msg = new GpuCommandBufferMsg_Destroyed( |
730 route_id_, state.context_lost_reason, state.error); | 727 route_id_, state.context_lost_reason, state.error); |
731 msg->set_unblock(true); | 728 msg->set_unblock(true); |
732 Send(msg); | 729 Send(msg); |
733 | 730 |
734 // Tell the browser about this context loss as well, so it can | 731 // Tell the browser about this context loss as well, so it can |
735 // determine whether client APIs like WebGL need to be immediately | 732 // determine whether client APIs like WebGL need to be immediately |
736 // blocked from automatically running. | 733 // blocked from automatically running. |
737 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 734 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
738 gpu_channel_manager->Send(new GpuHostMsg_DidLoseContext( | 735 gpu_channel_manager->delegate()->DidLoseContext( |
739 handle_.is_null(), state.context_lost_reason, active_url_)); | 736 handle_.is_null(), state.context_lost_reason, active_url_); |
740 | 737 |
741 CheckContextLost(); | 738 CheckContextLost(); |
742 } | 739 } |
743 | 740 |
744 void GpuCommandBufferStub::OnSchedulingChanged(bool scheduled) { | 741 void GpuCommandBufferStub::OnSchedulingChanged(bool scheduled) { |
745 TRACE_EVENT1("gpu", "GpuCommandBufferStub::OnSchedulingChanged", "scheduled", | 742 TRACE_EVENT1("gpu", "GpuCommandBufferStub::OnSchedulingChanged", "scheduled", |
746 scheduled); | 743 scheduled); |
747 channel_->OnStreamRescheduled(stream_id_, scheduled); | 744 channel_->OnStreamRescheduled(stream_id_, scheduled); |
748 } | 745 } |
749 | 746 |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 result)); | 1171 result)); |
1175 } | 1172 } |
1176 | 1173 |
1177 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1174 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
1178 base::TimeDelta interval) { | 1175 base::TimeDelta interval) { |
1179 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1176 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
1180 interval)); | 1177 interval)); |
1181 } | 1178 } |
1182 | 1179 |
1183 } // namespace content | 1180 } // namespace content |
OLD | NEW |