| 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 "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/shared_memory.h" | 10 #include "base/shared_memory.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "content/common/gpu/gpu_channel.h" | 13 #include "content/common/gpu/gpu_channel.h" |
| 14 #include "content/common/gpu/gpu_channel_manager.h" | 14 #include "content/common/gpu/gpu_channel_manager.h" |
| 15 #include "content/common/gpu/gpu_command_buffer_stub.h" | 15 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 16 #include "content/common/gpu/gpu_memory_manager.h" | 16 #include "content/common/gpu/gpu_memory_manager.h" |
| 17 #include "content/common/gpu/gpu_memory_tracking.h" | 17 #include "content/common/gpu/gpu_memory_tracking.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/media/gpu_video_decode_accelerator.h" | 21 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 22 #include "content/common/gpu/sync_point_manager.h" | 22 #include "content/common/gpu/sync_point_manager.h" |
| 23 #include "content/public/common/content_client.h" | 23 #include "content/public/common/content_client.h" |
| 24 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
| 25 #include "gpu/command_buffer/common/constants.h" | 25 #include "gpu/command_buffer/common/constants.h" |
| 26 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 26 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 27 #include "gpu/command_buffer/common/mailbox.h" |
| 27 #include "gpu/command_buffer/service/gl_context_virtual.h" | 28 #include "gpu/command_buffer/service/gl_context_virtual.h" |
| 28 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" | 29 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" |
| 29 #include "gpu/command_buffer/service/logger.h" | 30 #include "gpu/command_buffer/service/logger.h" |
| 30 #include "gpu/command_buffer/service/memory_tracking.h" | 31 #include "gpu/command_buffer/service/memory_tracking.h" |
| 31 #include "ui/gl/gl_bindings.h" | 32 #include "ui/gl/gl_bindings.h" |
| 32 #include "ui/gl/gl_switches.h" | 33 #include "ui/gl/gl_switches.h" |
| 33 | 34 |
| 34 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
| 35 #include "content/public/common/sandbox_init.h" | 36 #include "content/public/common/sandbox_init.h" |
| 36 #endif | 37 #endif |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 175 } |
| 175 | 176 |
| 176 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers | 177 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers |
| 177 // here. This is so the reply can be delayed if the scheduler is unscheduled. | 178 // here. This is so the reply can be delayed if the scheduler is unscheduled. |
| 178 bool handled = true; | 179 bool handled = true; |
| 179 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) | 180 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) |
| 180 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, | 181 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, |
| 181 OnInitialize); | 182 OnInitialize); |
| 182 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer, | 183 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer, |
| 183 OnSetGetBuffer); | 184 OnSetGetBuffer); |
| 184 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent, | 185 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ProduceFrontBuffer, |
| 185 OnSetParent); | 186 OnProduceFrontBuffer); |
| 186 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Echo, OnEcho); | 187 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Echo, OnEcho); |
| 187 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState); | 188 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState); |
| 188 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetStateFast, | 189 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetStateFast, |
| 189 OnGetStateFast); | 190 OnGetStateFast); |
| 190 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); | 191 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); |
| 191 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetLatencyInfo, OnSetLatencyInfo); | 192 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetLatencyInfo, OnSetLatencyInfo); |
| 192 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); | 193 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); |
| 193 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterTransferBuffer, | 194 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterTransferBuffer, |
| 194 OnRegisterTransferBuffer); | 195 OnRegisterTransferBuffer); |
| 195 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer, | 196 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer, |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 } | 572 } |
| 572 | 573 |
| 573 void GpuCommandBufferStub::OnSetGetBuffer(int32 shm_id, | 574 void GpuCommandBufferStub::OnSetGetBuffer(int32 shm_id, |
| 574 IPC::Message* reply_message) { | 575 IPC::Message* reply_message) { |
| 575 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSetGetBuffer"); | 576 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSetGetBuffer"); |
| 576 if (command_buffer_) | 577 if (command_buffer_) |
| 577 command_buffer_->SetGetBuffer(shm_id); | 578 command_buffer_->SetGetBuffer(shm_id); |
| 578 Send(reply_message); | 579 Send(reply_message); |
| 579 } | 580 } |
| 580 | 581 |
| 581 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, | 582 void GpuCommandBufferStub::OnProduceFrontBuffer(const gpu::Mailbox& mailbox) { |
| 582 uint32 parent_texture_id, | 583 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnProduceFrontBuffer"); |
| 583 IPC::Message* reply_message) { | 584 if (!decoder_) |
| 584 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSetParent"); | 585 LOG(ERROR) << "Can't produce front buffer before initialization."; |
| 585 GpuCommandBufferStub* parent_stub = NULL; | |
| 586 if (parent_route_id != MSG_ROUTING_NONE) { | |
| 587 parent_stub = channel_->LookupCommandBuffer(parent_route_id); | |
| 588 } | |
| 589 | 586 |
| 590 bool result = false; | 587 if (!decoder_->ProduceFrontBuffer(mailbox)) |
| 591 if (scheduler_) { | 588 LOG(ERROR) << "Failed to produce front buffer."; |
| 592 gpu::gles2::GLES2Decoder* parent_decoder = | |
| 593 parent_stub ? parent_stub->decoder_.get() : NULL; | |
| 594 result = decoder_->SetParent(parent_decoder, parent_texture_id); | |
| 595 } | |
| 596 GpuCommandBufferMsg_SetParent::WriteReplyParams(reply_message, result); | |
| 597 Send(reply_message); | |
| 598 } | 589 } |
| 599 | 590 |
| 600 void GpuCommandBufferStub::OnGetState(IPC::Message* reply_message) { | 591 void GpuCommandBufferStub::OnGetState(IPC::Message* reply_message) { |
| 601 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnGetState"); | 592 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnGetState"); |
| 602 if (command_buffer_) { | 593 if (command_buffer_) { |
| 603 gpu::CommandBuffer::State state = command_buffer_->GetState(); | 594 gpu::CommandBuffer::State state = command_buffer_->GetState(); |
| 604 if (state.error == gpu::error::kLostContext && | 595 if (state.error == gpu::error::kLostContext && |
| 605 gfx::GLContext::LosesAllContextsOnContextLost()) | 596 gfx::GLContext::LosesAllContextsOnContextLost()) |
| 606 channel_->LoseAllContexts(); | 597 channel_->LoseAllContexts(); |
| 607 | 598 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 if (surface_.get() && MakeCurrent()) | 911 if (surface_.get() && MakeCurrent()) |
| 921 surface_->SetFrontbufferAllocation( | 912 surface_->SetFrontbufferAllocation( |
| 922 allocation.browser_allocation.suggest_have_frontbuffer); | 913 allocation.browser_allocation.suggest_have_frontbuffer); |
| 923 } | 914 } |
| 924 | 915 |
| 925 last_memory_allocation_valid_ = true; | 916 last_memory_allocation_valid_ = true; |
| 926 last_memory_allocation_ = allocation; | 917 last_memory_allocation_ = allocation; |
| 927 } | 918 } |
| 928 | 919 |
| 929 } // namespace content | 920 } // namespace content |
| OLD | NEW |