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

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: dcheng's final comments 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
« no previous file with comments | « content/common/gpu/gpu_channel_manager.h ('k') | content/common/gpu/gpu_command_buffer_stub.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 "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::GetUnprocessedOrderNum() const {
255 uint32_t processed_order_num = 0;
256 for (auto& kv : gpu_channels_) {
257 processed_order_num =
258 std::max(processed_order_num, kv.second->GetProcessedOrderNum());
259 }
260 return processed_order_num;
261 }
262
263 uint32_t GpuChannelManager::UnprocessedOrderNumber() {
264 uint32_t unprocessed_order_num = 0; 255 uint32_t unprocessed_order_num = 0;
265 for (auto& kv : gpu_channels_) { 256 for (auto& kv : gpu_channels_) {
266 unprocessed_order_num = 257 unprocessed_order_num =
267 std::max(unprocessed_order_num, kv.second->GetUnprocessedOrderNum()); 258 std::max(unprocessed_order_num, kv.second->GetUnprocessedOrderNum());
268 } 259 }
269 return unprocessed_order_num; 260 return unprocessed_order_num;
270 } 261 }
271 262
263 uint32_t GpuChannelManager::GetProcessedOrderNum() const {
264 uint32_t processed_order_num = 0;
265 for (auto& kv : gpu_channels_) {
266 processed_order_num =
267 std::max(processed_order_num, kv.second->GetProcessedOrderNum());
268 }
269 return processed_order_num;
270 }
271
272 void GpuChannelManager::LoseAllContexts() { 272 void GpuChannelManager::LoseAllContexts() {
273 for (auto& kv : gpu_channels_) { 273 for (auto& kv : gpu_channels_) {
274 kv.second->MarkAllContextsLost(); 274 kv.second->MarkAllContextsLost();
275 } 275 }
276 task_runner_->PostTask(FROM_HERE, 276 task_runner_->PostTask(FROM_HERE,
277 base::Bind(&GpuChannelManager::OnLoseAllContexts, 277 base::Bind(&GpuChannelManager::OnLoseAllContexts,
278 weak_factory_.GetWeakPtr())); 278 weak_factory_.GetWeakPtr()));
279 } 279 }
280 280
281 void GpuChannelManager::OnLoseAllContexts() { 281 void GpuChannelManager::OnLoseAllContexts() {
282 gpu_channels_.clear(); 282 gpu_channels_.clear();
283 } 283 }
284 284
285 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { 285 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
286 if (!default_offscreen_surface_.get()) { 286 if (!default_offscreen_surface_.get()) {
287 default_offscreen_surface_ = 287 default_offscreen_surface_ =
288 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); 288 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size());
289 } 289 }
290 return default_offscreen_surface_.get(); 290 return default_offscreen_surface_.get();
291 } 291 }
292 292
293 } // namespace content 293 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel_manager.h ('k') | content/common/gpu/gpu_command_buffer_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698