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

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

Issue 1336623004: content/gpu: Simplify gpu channel message handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 void GpuChannelManager::AddRoute(int32 routing_id, IPC::Listener* listener) { 102 void GpuChannelManager::AddRoute(int32 routing_id, IPC::Listener* listener) {
103 router_.AddRoute(routing_id, listener); 103 router_.AddRoute(routing_id, listener);
104 } 104 }
105 105
106 void GpuChannelManager::RemoveRoute(int32 routing_id) { 106 void GpuChannelManager::RemoveRoute(int32 routing_id) {
107 router_.RemoveRoute(routing_id); 107 router_.RemoveRoute(routing_id);
108 } 108 }
109 109
110 GpuChannel* GpuChannelManager::LookupChannel(int32 client_id) { 110 GpuChannel* GpuChannelManager::LookupChannel(int32 client_id) const {
111 const auto& it = gpu_channels_.find(client_id); 111 const auto& it = gpu_channels_.find(client_id);
112 return it != gpu_channels_.end() ? it->second : nullptr; 112 return it != gpu_channels_.end() ? it->second : nullptr;
113 } 113 }
114 114
115 bool GpuChannelManager::OnControlMessageReceived(const IPC::Message& msg) { 115 bool GpuChannelManager::OnControlMessageReceived(const IPC::Message& msg) {
116 bool handled = true; 116 bool handled = true;
117 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) 117 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg)
118 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) 118 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel)
119 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) 119 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel)
120 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, 120 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 auto it = gpu_channels_.find(client_id); 244 auto it = gpu_channels_.find(client_id);
245 if (it != gpu_channels_.end()) 245 if (it != gpu_channels_.end())
246 it->second->HandleUpdateValueState(target, state); 246 it->second->HandleUpdateValueState(target, state);
247 } 247 }
248 248
249 void GpuChannelManager::OnLoadedShader(std::string program_proto) { 249 void GpuChannelManager::OnLoadedShader(std::string program_proto) {
250 if (program_cache()) 250 if (program_cache())
251 program_cache()->LoadProgram(program_proto); 251 program_cache()->LoadProgram(program_proto);
252 } 252 }
253 253
254 uint32_t GpuChannelManager::ProcessedOrderNumber() { 254 uint32_t GpuChannelManager::GetNextUnprocessedOrderNum() {
255 base::AutoLock lock(order_num_lock_);
David Yen 2015/09/10 22:42:06 Is the new scheduler also going to use this? Seems
sunnyps 2015/09/10 23:38:36 On second thought I'm keeping this as is for now -
David Yen 2015/09/11 16:47:20 per your comment yesterday, I think you are right.
256 return ++unprocessed_order_num_;
257 }
258
259 uint32_t GpuChannelManager::GetCurrentUnprocessedOrderNum() const {
260 base::AutoLock lock(order_num_lock_);
261 return unprocessed_order_num_;
262 }
263
264 uint32_t GpuChannelManager::GetProcessedOrderNum() const {
255 uint32_t processed_order_num = 0; 265 uint32_t processed_order_num = 0;
256 for (auto& kv : gpu_channels_) { 266 for (auto& kv : gpu_channels_) {
257 processed_order_num = 267 processed_order_num =
258 std::max(processed_order_num, kv.second->GetProcessedOrderNum()); 268 std::max(processed_order_num, kv.second->GetProcessedOrderNum());
259 } 269 }
260 return processed_order_num; 270 return processed_order_num;
261 } 271 }
262 272
263 uint32_t GpuChannelManager::UnprocessedOrderNumber() {
264 uint32_t unprocessed_order_num = 0;
265 for (auto& kv : gpu_channels_) {
266 unprocessed_order_num =
267 std::max(unprocessed_order_num, kv.second->GetUnprocessedOrderNum());
268 }
269 return unprocessed_order_num;
270 }
271
272 void GpuChannelManager::LoseAllContexts() { 273 void GpuChannelManager::LoseAllContexts() {
273 for (auto& kv : gpu_channels_) { 274 for (auto& kv : gpu_channels_) {
274 kv.second->MarkAllContextsLost(); 275 kv.second->MarkAllContextsLost();
275 } 276 }
276 task_runner_->PostTask(FROM_HERE, 277 task_runner_->PostTask(FROM_HERE,
277 base::Bind(&GpuChannelManager::OnLoseAllContexts, 278 base::Bind(&GpuChannelManager::OnLoseAllContexts,
278 weak_factory_.GetWeakPtr())); 279 weak_factory_.GetWeakPtr()));
279 } 280 }
280 281
281 void GpuChannelManager::OnLoseAllContexts() { 282 void GpuChannelManager::OnLoseAllContexts() {
282 gpu_channels_.clear(); 283 gpu_channels_.clear();
283 } 284 }
284 285
285 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { 286 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
286 if (!default_offscreen_surface_.get()) { 287 if (!default_offscreen_surface_.get()) {
287 default_offscreen_surface_ = 288 default_offscreen_surface_ =
288 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); 289 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size());
289 } 290 }
290 return default_offscreen_surface_.get(); 291 return default_offscreen_surface_.get();
291 } 292 }
292 293
293 } // namespace content 294 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698