Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.cc

Issue 19762004: Add multi-process GpuMemoryBuffer framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
11 #include "base/time/time.h" 11 #include "base/time/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 "gpu/command_buffer/common/constants.h" 24 #include "gpu/command_buffer/common/constants.h"
25 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 25 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
26 #include "gpu/command_buffer/common/mailbox.h" 26 #include "gpu/command_buffer/common/mailbox.h"
27 #include "gpu/command_buffer/service/gl_context_virtual.h" 27 #include "gpu/command_buffer/service/gl_context_virtual.h"
28 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" 28 #include "gpu/command_buffer/service/gl_state_restorer_impl.h"
29 #include "gpu/command_buffer/service/gpu_control_service.h"
30 #include "gpu/command_buffer/service/image_manager.h"
29 #include "gpu/command_buffer/service/logger.h" 31 #include "gpu/command_buffer/service/logger.h"
30 #include "gpu/command_buffer/service/memory_tracking.h" 32 #include "gpu/command_buffer/service/memory_tracking.h"
31 #include "gpu/command_buffer/service/query_manager.h" 33 #include "gpu/command_buffer/service/query_manager.h"
32 #include "ui/gl/gl_bindings.h" 34 #include "ui/gl/gl_bindings.h"
33 #include "ui/gl/gl_switches.h" 35 #include "ui/gl/gl_switches.h"
34 36
35 #if defined(OS_WIN) 37 #if defined(OS_WIN)
36 #include "content/public/common/sandbox_init.h" 38 #include "content/public/common/sandbox_init.h"
37 #endif 39 #endif
38 40
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 OnRetireSyncPoint) 218 OnRetireSyncPoint)
217 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPoint, 219 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPoint,
218 OnSignalSyncPoint) 220 OnSignalSyncPoint)
219 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery, 221 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery,
220 OnSignalQuery) 222 OnSignalQuery)
221 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SendClientManagedMemoryStats, 223 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SendClientManagedMemoryStats,
222 OnReceivedClientManagedMemoryStats) 224 OnReceivedClientManagedMemoryStats)
223 IPC_MESSAGE_HANDLER( 225 IPC_MESSAGE_HANDLER(
224 GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback, 226 GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback,
225 OnSetClientHasMemoryAllocationChangedCallback) 227 OnSetClientHasMemoryAllocationChangedCallback)
228 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterGpuMemoryBuffer,
229 OnRegisterGpuMemoryBuffer);
230 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyGpuMemoryBuffer,
231 OnDestroyGpuMemoryBuffer);
226 IPC_MESSAGE_UNHANDLED(handled = false) 232 IPC_MESSAGE_UNHANDLED(handled = false)
227 IPC_END_MESSAGE_MAP() 233 IPC_END_MESSAGE_MAP()
228 234
229 // Ensure that any delayed work that was created will be handled. 235 // Ensure that any delayed work that was created will be handled.
230 ScheduleDelayedWork(kHandleMoreWorkPeriodMs); 236 ScheduleDelayedWork(kHandleMoreWorkPeriodMs);
231 237
232 DCHECK(handled); 238 DCHECK(handled);
233 return handled; 239 return handled;
234 } 240 }
235 241
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 402
397 command_buffer_.reset(new gpu::CommandBufferService( 403 command_buffer_.reset(new gpu::CommandBufferService(
398 context_group_->transfer_buffer_manager())); 404 context_group_->transfer_buffer_manager()));
399 405
400 if (!command_buffer_->Initialize()) { 406 if (!command_buffer_->Initialize()) {
401 DLOG(ERROR) << "CommandBufferService failed to initialize.\n"; 407 DLOG(ERROR) << "CommandBufferService failed to initialize.\n";
402 OnInitializeFailed(reply_message); 408 OnInitializeFailed(reply_message);
403 return; 409 return;
404 } 410 }
405 411
412 gpu_control_.reset(
413 new gpu::GpuControlService(context_group_->image_manager(),
414 NULL,
415 context_group_->mailbox_manager(),
416 NULL));
417
406 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get())); 418 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get()));
407 419
408 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), 420 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(),
409 decoder_.get(), 421 decoder_.get(),
410 decoder_.get())); 422 decoder_.get()));
411 if (preemption_flag_.get()) 423 if (preemption_flag_.get())
412 scheduler_->SetPreemptByFlag(preemption_flag_); 424 scheduler_->SetPreemptByFlag(preemption_flag_);
413 425
414 decoder_->set_engine(scheduler_.get()); 426 decoder_->set_engine(scheduler_.get());
415 427
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 if (has_callback) { 853 if (has_callback) {
842 if (!memory_manager_client_state_) { 854 if (!memory_manager_client_state_) {
843 memory_manager_client_state_.reset(GetMemoryManager()->CreateClientState( 855 memory_manager_client_state_.reset(GetMemoryManager()->CreateClientState(
844 this, surface_id_ != 0, true)); 856 this, surface_id_ != 0, true));
845 } 857 }
846 } else { 858 } else {
847 memory_manager_client_state_.reset(); 859 memory_manager_client_state_.reset();
848 } 860 }
849 } 861 }
850 862
863 void GpuCommandBufferStub::OnRegisterGpuMemoryBuffer(
864 int32 id,
865 gfx::GpuMemoryBufferHandle gpu_memory_buffer,
866 uint32 width,
867 uint32 height,
868 uint32 internalformat) {
869 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterGpuMemoryBuffer");
870 if (gpu_control_) {
871 gpu_control_->RegisterGpuMemoryBuffer(id,
872 gpu_memory_buffer,
873 width,
874 height,
875 internalformat);
876 }
877 }
878
879 void GpuCommandBufferStub::OnDestroyGpuMemoryBuffer(int32 id) {
880 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyGpuMemoryBuffer");
881 if (gpu_control_)
882 gpu_control_->DestroyGpuMemoryBuffer(id);
883 }
884
851 void GpuCommandBufferStub::SendConsoleMessage( 885 void GpuCommandBufferStub::SendConsoleMessage(
852 int32 id, 886 int32 id,
853 const std::string& message) { 887 const std::string& message) {
854 GPUCommandBufferConsoleMessage console_message; 888 GPUCommandBufferConsoleMessage console_message;
855 console_message.id = id; 889 console_message.id = id;
856 console_message.message = message; 890 console_message.message = message;
857 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( 891 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg(
858 route_id_, console_message); 892 route_id_, console_message);
859 msg->set_unblock(true); 893 msg->set_unblock(true);
860 Send(msg); 894 Send(msg);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 command_buffer_->GetState().error == gpu::error::kLostContext) 972 command_buffer_->GetState().error == gpu::error::kLostContext)
939 return; 973 return;
940 974
941 command_buffer_->SetContextLostReason(gpu::error::kUnknown); 975 command_buffer_->SetContextLostReason(gpu::error::kUnknown);
942 if (decoder_) 976 if (decoder_)
943 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); 977 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB);
944 command_buffer_->SetParseError(gpu::error::kLostContext); 978 command_buffer_->SetParseError(gpu::error::kLostContext);
945 } 979 }
946 980
947 } // namespace content 981 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698