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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 Send(wait_for_token_->reply.release()); | 465 Send(wait_for_token_->reply.release()); |
465 wait_for_token_.reset(); | 466 wait_for_token_.reset(); |
466 } | 467 } |
467 if (wait_for_get_offset_) { | 468 if (wait_for_get_offset_) { |
468 Send(wait_for_get_offset_->reply.release()); | 469 Send(wait_for_get_offset_->reply.release()); |
469 wait_for_get_offset_.reset(); | 470 wait_for_get_offset_.reset(); |
470 } | 471 } |
471 | 472 |
472 if (initialized_) { | 473 if (initialized_) { |
473 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 474 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
474 if (handle_.is_null() && !active_url_.is_empty()) { | 475 if (handle_.is_null() && !active_url_.is_empty()) |
475 gpu_channel_manager->Send( | 476 gpu_channel_manager->delegate()->DidDestroyOffscreenContext(active_url_); |
476 new GpuHostMsg_DidDestroyOffscreenContext(active_url_)); | |
477 } | |
478 } | 477 } |
479 | 478 |
480 if (decoder_) | 479 if (decoder_) |
481 decoder_->set_engine(NULL); | 480 decoder_->set_engine(NULL); |
482 | 481 |
483 // The scheduler has raw references to the decoder and the command buffer so | 482 // The scheduler has raw references to the decoder and the command buffer so |
484 // destroy it before those. | 483 // destroy it before those. |
485 scheduler_.reset(); | 484 scheduler_.reset(); |
486 | 485 |
487 sync_point_client_.reset(); | 486 sync_point_client_.reset(); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 } | 666 } |
668 command_buffer_->SetSharedStateBuffer(gpu::MakeBackingFromSharedMemory( | 667 command_buffer_->SetSharedStateBuffer(gpu::MakeBackingFromSharedMemory( |
669 std::move(shared_state_shm), kSharedStateSize)); | 668 std::move(shared_state_shm), kSharedStateSize)); |
670 | 669 |
671 gpu::Capabilities capabilities = decoder_->GetCapabilities(); | 670 gpu::Capabilities capabilities = decoder_->GetCapabilities(); |
672 | 671 |
673 GpuCommandBufferMsg_Initialize::WriteReplyParams( | 672 GpuCommandBufferMsg_Initialize::WriteReplyParams( |
674 reply_message, true, capabilities); | 673 reply_message, true, capabilities); |
675 Send(reply_message); | 674 Send(reply_message); |
676 | 675 |
677 if (handle_.is_null() && !active_url_.is_empty()) { | 676 if (handle_.is_null() && !active_url_.is_empty()) |
678 manager->Send(new GpuHostMsg_DidCreateOffscreenContext( | 677 manager->delegate()->DidCreateOffscreenContext(active_url_); |
679 active_url_)); | |
680 } | |
681 | 678 |
682 initialized_ = true; | 679 initialized_ = true; |
683 } | 680 } |
684 | 681 |
685 void GpuCommandBufferStub::OnCreateStreamTexture(uint32_t texture_id, | 682 void GpuCommandBufferStub::OnCreateStreamTexture(uint32_t texture_id, |
686 int32_t stream_id, | 683 int32_t stream_id, |
687 bool* succeeded) { | 684 bool* succeeded) { |
688 #if defined(OS_ANDROID) | 685 #if defined(OS_ANDROID) |
689 *succeeded = StreamTexture::Create(this, texture_id, stream_id); | 686 *succeeded = StreamTexture::Create(this, texture_id, stream_id); |
690 #else | 687 #else |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 730 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
734 IPC::Message* msg = new GpuCommandBufferMsg_Destroyed( | 731 IPC::Message* msg = new GpuCommandBufferMsg_Destroyed( |
735 route_id_, state.context_lost_reason, state.error); | 732 route_id_, state.context_lost_reason, state.error); |
736 msg->set_unblock(true); | 733 msg->set_unblock(true); |
737 Send(msg); | 734 Send(msg); |
738 | 735 |
739 // Tell the browser about this context loss as well, so it can | 736 // Tell the browser about this context loss as well, so it can |
740 // determine whether client APIs like WebGL need to be immediately | 737 // determine whether client APIs like WebGL need to be immediately |
741 // blocked from automatically running. | 738 // blocked from automatically running. |
742 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 739 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
743 gpu_channel_manager->Send(new GpuHostMsg_DidLoseContext( | 740 gpu_channel_manager->delegate()->DidLoseContext( |
744 handle_.is_null(), state.context_lost_reason, active_url_)); | 741 handle_.is_null(), state.context_lost_reason, active_url_); |
745 | 742 |
746 CheckContextLost(); | 743 CheckContextLost(); |
747 } | 744 } |
748 | 745 |
749 void GpuCommandBufferStub::OnSchedulingChanged(bool scheduled) { | 746 void GpuCommandBufferStub::OnSchedulingChanged(bool scheduled) { |
750 TRACE_EVENT1("gpu", "GpuCommandBufferStub::OnSchedulingChanged", "scheduled", | 747 TRACE_EVENT1("gpu", "GpuCommandBufferStub::OnSchedulingChanged", "scheduled", |
751 scheduled); | 748 scheduled); |
752 channel_->OnStubSchedulingChanged(this, scheduled); | 749 channel_->OnStubSchedulingChanged(this, scheduled); |
753 } | 750 } |
754 | 751 |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 result)); | 1176 result)); |
1180 } | 1177 } |
1181 | 1178 |
1182 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1179 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
1183 base::TimeDelta interval) { | 1180 base::TimeDelta interval) { |
1184 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1181 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
1185 interval)); | 1182 interval)); |
1186 } | 1183 } |
1187 | 1184 |
1188 } // namespace content | 1185 } // namespace content |
OLD | NEW |