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 "content/common/child_thread.h" | 9 #include "content/common/child_thread.h" |
9 #include "content/common/gpu/gpu_channel.h" | 10 #include "content/common/gpu/gpu_channel.h" |
10 #include "content/common/gpu/gpu_memory_manager.h" | 11 #include "content/common/gpu/gpu_memory_manager.h" |
11 #include "content/common/gpu/gpu_messages.h" | 12 #include "content/common/gpu/gpu_messages.h" |
12 #include "content/common/gpu/sync_point_manager.h" | 13 #include "content/common/gpu/sync_point_manager.h" |
| 14 #include "gpu/command_buffer/service/feature_info.h" |
| 15 #include "gpu/command_buffer/service/gpu_switches.h" |
13 #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" |
| 18 #include "ui/gl/gl_bindings.h" |
14 #include "ui/gl/gl_share_group.h" | 19 #include "ui/gl/gl_share_group.h" |
15 | 20 |
16 GpuChannelManager::GpuChannelManager(ChildThread* gpu_child_thread, | 21 GpuChannelManager::GpuChannelManager(ChildThread* gpu_child_thread, |
17 GpuWatchdog* watchdog, | 22 GpuWatchdog* watchdog, |
18 base::MessageLoopProxy* io_message_loop, | 23 base::MessageLoopProxy* io_message_loop, |
19 base::WaitableEvent* shutdown_event) | 24 base::WaitableEvent* shutdown_event) |
20 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 25 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
21 io_message_loop_(io_message_loop), | 26 io_message_loop_(io_message_loop), |
22 shutdown_event_(shutdown_event), | 27 shutdown_event_(shutdown_event), |
23 gpu_child_thread_(gpu_child_thread), | 28 gpu_child_thread_(gpu_child_thread), |
24 ALLOW_THIS_IN_INITIALIZER_LIST(gpu_memory_manager_(this, | 29 ALLOW_THIS_IN_INITIALIZER_LIST(gpu_memory_manager_(this, |
25 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit)), | 30 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit)), |
26 watchdog_(watchdog), | 31 watchdog_(watchdog), |
27 sync_point_manager_(new SyncPointManager) { | 32 sync_point_manager_(new SyncPointManager), |
| 33 program_cache_(NULL) { |
28 DCHECK(gpu_child_thread); | 34 DCHECK(gpu_child_thread); |
29 DCHECK(io_message_loop); | 35 DCHECK(io_message_loop); |
30 DCHECK(shutdown_event); | 36 DCHECK(shutdown_event); |
31 } | 37 } |
32 | 38 |
33 GpuChannelManager::~GpuChannelManager() { | 39 GpuChannelManager::~GpuChannelManager() { |
34 gpu_channels_.clear(); | 40 gpu_channels_.clear(); |
35 } | 41 } |
36 | 42 |
| 43 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() { |
| 44 if (!program_cache_.get() && |
| 45 (gfx::g_ARB_get_program_binary || gfx::g_OES_get_program_binary) && |
| 46 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 47 switches::kDisableGpuProgramCache)) { |
| 48 program_cache_.reset(new gpu::gles2::MemoryProgramCache()); |
| 49 } |
| 50 return program_cache_.get(); |
| 51 } |
| 52 |
37 void GpuChannelManager::RemoveChannel(int client_id) { | 53 void GpuChannelManager::RemoveChannel(int client_id) { |
38 gpu_channels_.erase(client_id); | 54 gpu_channels_.erase(client_id); |
39 } | 55 } |
40 | 56 |
41 int GpuChannelManager::GenerateRouteID() { | 57 int GpuChannelManager::GenerateRouteID() { |
42 static int last_id = 0; | 58 static int last_id = 0; |
43 return ++last_id; | 59 return ++last_id; |
44 } | 60 } |
45 | 61 |
46 void GpuChannelManager::AddRoute(int32 routing_id, IPC::Listener* listener) { | 62 void GpuChannelManager::AddRoute(int32 routing_id, IPC::Listener* listener) { |
(...skipping 11 matching lines...) Expand all Loading... |
58 else | 74 else |
59 return iter->second; | 75 return iter->second; |
60 } | 76 } |
61 | 77 |
62 void GpuChannelManager::AppendAllCommandBufferStubs( | 78 void GpuChannelManager::AppendAllCommandBufferStubs( |
63 std::vector<GpuCommandBufferStubBase*>& stubs) { | 79 std::vector<GpuCommandBufferStubBase*>& stubs) { |
64 for (GpuChannelMap::const_iterator it = gpu_channels_.begin(); | 80 for (GpuChannelMap::const_iterator it = gpu_channels_.begin(); |
65 it != gpu_channels_.end(); ++it ) { | 81 it != gpu_channels_.end(); ++it ) { |
66 it->second->AppendAllCommandBufferStubs(stubs); | 82 it->second->AppendAllCommandBufferStubs(stubs); |
67 } | 83 } |
68 | |
69 } | 84 } |
70 | 85 |
71 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { | 86 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { |
72 bool msg_is_ok = true; | 87 bool msg_is_ok = true; |
73 bool handled = true; | 88 bool handled = true; |
74 IPC_BEGIN_MESSAGE_MAP_EX(GpuChannelManager, msg, msg_is_ok) | 89 IPC_BEGIN_MESSAGE_MAP_EX(GpuChannelManager, msg, msg_is_ok) |
75 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) | 90 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) |
76 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) | 91 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) |
77 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, | 92 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, |
78 OnCreateViewCommandBuffer) | 93 OnCreateViewCommandBuffer) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 void GpuChannelManager::LoseAllContexts() { | 168 void GpuChannelManager::LoseAllContexts() { |
154 MessageLoop::current()->PostTask( | 169 MessageLoop::current()->PostTask( |
155 FROM_HERE, | 170 FROM_HERE, |
156 base::Bind(&GpuChannelManager::OnLoseAllContexts, | 171 base::Bind(&GpuChannelManager::OnLoseAllContexts, |
157 weak_factory_.GetWeakPtr())); | 172 weak_factory_.GetWeakPtr())); |
158 } | 173 } |
159 | 174 |
160 void GpuChannelManager::OnLoseAllContexts() { | 175 void GpuChannelManager::OnLoseAllContexts() { |
161 gpu_channels_.clear(); | 176 gpu_channels_.clear(); |
162 } | 177 } |
OLD | NEW |