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 "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" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 GpuWatchdog* watchdog, | 32 GpuWatchdog* watchdog, |
33 base::SingleThreadTaskRunner* task_runner, | 33 base::SingleThreadTaskRunner* task_runner, |
34 base::SingleThreadTaskRunner* io_task_runner, | 34 base::SingleThreadTaskRunner* io_task_runner, |
35 base::WaitableEvent* shutdown_event, | 35 base::WaitableEvent* shutdown_event, |
36 IPC::AttachmentBroker* broker, | 36 IPC::AttachmentBroker* broker, |
37 gpu::SyncPointManager* sync_point_manager, | 37 gpu::SyncPointManager* sync_point_manager, |
38 GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 38 GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
39 : task_runner_(task_runner), | 39 : task_runner_(task_runner), |
40 io_task_runner_(io_task_runner), | 40 io_task_runner_(io_task_runner), |
41 channel_(channel), | 41 channel_(channel), |
42 global_order_counter_(0), | |
42 watchdog_(watchdog), | 43 watchdog_(watchdog), |
43 shutdown_event_(shutdown_event), | 44 shutdown_event_(shutdown_event), |
44 gpu_memory_manager_( | 45 gpu_memory_manager_( |
45 this, | 46 this, |
46 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit), | 47 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit), |
47 sync_point_manager_(sync_point_manager), | 48 sync_point_manager_(sync_point_manager), |
48 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), | 49 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), |
49 attachment_broker_(broker), | 50 attachment_broker_(broker), |
50 weak_factory_(this) { | 51 weak_factory_(this) { |
51 DCHECK(task_runner); | 52 DCHECK(task_runner); |
52 DCHECK(io_task_runner); | 53 DCHECK(io_task_runner); |
54 io_thread_checker_.DetachFromThread(); | |
53 } | 55 } |
54 | 56 |
55 GpuChannelManager::~GpuChannelManager() { | 57 GpuChannelManager::~GpuChannelManager() { |
56 // Destroy channels before anything else because of dependencies. | 58 // Destroy channels before anything else because of dependencies. |
57 gpu_channels_.clear(); | 59 gpu_channels_.clear(); |
58 if (default_offscreen_surface_.get()) { | 60 if (default_offscreen_surface_.get()) { |
59 default_offscreen_surface_->Destroy(); | 61 default_offscreen_surface_->Destroy(); |
60 default_offscreen_surface_ = NULL; | 62 default_offscreen_surface_ = NULL; |
61 } | 63 } |
62 } | 64 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 } | 100 } |
99 | 101 |
100 void GpuChannelManager::AddRoute(int32 routing_id, IPC::Listener* listener) { | 102 void GpuChannelManager::AddRoute(int32 routing_id, IPC::Listener* listener) { |
101 router_.AddRoute(routing_id, listener); | 103 router_.AddRoute(routing_id, listener); |
102 } | 104 } |
103 | 105 |
104 void GpuChannelManager::RemoveRoute(int32 routing_id) { | 106 void GpuChannelManager::RemoveRoute(int32 routing_id) { |
105 router_.RemoveRoute(routing_id); | 107 router_.RemoveRoute(routing_id); |
106 } | 108 } |
107 | 109 |
110 uint32_t GpuChannelManager::GenerateGlobalOrderNumber() { | |
111 DCHECK(io_thread_checker_.CalledOnValidThread()); | |
112 return global_order_counter_++; | |
113 } | |
114 | |
108 GpuChannel* GpuChannelManager::LookupChannel(int32 client_id) { | 115 GpuChannel* GpuChannelManager::LookupChannel(int32 client_id) { |
109 const auto& it = gpu_channels_.find(client_id); | 116 const auto& it = gpu_channels_.find(client_id); |
110 return it != gpu_channels_.end() ? it->second : nullptr; | 117 return it != gpu_channels_.end() ? it->second : nullptr; |
111 } | 118 } |
112 | 119 |
113 bool GpuChannelManager::OnControlMessageReceived(const IPC::Message& msg) { | 120 bool GpuChannelManager::OnControlMessageReceived(const IPC::Message& msg) { |
114 bool handled = true; | 121 bool handled = true; |
115 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) | 122 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) |
116 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) | 123 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) |
117 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) | 124 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 } | 255 } |
249 | 256 |
250 bool GpuChannelManager::HandleMessagesScheduled() { | 257 bool GpuChannelManager::HandleMessagesScheduled() { |
251 for (auto& kv : gpu_channels_) { | 258 for (auto& kv : gpu_channels_) { |
252 if (kv.second->handle_messages_scheduled()) | 259 if (kv.second->handle_messages_scheduled()) |
253 return true; | 260 return true; |
254 } | 261 } |
255 return false; | 262 return false; |
256 } | 263 } |
257 | 264 |
258 uint64 GpuChannelManager::MessagesProcessed() { | 265 uint32_t GpuChannelManager::ProcessedOrderNumber() { |
259 uint64 messages_processed = 0; | 266 uint32_t processed_order_num = 0; |
260 for (auto& kv : gpu_channels_) | 267 for (auto& kv : gpu_channels_) |
piman
2015/08/31 23:15:04
nit: needs brackets per style guide
David Yen
2015/09/01 02:01:52
Done, although I was following the style in the be
| |
261 messages_processed += kv.second->messages_processed(); | 268 processed_order_num = std::max(processed_order_num, |
262 return messages_processed; | 269 kv.second->GetProcessedOrderNum()); |
270 return processed_order_num; | |
263 } | 271 } |
264 | 272 |
265 void GpuChannelManager::LoseAllContexts() { | 273 void GpuChannelManager::LoseAllContexts() { |
266 for (auto& kv : gpu_channels_) | 274 for (auto& kv : gpu_channels_) |
267 kv.second->MarkAllContextsLost(); | 275 kv.second->MarkAllContextsLost(); |
268 task_runner_->PostTask(FROM_HERE, | 276 task_runner_->PostTask(FROM_HERE, |
269 base::Bind(&GpuChannelManager::OnLoseAllContexts, | 277 base::Bind(&GpuChannelManager::OnLoseAllContexts, |
270 weak_factory_.GetWeakPtr())); | 278 weak_factory_.GetWeakPtr())); |
271 } | 279 } |
272 | 280 |
273 void GpuChannelManager::OnLoseAllContexts() { | 281 void GpuChannelManager::OnLoseAllContexts() { |
274 gpu_channels_.clear(); | 282 gpu_channels_.clear(); |
275 } | 283 } |
276 | 284 |
277 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { | 285 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { |
278 if (!default_offscreen_surface_.get()) { | 286 if (!default_offscreen_surface_.get()) { |
279 default_offscreen_surface_ = | 287 default_offscreen_surface_ = |
280 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); | 288 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); |
281 } | 289 } |
282 return default_offscreen_surface_.get(); | 290 return default_offscreen_surface_.get(); |
283 } | 291 } |
284 | 292 |
285 } // namespace content | 293 } // namespace content |
OLD | NEW |