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 <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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 io_task_runner_(io_task_runner), | 53 io_task_runner_(io_task_runner), |
54 channel_(channel), | 54 channel_(channel), |
55 watchdog_(watchdog), | 55 watchdog_(watchdog), |
56 shutdown_event_(shutdown_event), | 56 shutdown_event_(shutdown_event), |
57 share_group_(new gfx::GLShareGroup), | 57 share_group_(new gfx::GLShareGroup), |
58 mailbox_manager_(gpu::gles2::MailboxManager::Create()), | 58 mailbox_manager_(gpu::gles2::MailboxManager::Create()), |
59 gpu_memory_manager_( | 59 gpu_memory_manager_( |
60 this, | 60 this, |
61 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit), | 61 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit), |
62 sync_point_manager_(sync_point_manager), | 62 sync_point_manager_(sync_point_manager), |
| 63 sync_point_client_waiter_(new gpu::SyncPointClientWaiter), |
63 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), | 64 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), |
64 weak_factory_(this) { | 65 weak_factory_(this) { |
65 DCHECK(task_runner); | 66 DCHECK(task_runner); |
66 DCHECK(io_task_runner); | 67 DCHECK(io_task_runner); |
67 const base::CommandLine* command_line = | 68 const base::CommandLine* command_line = |
68 base::CommandLine::ForCurrentProcess(); | 69 base::CommandLine::ForCurrentProcess(); |
69 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess)) | 70 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess)) |
70 preemption_flag_ = new gpu::PreemptionFlag; | 71 preemption_flag_ = new gpu::PreemptionFlag; |
71 } | 72 } |
72 | 73 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 221 |
221 void GpuChannelManager::DestroyGpuMemoryBufferOnIO( | 222 void GpuChannelManager::DestroyGpuMemoryBufferOnIO( |
222 gfx::GpuMemoryBufferId id, | 223 gfx::GpuMemoryBufferId id, |
223 int client_id) { | 224 int client_id) { |
224 gpu_memory_buffer_factory_->DestroyGpuMemoryBuffer(id, client_id); | 225 gpu_memory_buffer_factory_->DestroyGpuMemoryBuffer(id, client_id); |
225 } | 226 } |
226 | 227 |
227 void GpuChannelManager::OnDestroyGpuMemoryBuffer( | 228 void GpuChannelManager::OnDestroyGpuMemoryBuffer( |
228 gfx::GpuMemoryBufferId id, | 229 gfx::GpuMemoryBufferId id, |
229 int client_id, | 230 int client_id, |
230 int32 sync_point) { | 231 const gpu::SyncToken& sync_token) { |
231 if (!sync_point) { | 232 if (sync_token.HasData()) { |
232 DestroyGpuMemoryBuffer(id, client_id); | 233 scoped_refptr<gpu::SyncPointClientState> release_state = |
233 } else { | 234 sync_point_manager()->GetSyncPointClientState( |
234 sync_point_manager()->AddSyncPointCallback( | 235 sync_token.namespace_id(), sync_token.command_buffer_id()); |
235 sync_point, | 236 if (release_state) { |
236 base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, | 237 sync_point_client_waiter_->Wait( |
237 base::Unretained(this), | 238 release_state.get(), sync_token.release_count(), |
238 id, | 239 base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, |
239 client_id)); | 240 base::Unretained(this), id, client_id)); |
| 241 return; |
| 242 } |
240 } | 243 } |
| 244 |
| 245 // No sync token or invalid sync token, destroy immediately. |
| 246 DestroyGpuMemoryBuffer(id, client_id); |
241 } | 247 } |
242 | 248 |
243 void GpuChannelManager::OnUpdateValueState( | 249 void GpuChannelManager::OnUpdateValueState( |
244 int client_id, unsigned int target, const gpu::ValueState& state) { | 250 int client_id, unsigned int target, const gpu::ValueState& state) { |
245 // Only pass updated state to the channel corresponding to the | 251 // Only pass updated state to the channel corresponding to the |
246 // render_widget_host where the event originated. | 252 // render_widget_host where the event originated. |
247 auto it = gpu_channels_.find(client_id); | 253 auto it = gpu_channels_.find(client_id); |
248 if (it != gpu_channels_.end()) | 254 if (it != gpu_channels_.end()) |
249 it->second->HandleUpdateValueState(target, state); | 255 it->second->HandleUpdateValueState(target, state); |
250 } | 256 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 } | 340 } |
335 } | 341 } |
336 if (!stub || !stub->decoder()->MakeCurrent()) | 342 if (!stub || !stub->decoder()->MakeCurrent()) |
337 return; | 343 return; |
338 glFinish(); | 344 glFinish(); |
339 DidAccessGpu(); | 345 DidAccessGpu(); |
340 } | 346 } |
341 #endif | 347 #endif |
342 | 348 |
343 } // namespace content | 349 } // namespace content |
OLD | NEW |