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

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

Issue 198073003: Remove some content_child dependency from content_common (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ffd442cb fix for bots barfing on clang style checks Created 6 years, 9 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
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 "content/common/gpu/gpu_channel_manager.h" 5 #include "content/common/gpu/gpu_channel_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "content/child/child_thread.h"
10 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
11 #include "content/common/gpu/gpu_memory_manager.h" 10 #include "content/common/gpu/gpu_memory_manager.h"
12 #include "content/common/gpu/gpu_messages.h" 11 #include "content/common/gpu/gpu_messages.h"
13 #include "content/common/gpu/sync_point_manager.h" 12 #include "content/common/gpu/sync_point_manager.h"
13 #include "content/common/message_router.h"
14 #include "gpu/command_buffer/service/feature_info.h" 14 #include "gpu/command_buffer/service/feature_info.h"
15 #include "gpu/command_buffer/service/gpu_switches.h" 15 #include "gpu/command_buffer/service/gpu_switches.h"
16 #include "gpu/command_buffer/service/mailbox_manager.h" 16 #include "gpu/command_buffer/service/mailbox_manager.h"
17 #include "gpu/command_buffer/service/memory_program_cache.h" 17 #include "gpu/command_buffer/service/memory_program_cache.h"
18 #include "ui/gl/gl_bindings.h" 18 #include "ui/gl/gl_bindings.h"
19 #include "ui/gl/gl_share_group.h" 19 #include "ui/gl/gl_share_group.h"
20 20
21 namespace content { 21 namespace content {
22 22
23 GpuChannelManager::ImageOperation::ImageOperation( 23 GpuChannelManager::ImageOperation::ImageOperation(
24 int32 sync_point, base::Closure callback) 24 int32 sync_point, base::Closure callback)
25 : sync_point(sync_point), 25 : sync_point(sync_point),
26 callback(callback) { 26 callback(callback) {
27 } 27 }
28 28
29 GpuChannelManager::ImageOperation::~ImageOperation() { 29 GpuChannelManager::ImageOperation::~ImageOperation() {
30 } 30 }
31 31
32 GpuChannelManager::GpuChannelManager(ChildThread* gpu_child_thread, 32 GpuChannelManager::GpuChannelManager(MessageRouter* router,
33 GpuWatchdog* watchdog, 33 GpuWatchdog* watchdog,
34 base::MessageLoopProxy* io_message_loop, 34 base::MessageLoopProxy* io_message_loop,
35 base::WaitableEvent* shutdown_event) 35 base::WaitableEvent* shutdown_event)
36 : weak_factory_(this), 36 : weak_factory_(this),
37 io_message_loop_(io_message_loop), 37 io_message_loop_(io_message_loop),
38 shutdown_event_(shutdown_event), 38 shutdown_event_(shutdown_event),
39 gpu_child_thread_(gpu_child_thread), 39 router_(router),
40 gpu_memory_manager_( 40 gpu_memory_manager_(
41 this, 41 this,
42 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit), 42 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit),
43 watchdog_(watchdog), 43 watchdog_(watchdog),
44 sync_point_manager_(new SyncPointManager) { 44 sync_point_manager_(new SyncPointManager) {
45 DCHECK(gpu_child_thread); 45 DCHECK(router_);
46 DCHECK(io_message_loop); 46 DCHECK(io_message_loop);
47 DCHECK(shutdown_event); 47 DCHECK(shutdown_event);
48 } 48 }
49 49
50 GpuChannelManager::~GpuChannelManager() { 50 GpuChannelManager::~GpuChannelManager() {
51 gpu_channels_.clear(); 51 gpu_channels_.clear();
52 if (default_offscreen_surface_.get()) { 52 if (default_offscreen_surface_.get()) {
53 default_offscreen_surface_->Destroy(); 53 default_offscreen_surface_->Destroy();
54 default_offscreen_surface_ = NULL; 54 default_offscreen_surface_ = NULL;
55 } 55 }
(...skipping 15 matching lines...) Expand all
71 Send(new GpuHostMsg_DestroyChannel(client_id)); 71 Send(new GpuHostMsg_DestroyChannel(client_id));
72 gpu_channels_.erase(client_id); 72 gpu_channels_.erase(client_id);
73 } 73 }
74 74
75 int GpuChannelManager::GenerateRouteID() { 75 int GpuChannelManager::GenerateRouteID() {
76 static int last_id = 0; 76 static int last_id = 0;
77 return ++last_id; 77 return ++last_id;
78 } 78 }
79 79
80 void GpuChannelManager::AddRoute(int32 routing_id, IPC::Listener* listener) { 80 void GpuChannelManager::AddRoute(int32 routing_id, IPC::Listener* listener) {
81 gpu_child_thread_->AddRoute(routing_id, listener); 81 router_->AddRoute(routing_id, listener);
82 } 82 }
83 83
84 void GpuChannelManager::RemoveRoute(int32 routing_id) { 84 void GpuChannelManager::RemoveRoute(int32 routing_id) {
85 gpu_child_thread_->RemoveRoute(routing_id); 85 router_->RemoveRoute(routing_id);
86 } 86 }
87 87
88 GpuChannel* GpuChannelManager::LookupChannel(int32 client_id) { 88 GpuChannel* GpuChannelManager::LookupChannel(int32 client_id) {
89 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); 89 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id);
90 if (iter == gpu_channels_.end()) 90 if (iter == gpu_channels_.end())
91 return NULL; 91 return NULL;
92 else 92 else
93 return iter->second.get(); 93 return iter->second.get();
94 } 94 }
95 95
96 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { 96 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) {
97 bool msg_is_ok = true; 97 bool msg_is_ok = true;
98 bool handled = true; 98 bool handled = true;
99 IPC_BEGIN_MESSAGE_MAP_EX(GpuChannelManager, msg, msg_is_ok) 99 IPC_BEGIN_MESSAGE_MAP_EX(GpuChannelManager, msg, msg_is_ok)
100 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) 100 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel)
101 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) 101 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel)
102 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, 102 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer,
103 OnCreateViewCommandBuffer) 103 OnCreateViewCommandBuffer)
104 IPC_MESSAGE_HANDLER(GpuMsg_CreateImage, OnCreateImage) 104 IPC_MESSAGE_HANDLER(GpuMsg_CreateImage, OnCreateImage)
105 IPC_MESSAGE_HANDLER(GpuMsg_DeleteImage, OnDeleteImage) 105 IPC_MESSAGE_HANDLER(GpuMsg_DeleteImage, OnDeleteImage)
106 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) 106 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader)
107 IPC_MESSAGE_UNHANDLED(handled = false) 107 IPC_MESSAGE_UNHANDLED(handled = false)
108 IPC_END_MESSAGE_MAP_EX() 108 IPC_END_MESSAGE_MAP_EX()
109 return handled; 109 return handled;
110 } 110 }
111 111
112 bool GpuChannelManager::Send(IPC::Message* msg) { 112 bool GpuChannelManager::Send(IPC::Message* msg) { return router_->Send(msg); }
113 return gpu_child_thread_->Send(msg);
114 }
115 113
116 void GpuChannelManager::OnEstablishChannel(int client_id, bool share_context) { 114 void GpuChannelManager::OnEstablishChannel(int client_id, bool share_context) {
117 IPC::ChannelHandle channel_handle; 115 IPC::ChannelHandle channel_handle;
118 116
119 gfx::GLShareGroup* share_group = NULL; 117 gfx::GLShareGroup* share_group = NULL;
120 gpu::gles2::MailboxManager* mailbox_manager = NULL; 118 gpu::gles2::MailboxManager* mailbox_manager = NULL;
121 if (share_context) { 119 if (share_context) {
122 if (!share_group_.get()) { 120 if (!share_group_.get()) {
123 share_group_ = new gfx::GLShareGroup; 121 share_group_ = new gfx::GLShareGroup;
124 DCHECK(!mailbox_manager_.get()); 122 DCHECK(!mailbox_manager_.get());
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 291
294 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { 292 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
295 if (!default_offscreen_surface_.get()) { 293 if (!default_offscreen_surface_.get()) {
296 default_offscreen_surface_ = 294 default_offscreen_surface_ =
297 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); 295 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1));
298 } 296 }
299 return default_offscreen_surface_.get(); 297 return default_offscreen_surface_.get();
300 } 298 }
301 299
302 } // namespace content 300 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel_manager.h ('k') | content/common/gpu/media/vaapi_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698