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

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

Issue 1134113002: content/common: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix CrOS build. Created 5 years, 7 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
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 "base/location.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h"
9 #include "content/common/gpu/gpu_channel.h" 12 #include "content/common/gpu/gpu_channel.h"
10 #include "content/common/gpu/gpu_memory_buffer_factory.h" 13 #include "content/common/gpu/gpu_memory_buffer_factory.h"
11 #include "content/common/gpu/gpu_memory_manager.h" 14 #include "content/common/gpu/gpu_memory_manager.h"
12 #include "content/common/gpu/gpu_messages.h" 15 #include "content/common/gpu/gpu_messages.h"
13 #include "content/common/message_router.h" 16 #include "content/common/message_router.h"
14 #include "gpu/command_buffer/common/value_state.h" 17 #include "gpu/command_buffer/common/value_state.h"
15 #include "gpu/command_buffer/service/feature_info.h" 18 #include "gpu/command_buffer/service/feature_info.h"
16 #include "gpu/command_buffer/service/gpu_switches.h" 19 #include "gpu/command_buffer/service/gpu_switches.h"
17 #include "gpu/command_buffer/service/mailbox_manager_impl.h" 20 #include "gpu/command_buffer/service/mailbox_manager_impl.h"
18 #include "gpu/command_buffer/service/memory_program_cache.h" 21 #include "gpu/command_buffer/service/memory_program_cache.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 81
79 gfx::GpuMemoryBufferType GetGpuMemoryBufferFactoryType() { 82 gfx::GpuMemoryBufferType GetGpuMemoryBufferFactoryType() {
80 std::vector<gfx::GpuMemoryBufferType> supported_types; 83 std::vector<gfx::GpuMemoryBufferType> supported_types;
81 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); 84 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types);
82 DCHECK(!supported_types.empty()); 85 DCHECK(!supported_types.empty());
83 return supported_types[0]; 86 return supported_types[0];
84 } 87 }
85 88
86 } // namespace 89 } // namespace
87 90
88 GpuChannelManager::GpuChannelManager(MessageRouter* router, 91 GpuChannelManager::GpuChannelManager(
89 GpuWatchdog* watchdog, 92 MessageRouter* router,
90 base::MessageLoopProxy* io_message_loop, 93 GpuWatchdog* watchdog,
91 base::WaitableEvent* shutdown_event, 94 base::SingleThreadTaskRunner* io_task_runner,
92 IPC::SyncChannel* channel) 95 base::WaitableEvent* shutdown_event,
93 : io_message_loop_(io_message_loop), 96 IPC::SyncChannel* channel)
97 : io_task_runner_(io_task_runner),
94 shutdown_event_(shutdown_event), 98 shutdown_event_(shutdown_event),
95 router_(router), 99 router_(router),
96 gpu_memory_manager_( 100 gpu_memory_manager_(
97 this, 101 this,
98 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit), 102 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit),
99 watchdog_(watchdog), 103 watchdog_(watchdog),
100 sync_point_manager_(gpu::SyncPointManager::Create(false)), 104 sync_point_manager_(gpu::SyncPointManager::Create(false)),
101 gpu_memory_buffer_factory_( 105 gpu_memory_buffer_factory_(
102 GpuMemoryBufferFactory::Create(GetGpuMemoryBufferFactoryType())), 106 GpuMemoryBufferFactory::Create(GetGpuMemoryBufferFactoryType())),
103 channel_(channel), 107 channel_(channel),
104 filter_( 108 filter_(
105 new GpuChannelManagerMessageFilter(gpu_memory_buffer_factory_.get())), 109 new GpuChannelManagerMessageFilter(gpu_memory_buffer_factory_.get())),
106 relinquish_resources_pending_(false), 110 relinquish_resources_pending_(false),
107 weak_factory_(this) { 111 weak_factory_(this) {
108 DCHECK(router_); 112 DCHECK(router_);
109 DCHECK(io_message_loop); 113 DCHECK(io_task_runner);
110 DCHECK(shutdown_event); 114 DCHECK(shutdown_event);
111 channel_->AddFilter(filter_.get()); 115 channel_->AddFilter(filter_.get());
112 } 116 }
113 117
114 GpuChannelManager::~GpuChannelManager() { 118 GpuChannelManager::~GpuChannelManager() {
115 gpu_channels_.clear(); 119 gpu_channels_.clear();
116 if (default_offscreen_surface_.get()) { 120 if (default_offscreen_surface_.get()) {
117 default_offscreen_surface_->Destroy(); 121 default_offscreen_surface_->Destroy();
118 default_offscreen_surface_ = NULL; 122 default_offscreen_surface_ = NULL;
119 } 123 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 mailbox_manager = mailbox_manager_.get(); 203 mailbox_manager = mailbox_manager_.get();
200 } 204 }
201 205
202 scoped_ptr<GpuChannel> channel(new GpuChannel(this, 206 scoped_ptr<GpuChannel> channel(new GpuChannel(this,
203 watchdog_, 207 watchdog_,
204 share_group, 208 share_group,
205 mailbox_manager, 209 mailbox_manager,
206 client_id, 210 client_id,
207 false, 211 false,
208 allow_future_sync_points)); 212 allow_future_sync_points));
209 channel->Init(io_message_loop_.get(), shutdown_event_); 213 channel->Init(io_task_runner_.get(), shutdown_event_);
210 channel_handle.name = channel->GetChannelName(); 214 channel_handle.name = channel->GetChannelName();
211 215
212 #if defined(OS_POSIX) 216 #if defined(OS_POSIX)
213 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so 217 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so
214 // that it gets closed after it has been sent. 218 // that it gets closed after it has been sent.
215 base::ScopedFD renderer_fd = channel->TakeRendererFileDescriptor(); 219 base::ScopedFD renderer_fd = channel->TakeRendererFileDescriptor();
216 DCHECK(renderer_fd.is_valid()); 220 DCHECK(renderer_fd.is_valid());
217 channel_handle.socket = base::FileDescriptor(renderer_fd.Pass()); 221 channel_handle.socket = base::FileDescriptor(renderer_fd.Pass());
218 #endif 222 #endif
219 223
(...skipping 28 matching lines...) Expand all
248 result = iter->second->CreateViewCommandBuffer( 252 result = iter->second->CreateViewCommandBuffer(
249 window, surface_id, init_params, route_id); 253 window, surface_id, init_params, route_id);
250 } 254 }
251 255
252 Send(new GpuHostMsg_CommandBufferCreated(result)); 256 Send(new GpuHostMsg_CommandBufferCreated(result));
253 } 257 }
254 258
255 void GpuChannelManager::DestroyGpuMemoryBuffer( 259 void GpuChannelManager::DestroyGpuMemoryBuffer(
256 gfx::GpuMemoryBufferId id, 260 gfx::GpuMemoryBufferId id,
257 int client_id) { 261 int client_id) {
258 io_message_loop_->PostTask( 262 io_task_runner_->PostTask(
259 FROM_HERE, 263 FROM_HERE, base::Bind(&GpuChannelManager::DestroyGpuMemoryBufferOnIO,
260 base::Bind(&GpuChannelManager::DestroyGpuMemoryBufferOnIO, 264 base::Unretained(this), id, client_id));
261 base::Unretained(this),
262 id,
263 client_id));
264 } 265 }
265 266
266 void GpuChannelManager::DestroyGpuMemoryBufferOnIO( 267 void GpuChannelManager::DestroyGpuMemoryBufferOnIO(
267 gfx::GpuMemoryBufferId id, 268 gfx::GpuMemoryBufferId id,
268 int client_id) { 269 int client_id) {
269 gpu_memory_buffer_factory_->DestroyGpuMemoryBuffer(id, client_id); 270 gpu_memory_buffer_factory_->DestroyGpuMemoryBuffer(id, client_id);
270 } 271 }
271 272
272 void GpuChannelManager::OnDestroyGpuMemoryBuffer( 273 void GpuChannelManager::OnDestroyGpuMemoryBuffer(
273 gfx::GpuMemoryBufferId id, 274 gfx::GpuMemoryBufferId id,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 messages_processed += iter->second->messages_processed(); 318 messages_processed += iter->second->messages_processed();
318 } 319 }
319 return messages_processed; 320 return messages_processed;
320 } 321 }
321 322
322 void GpuChannelManager::LoseAllContexts() { 323 void GpuChannelManager::LoseAllContexts() {
323 for (GpuChannelMap::iterator iter = gpu_channels_.begin(); 324 for (GpuChannelMap::iterator iter = gpu_channels_.begin();
324 iter != gpu_channels_.end(); ++iter) { 325 iter != gpu_channels_.end(); ++iter) {
325 iter->second->MarkAllContextsLost(); 326 iter->second->MarkAllContextsLost();
326 } 327 }
327 base::MessageLoop::current()->PostTask( 328 base::ThreadTaskRunnerHandle::Get()->PostTask(
328 FROM_HERE, 329 FROM_HERE, base::Bind(&GpuChannelManager::OnLoseAllContexts,
329 base::Bind(&GpuChannelManager::OnLoseAllContexts, 330 weak_factory_.GetWeakPtr()));
330 weak_factory_.GetWeakPtr()));
331 } 331 }
332 332
333 void GpuChannelManager::OnLoseAllContexts() { 333 void GpuChannelManager::OnLoseAllContexts() {
334 gpu_channels_.clear(); 334 gpu_channels_.clear();
335 CheckRelinquishGpuResources(); 335 CheckRelinquishGpuResources();
336 } 336 }
337 337
338 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { 338 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
339 if (!default_offscreen_surface_.get()) { 339 if (!default_offscreen_surface_.get()) {
340 default_offscreen_surface_ = 340 default_offscreen_surface_ =
(...skipping 24 matching lines...) Expand all
365 OnResourcesRelinquished(); 365 OnResourcesRelinquished();
366 #endif 366 #endif
367 } 367 }
368 } 368 }
369 369
370 void GpuChannelManager::OnResourcesRelinquished() { 370 void GpuChannelManager::OnResourcesRelinquished() {
371 Send(new GpuHostMsg_ResourcesRelinquished()); 371 Send(new GpuHostMsg_ResourcesRelinquished());
372 } 372 }
373 373
374 } // namespace content 374 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel_manager.h ('k') | content/common/gpu/gpu_channel_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698