OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/renderer/gpu_channel_host.h" | 5 #include "chrome/renderer/gpu_channel_host.h" |
6 | 6 |
7 #include "chrome/common/child_process.h" | 7 #include "chrome/common/child_process.h" |
8 #include "chrome/common/gpu_create_command_buffer_config.h" | 8 #include "chrome/common/gpu_create_command_buffer_config.h" |
9 #include "chrome/common/gpu_messages.h" | 9 #include "chrome/common/gpu_messages.h" |
10 #include "chrome/renderer/command_buffer_proxy.h" | 10 #include "chrome/renderer/command_buffer_proxy.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 int render_view_id, | 90 int render_view_id, |
91 const std::string& allowed_extensions, | 91 const std::string& allowed_extensions, |
92 const std::vector<int32>& attribs) { | 92 const std::vector<int32>& attribs) { |
93 #if defined(ENABLE_GPU) | 93 #if defined(ENABLE_GPU) |
94 // An error occurred. Need to get the host again to reinitialize it. | 94 // An error occurred. Need to get the host again to reinitialize it. |
95 if (!channel_.get()) | 95 if (!channel_.get()) |
96 return NULL; | 96 return NULL; |
97 | 97 |
98 GPUCreateCommandBufferConfig init_params(allowed_extensions, attribs); | 98 GPUCreateCommandBufferConfig init_params(allowed_extensions, attribs); |
99 int32 route_id; | 99 int32 route_id; |
100 if (!Send(new GpuChannelMsg_CreateViewCommandBuffer( | 100 if (!Send(new GpuChannelMsg_CreateViewCommandBuffer(view, |
101 view, | 101 render_view_id, |
102 render_view_id, | 102 init_params, |
103 init_params, | 103 &route_id))) { |
104 &route_id)) && | |
105 route_id != MSG_ROUTING_NONE) { | |
106 return NULL; | 104 return NULL; |
107 } | 105 } |
108 | 106 |
| 107 if (route_id == MSG_ROUTING_NONE) |
| 108 return NULL; |
| 109 |
109 CommandBufferProxy* command_buffer = new CommandBufferProxy(this, route_id); | 110 CommandBufferProxy* command_buffer = new CommandBufferProxy(this, route_id); |
110 router_.AddRoute(route_id, command_buffer); | 111 router_.AddRoute(route_id, command_buffer); |
111 proxies_[route_id] = command_buffer; | 112 proxies_[route_id] = command_buffer; |
112 return command_buffer; | 113 return command_buffer; |
113 #else | 114 #else |
114 return NULL; | 115 return NULL; |
115 #endif | 116 #endif |
116 } | 117 } |
117 | 118 |
118 CommandBufferProxy* GpuChannelHost::CreateOffscreenCommandBuffer( | 119 CommandBufferProxy* GpuChannelHost::CreateOffscreenCommandBuffer( |
119 CommandBufferProxy* parent, | 120 CommandBufferProxy* parent, |
120 const gfx::Size& size, | 121 const gfx::Size& size, |
121 const std::string& allowed_extensions, | 122 const std::string& allowed_extensions, |
122 const std::vector<int32>& attribs, | 123 const std::vector<int32>& attribs, |
123 uint32 parent_texture_id) { | 124 uint32 parent_texture_id) { |
124 #if defined(ENABLE_GPU) | 125 #if defined(ENABLE_GPU) |
125 // An error occurred. Need to get the host again to reinitialize it. | 126 // An error occurred. Need to get the host again to reinitialize it. |
126 if (!channel_.get()) | 127 if (!channel_.get()) |
127 return NULL; | 128 return NULL; |
128 | 129 |
129 GPUCreateCommandBufferConfig init_params(allowed_extensions, attribs); | 130 GPUCreateCommandBufferConfig init_params(allowed_extensions, attribs); |
130 int32 parent_route_id = parent ? parent->route_id() : 0; | 131 int32 parent_route_id = parent ? parent->route_id() : 0; |
131 int32 route_id; | 132 int32 route_id; |
132 if (!Send(new GpuChannelMsg_CreateOffscreenCommandBuffer(parent_route_id, | 133 if (!Send(new GpuChannelMsg_CreateOffscreenCommandBuffer(parent_route_id, |
133 size, | 134 size, |
134 init_params, | 135 init_params, |
135 parent_texture_id, | 136 parent_texture_id, |
136 &route_id)) && | 137 &route_id))) { |
137 route_id != MSG_ROUTING_NONE) { | |
138 return NULL; | 138 return NULL; |
139 } | 139 } |
140 | 140 |
| 141 if (route_id == MSG_ROUTING_NONE) |
| 142 return NULL; |
| 143 |
141 CommandBufferProxy* command_buffer = new CommandBufferProxy(this, route_id); | 144 CommandBufferProxy* command_buffer = new CommandBufferProxy(this, route_id); |
142 router_.AddRoute(route_id, command_buffer); | 145 router_.AddRoute(route_id, command_buffer); |
143 proxies_[route_id] = command_buffer; | 146 proxies_[route_id] = command_buffer; |
144 return command_buffer; | 147 return command_buffer; |
145 #else | 148 #else |
146 return NULL; | 149 return NULL; |
147 #endif | 150 #endif |
148 } | 151 } |
149 | 152 |
150 void GpuChannelHost::DestroyCommandBuffer(CommandBufferProxy* command_buffer) { | 153 void GpuChannelHost::DestroyCommandBuffer(CommandBufferProxy* command_buffer) { |
151 #if defined(ENABLE_GPU) | 154 #if defined(ENABLE_GPU) |
152 Send(new GpuChannelMsg_DestroyCommandBuffer(command_buffer->route_id())); | 155 Send(new GpuChannelMsg_DestroyCommandBuffer(command_buffer->route_id())); |
153 | 156 |
154 // Check the proxy has not already been removed after a channel error. | 157 // Check the proxy has not already been removed after a channel error. |
155 int route_id = command_buffer->route_id(); | 158 int route_id = command_buffer->route_id(); |
156 if (proxies_.find(command_buffer->route_id()) != proxies_.end()) { | 159 if (proxies_.find(command_buffer->route_id()) != proxies_.end()) { |
157 proxies_.erase(route_id); | 160 proxies_.erase(route_id); |
158 router_.RemoveRoute(route_id); | 161 router_.RemoveRoute(route_id); |
159 } | 162 } |
160 | 163 |
161 delete command_buffer; | 164 delete command_buffer; |
162 #endif | 165 #endif |
163 } | 166 } |
OLD | NEW |