| 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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
| 12 #include "base/time.h" | 12 #include "base/time.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "content/common/gpu/gpu_channel.h" | 14 #include "content/common/gpu/gpu_channel.h" |
| 15 #include "content/common/gpu/gpu_channel_manager.h" | 15 #include "content/common/gpu/gpu_channel_manager.h" |
| 16 #include "content/common/gpu/gpu_command_buffer_stub.h" | 16 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 17 #include "content/common/gpu/gpu_memory_manager.h" | 17 #include "content/common/gpu/gpu_memory_manager.h" |
| 18 #include "content/common/gpu/gpu_messages.h" | 18 #include "content/common/gpu/gpu_messages.h" |
| 19 #include "content/common/gpu/gpu_watchdog.h" | 19 #include "content/common/gpu/gpu_watchdog.h" |
| 20 #include "content/common/gpu/image_transport_surface.h" | 20 #include "content/common/gpu/image_transport_surface.h" |
| 21 #include "content/common/gpu/sync_point_manager.h" |
| 21 #include "gpu/command_buffer/common/constants.h" | 22 #include "gpu/command_buffer/common/constants.h" |
| 22 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 23 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 23 #include "ui/gl/gl_bindings.h" | 24 #include "ui/gl/gl_bindings.h" |
| 24 #include "ui/gl/gl_switches.h" | 25 #include "ui/gl/gl_switches.h" |
| 25 | 26 |
| 26 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 27 #include "content/public/common/sandbox_init.h" | 28 #include "content/public/common/sandbox_init.h" |
| 28 #endif | 29 #endif |
| 29 | 30 |
| 30 GpuCommandBufferStub::SurfaceState::SurfaceState(int32 surface_id, | 31 GpuCommandBufferStub::SurfaceState::SurfaceState(int32 surface_id, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder, | 125 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder, |
| 125 OnCreateVideoDecoder) | 126 OnCreateVideoDecoder) |
| 126 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyVideoDecoder, | 127 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyVideoDecoder, |
| 127 OnDestroyVideoDecoder) | 128 OnDestroyVideoDecoder) |
| 128 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetSurfaceVisible, | 129 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetSurfaceVisible, |
| 129 OnSetSurfaceVisible) | 130 OnSetSurfaceVisible) |
| 130 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DiscardBackbuffer, | 131 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DiscardBackbuffer, |
| 131 OnDiscardBackbuffer) | 132 OnDiscardBackbuffer) |
| 132 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_EnsureBackbuffer, | 133 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_EnsureBackbuffer, |
| 133 OnEnsureBackbuffer) | 134 OnEnsureBackbuffer) |
| 135 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RetireSyncPoint, |
| 136 OnRetireSyncPoint) |
| 137 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_WaitSyncPoint, |
| 138 OnWaitSyncPoint) |
| 134 IPC_MESSAGE_HANDLER( | 139 IPC_MESSAGE_HANDLER( |
| 135 GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback, | 140 GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback, |
| 136 OnSetClientHasMemoryAllocationChangedCallback) | 141 OnSetClientHasMemoryAllocationChangedCallback) |
| 137 IPC_MESSAGE_UNHANDLED(handled = false) | 142 IPC_MESSAGE_UNHANDLED(handled = false) |
| 138 IPC_END_MESSAGE_MAP() | 143 IPC_END_MESSAGE_MAP() |
| 139 | 144 |
| 140 DCHECK(handled); | 145 DCHECK(handled); |
| 141 return handled; | 146 return handled; |
| 142 } | 147 } |
| 143 | 148 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 scoped_ptr<IPC::Message> message(delayed_echos_.front()); | 198 scoped_ptr<IPC::Message> message(delayed_echos_.front()); |
| 194 delayed_echos_.pop_front(); | 199 delayed_echos_.pop_front(); |
| 195 | 200 |
| 196 OnMessageReceived(*message); | 201 OnMessageReceived(*message); |
| 197 } | 202 } |
| 198 | 203 |
| 199 channel_->OnScheduled(); | 204 channel_->OnScheduled(); |
| 200 } | 205 } |
| 201 | 206 |
| 202 void GpuCommandBufferStub::Destroy() { | 207 void GpuCommandBufferStub::Destroy() { |
| 208 while (!sync_points_.empty()) |
| 209 OnRetireSyncPoint(sync_points_.front()); |
| 210 |
| 203 // The scheduler has raw references to the decoder and the command buffer so | 211 // The scheduler has raw references to the decoder and the command buffer so |
| 204 // destroy it before those. | 212 // destroy it before those. |
| 205 scheduler_.reset(); | 213 scheduler_.reset(); |
| 206 | 214 |
| 207 while (!delayed_echos_.empty()) { | 215 while (!delayed_echos_.empty()) { |
| 208 delete delayed_echos_.front(); | 216 delete delayed_echos_.front(); |
| 209 delayed_echos_.pop_front(); | 217 delayed_echos_.pop_front(); |
| 210 } | 218 } |
| 211 | 219 |
| 212 if (decoder_.get()) | 220 if (decoder_.get()) |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 surface_->SetBackbufferAllocation(false); | 609 surface_->SetBackbufferAllocation(false); |
| 602 } | 610 } |
| 603 | 611 |
| 604 void GpuCommandBufferStub::OnEnsureBackbuffer() { | 612 void GpuCommandBufferStub::OnEnsureBackbuffer() { |
| 605 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnEnsureBackbuffer"); | 613 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnEnsureBackbuffer"); |
| 606 if (!surface_) | 614 if (!surface_) |
| 607 return; | 615 return; |
| 608 surface_->SetBackbufferAllocation(true); | 616 surface_->SetBackbufferAllocation(true); |
| 609 } | 617 } |
| 610 | 618 |
| 619 void GpuCommandBufferStub::AddSyncPoint(uint32 sync_point) { |
| 620 sync_points_.push_back(sync_point); |
| 621 } |
| 622 |
| 623 void GpuCommandBufferStub::OnRetireSyncPoint(uint32 sync_point) { |
| 624 DCHECK(!sync_points_.empty() && sync_points_.front() == sync_point); |
| 625 sync_points_.pop_front(); |
| 626 GpuChannelManager* manager = channel_->gpu_channel_manager(); |
| 627 manager->sync_point_manager()->RetireSyncPoint(sync_point); |
| 628 } |
| 629 |
| 630 void GpuCommandBufferStub::OnWaitSyncPoint(uint32 sync_point) { |
| 631 if (!scheduler_.get()) |
| 632 return; |
| 633 scheduler_->SetScheduled(false); |
| 634 GpuChannelManager* manager = channel_->gpu_channel_manager(); |
| 635 manager->sync_point_manager()->AddSyncPointCallback( |
| 636 sync_point, |
| 637 base::Bind(&GpuCommandBufferStub::OnSyncPointRetired, |
| 638 this->AsWeakPtr())); |
| 639 } |
| 640 |
| 641 void GpuCommandBufferStub::OnSyncPointRetired() { |
| 642 if (!scheduler_.get()) |
| 643 return; |
| 644 scheduler_->SetScheduled(true); |
| 645 } |
| 646 |
| 611 void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( | 647 void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( |
| 612 bool has_callback) { | 648 bool has_callback) { |
| 613 TRACE_EVENT0( | 649 TRACE_EVENT0( |
| 614 "gpu", | 650 "gpu", |
| 615 "GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback"); | 651 "GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback"); |
| 616 client_has_memory_allocation_changed_callback_ = has_callback; | 652 client_has_memory_allocation_changed_callback_ = has_callback; |
| 617 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage(); | 653 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage(); |
| 618 } | 654 } |
| 619 | 655 |
| 620 void GpuCommandBufferStub::SendConsoleMessage( | 656 void GpuCommandBufferStub::SendConsoleMessage( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 | 704 |
| 669 void GpuCommandBufferStub::SetMemoryAllocation( | 705 void GpuCommandBufferStub::SetMemoryAllocation( |
| 670 const GpuMemoryAllocation& allocation) { | 706 const GpuMemoryAllocation& allocation) { |
| 671 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation)); | 707 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation)); |
| 672 if (!surface_) | 708 if (!surface_) |
| 673 return; | 709 return; |
| 674 surface_->SetFrontbufferAllocation(allocation.suggest_have_frontbuffer); | 710 surface_->SetFrontbufferAllocation(allocation.suggest_have_frontbuffer); |
| 675 } | 711 } |
| 676 | 712 |
| 677 #endif // defined(ENABLE_GPU) | 713 #endif // defined(ENABLE_GPU) |
| OLD | NEW |