OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/common/child_thread.h" | 8 #include "content/common/child_thread.h" |
9 #include "content/common/gpu/gpu_channel.h" | 9 #include "content/common/gpu/gpu_channel.h" |
10 #include "content/common/gpu/gpu_messages.h" | 10 #include "content/common/gpu/gpu_messages.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { | 56 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { |
57 bool msg_is_ok = true; | 57 bool msg_is_ok = true; |
58 bool handled = true; | 58 bool handled = true; |
59 IPC_BEGIN_MESSAGE_MAP_EX(GpuChannelManager, msg, msg_is_ok) | 59 IPC_BEGIN_MESSAGE_MAP_EX(GpuChannelManager, msg, msg_is_ok) |
60 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) | 60 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) |
61 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) | 61 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) |
62 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, | 62 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, |
63 OnCreateViewCommandBuffer) | 63 OnCreateViewCommandBuffer) |
64 IPC_MESSAGE_HANDLER(GpuMsg_VisibilityChanged, OnVisibilityChanged) | 64 IPC_MESSAGE_HANDLER(GpuMsg_VisibilityChanged, OnVisibilityChanged) |
| 65 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) |
| 66 IPC_MESSAGE_HANDLER(GpuMsg_ResizeViewACK, OnResizeViewACK); |
| 67 #endif |
65 IPC_MESSAGE_UNHANDLED(handled = false) | 68 IPC_MESSAGE_UNHANDLED(handled = false) |
66 IPC_END_MESSAGE_MAP_EX() | 69 IPC_END_MESSAGE_MAP_EX() |
67 return handled; | 70 return handled; |
68 } | 71 } |
69 | 72 |
70 bool GpuChannelManager::Send(IPC::Message* msg) { | 73 bool GpuChannelManager::Send(IPC::Message* msg) { |
71 return gpu_child_thread_->Send(msg); | 74 return gpu_child_thread_->Send(msg); |
72 } | 75 } |
73 | 76 |
74 void GpuChannelManager::OnEstablishChannel(int renderer_id) { | 77 void GpuChannelManager::OnEstablishChannel(int renderer_id) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 void GpuChannelManager::OnVisibilityChanged( | 120 void GpuChannelManager::OnVisibilityChanged( |
118 int32 render_view_id, int32 renderer_id, bool visible) { | 121 int32 render_view_id, int32 renderer_id, bool visible) { |
119 // TODO(amarinichev): this will be used for context eviction | 122 // TODO(amarinichev): this will be used for context eviction |
120 } | 123 } |
121 | 124 |
122 void GpuChannelManager::OnCreateViewCommandBuffer( | 125 void GpuChannelManager::OnCreateViewCommandBuffer( |
123 gfx::PluginWindowHandle window, | 126 gfx::PluginWindowHandle window, |
124 int32 render_view_id, | 127 int32 render_view_id, |
125 int32 renderer_id, | 128 int32 renderer_id, |
126 const GPUCreateCommandBufferConfig& init_params) { | 129 const GPUCreateCommandBufferConfig& init_params) { |
127 DCHECK(render_view_id); | |
128 int32 route_id = MSG_ROUTING_NONE; | 130 int32 route_id = MSG_ROUTING_NONE; |
129 | 131 |
130 GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); | 132 GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); |
131 if (iter != gpu_channels_.end()) { | 133 if (iter != gpu_channels_.end()) { |
132 iter->second->CreateViewCommandBuffer( | 134 iter->second->CreateViewCommandBuffer( |
133 window, render_view_id, init_params, &route_id); | 135 window, render_view_id, init_params, &route_id); |
134 } | 136 } |
135 | 137 |
136 Send(new GpuHostMsg_CommandBufferCreated(route_id)); | 138 Send(new GpuHostMsg_CommandBufferCreated(route_id)); |
137 } | 139 } |
138 | 140 |
| 141 void GpuChannelManager::OnResizeViewACK(int32 renderer_id, |
| 142 int32 command_buffer_route_id) { |
| 143 GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); |
| 144 if (iter == gpu_channels_.end()) |
| 145 return; |
| 146 scoped_refptr<GpuChannel> channel = iter->second; |
| 147 |
| 148 channel->ViewResized(command_buffer_route_id); |
| 149 } |
| 150 |
139 void GpuChannelManager::LoseAllContexts() { | 151 void GpuChannelManager::LoseAllContexts() { |
140 MessageLoop::current()->PostTask( | 152 MessageLoop::current()->PostTask( |
141 FROM_HERE, | 153 FROM_HERE, |
142 base::Bind(&GpuChannelManager::OnLoseAllContexts, | 154 base::Bind(&GpuChannelManager::OnLoseAllContexts, |
143 weak_factory_.GetWeakPtr())); | 155 weak_factory_.GetWeakPtr())); |
144 } | 156 } |
145 | 157 |
146 void GpuChannelManager::OnLoseAllContexts() { | 158 void GpuChannelManager::OnLoseAllContexts() { |
147 gpu_channels_.clear(); | 159 gpu_channels_.clear(); |
148 } | 160 } |
OLD | NEW |