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/client/command_buffer_proxy_impl.h" | 5 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 | 142 |
143 // This handle is owned by the GPU process and must be passed to it or it | 143 // This handle is owned by the GPU process and must be passed to it or it |
144 // will leak. In otherwords, do not early out on error between here and the | 144 // will leak. In otherwords, do not early out on error between here and the |
145 // sending of the Initialize IPC below. | 145 // sending of the Initialize IPC below. |
146 base::SharedMemoryHandle handle = | 146 base::SharedMemoryHandle handle = |
147 channel_->ShareToGpuProcess(shared_state_shm_.get()); | 147 channel_->ShareToGpuProcess(shared_state_shm_.get()); |
148 if (!base::SharedMemory::IsHandleValid(handle)) | 148 if (!base::SharedMemory::IsHandleValid(handle)) |
149 return false; | 149 return false; |
150 | 150 |
151 bool result; | 151 bool result; |
152 if (!Send(new GpuCommandBufferMsg_Initialize(route_id_, handle, &result))) { | 152 { |
153 LOG(ERROR) << "Could not send GpuCommandBufferMsg_Initialize."; | 153 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
154 return false; | 154 if (!Send(new GpuCommandBufferMsg_Initialize(route_id_, handle, &result))) { |
boliu
2013/03/01 00:19:12
handler does not need DELAYED_RESPONSE, so should
| |
155 LOG(ERROR) << "Could not send GpuCommandBufferMsg_Initialize."; | |
156 return false; | |
157 } | |
155 } | 158 } |
156 | 159 |
157 if (!result) { | 160 if (!result) { |
158 LOG(ERROR) << "Failed to initialize command buffer service."; | 161 LOG(ERROR) << "Failed to initialize command buffer service."; |
159 return false; | 162 return false; |
160 } | 163 } |
161 | 164 |
162 return true; | 165 return true; |
163 } | 166 } |
164 | 167 |
165 gpu::CommandBuffer::State CommandBufferProxyImpl::GetState() { | 168 gpu::CommandBuffer::State CommandBufferProxyImpl::GetState() { |
166 // Send will flag state with lost context if IPC fails. | 169 // Send will flag state with lost context if IPC fails. |
167 if (last_state_.error == gpu::error::kNoError) { | 170 if (last_state_.error == gpu::error::kNoError) { |
168 gpu::CommandBuffer::State state; | 171 gpu::CommandBuffer::State state; |
169 if (Send(new GpuCommandBufferMsg_GetState(route_id_, &state))) | 172 { |
170 OnUpdateState(state); | 173 // Seems fine. |
174 base::ThreadRestrictions::ScopedAllowWait allow_wait; | |
175 if (Send(new GpuCommandBufferMsg_GetState(route_id_, &state))) | |
boliu
2013/03/01 00:19:12
Again doesn't really need DELAYED_RESPONSE except
| |
176 OnUpdateState(state); | |
177 } | |
171 } | 178 } |
172 | 179 |
173 TryUpdateState(); | 180 TryUpdateState(); |
174 return last_state_; | 181 return last_state_; |
175 } | 182 } |
176 | 183 |
177 gpu::CommandBuffer::State CommandBufferProxyImpl::GetLastState() { | 184 gpu::CommandBuffer::State CommandBufferProxyImpl::GetLastState() { |
178 return last_state_; | 185 return last_state_; |
179 } | 186 } |
180 | 187 |
(...skipping 25 matching lines...) Expand all Loading... | |
206 int32 put_offset, | 213 int32 put_offset, |
207 int32 last_known_get) { | 214 int32 last_known_get) { |
208 TRACE_EVENT1("gpu", "CommandBufferProxyImpl::FlushSync", "put_offset", | 215 TRACE_EVENT1("gpu", "CommandBufferProxyImpl::FlushSync", "put_offset", |
209 put_offset); | 216 put_offset); |
210 Flush(put_offset); | 217 Flush(put_offset); |
211 TryUpdateState(); | 218 TryUpdateState(); |
212 if (last_known_get == last_state_.get_offset) { | 219 if (last_known_get == last_state_.get_offset) { |
213 // Send will flag state with lost context if IPC fails. | 220 // Send will flag state with lost context if IPC fails. |
214 if (last_state_.error == gpu::error::kNoError) { | 221 if (last_state_.error == gpu::error::kNoError) { |
215 gpu::CommandBuffer::State state; | 222 gpu::CommandBuffer::State state; |
216 if (Send(new GpuCommandBufferMsg_GetStateFast(route_id_, | 223 { |
217 &state))) | 224 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
218 OnUpdateState(state); | 225 if (Send(new GpuCommandBufferMsg_GetStateFast(route_id_, |
boliu
2013/03/01 00:19:12
I changed handler to not use DELAYED_RESPONSE
| |
226 &state))) | |
227 OnUpdateState(state); | |
228 } | |
219 } | 229 } |
220 TryUpdateState(); | 230 TryUpdateState(); |
221 } | 231 } |
222 | 232 |
223 return last_state_; | 233 return last_state_; |
224 } | 234 } |
225 | 235 |
226 void CommandBufferProxyImpl::SetGetBuffer(int32 shm_id) { | 236 void CommandBufferProxyImpl::SetGetBuffer(int32 shm_id) { |
227 if (last_state_.error != gpu::error::kNoError) | 237 if (last_state_.error != gpu::error::kNoError) |
228 return; | 238 return; |
229 | 239 |
230 Send(new GpuCommandBufferMsg_SetGetBuffer(route_id_, shm_id)); | 240 { |
241 // Seems safe, direct reply. | |
242 base::ThreadRestrictions::ScopedAllowWait allow_wait; | |
243 Send(new GpuCommandBufferMsg_SetGetBuffer(route_id_, shm_id)); | |
boliu
2013/03/01 00:19:12
Changed handler to not use DELAYED_RESPONSE
| |
244 } | |
231 last_put_offset_ = -1; | 245 last_put_offset_ = -1; |
232 } | 246 } |
233 | 247 |
234 void CommandBufferProxyImpl::SetGetOffset(int32 get_offset) { | 248 void CommandBufferProxyImpl::SetGetOffset(int32 get_offset) { |
235 // Not implemented in proxy. | 249 // Not implemented in proxy. |
236 NOTREACHED(); | 250 NOTREACHED(); |
237 } | 251 } |
238 | 252 |
239 gpu::Buffer CommandBufferProxyImpl::CreateTransferBuffer(size_t size, | 253 gpu::Buffer CommandBufferProxyImpl::CreateTransferBuffer(size_t size, |
240 int32* id) { | 254 int32* id) { |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 void CommandBufferProxyImpl::SendManagedMemoryStats( | 539 void CommandBufferProxyImpl::SendManagedMemoryStats( |
526 const GpuManagedMemoryStats& stats) { | 540 const GpuManagedMemoryStats& stats) { |
527 if (last_state_.error != gpu::error::kNoError) | 541 if (last_state_.error != gpu::error::kNoError) |
528 return; | 542 return; |
529 | 543 |
530 Send(new GpuCommandBufferMsg_SendClientManagedMemoryStats(route_id_, | 544 Send(new GpuCommandBufferMsg_SendClientManagedMemoryStats(route_id_, |
531 stats)); | 545 stats)); |
532 } | 546 } |
533 | 547 |
534 } // namespace content | 548 } // namespace content |
OLD | NEW |