OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/context_provider_command_buffer.h" | 5 #include "content/common/gpu/client/context_provider_command_buffer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 178 } |
179 | 179 |
180 void ContextProviderCommandBuffer::DeleteCachedResources() { | 180 void ContextProviderCommandBuffer::DeleteCachedResources() { |
181 DCHECK(context_thread_checker_.CalledOnValidThread()); | 181 DCHECK(context_thread_checker_.CalledOnValidThread()); |
182 | 182 |
183 if (gr_context_) | 183 if (gr_context_) |
184 gr_context_->FreeGpuResources(); | 184 gr_context_->FreeGpuResources(); |
185 } | 185 } |
186 | 186 |
187 void ContextProviderCommandBuffer::OnLostContext() { | 187 void ContextProviderCommandBuffer::OnLostContext() { |
| 188 base::AutoLock lock(context_lock_); |
| 189 |
188 DCHECK(context_thread_checker_.CalledOnValidThread()); | 190 DCHECK(context_thread_checker_.CalledOnValidThread()); |
189 { | 191 { |
190 base::AutoLock lock(main_thread_lock_); | 192 base::AutoLock lock(main_thread_lock_); |
191 if (destroyed_) | 193 if (destroyed_) |
192 return; | 194 return; |
193 destroyed_ = true; | 195 destroyed_ = true; |
194 } | 196 } |
195 if (!lost_context_callback_.is_null()) | 197 if (!lost_context_callback_.is_null()) |
196 base::ResetAndReturn(&lost_context_callback_).Run(); | 198 base::ResetAndReturn(&lost_context_callback_).Run(); |
197 if (gr_context_) | 199 if (gr_context_) |
198 gr_context_->OnLostContext(); | 200 gr_context_->OnLostContext(); |
199 } | 201 } |
200 | 202 |
201 void ContextProviderCommandBuffer::OnMemoryAllocationChanged( | 203 void ContextProviderCommandBuffer::OnMemoryAllocationChanged( |
202 const gpu::MemoryAllocation& allocation) { | 204 const gpu::MemoryAllocation& allocation) { |
| 205 base::AutoLock lock(context_lock_); |
| 206 |
203 DCHECK(context_thread_checker_.CalledOnValidThread()); | 207 DCHECK(context_thread_checker_.CalledOnValidThread()); |
204 | 208 |
205 if (memory_policy_changed_callback_.is_null()) | 209 if (memory_policy_changed_callback_.is_null()) |
206 return; | 210 return; |
207 | 211 |
208 memory_policy_changed_callback_.Run(cc::ManagedMemoryPolicy(allocation)); | 212 memory_policy_changed_callback_.Run(cc::ManagedMemoryPolicy(allocation)); |
209 } | 213 } |
210 | 214 |
211 void ContextProviderCommandBuffer::InitializeCapabilities() { | 215 void ContextProviderCommandBuffer::InitializeCapabilities() { |
212 Capabilities caps; | 216 Capabilities caps; |
(...skipping 24 matching lines...) Expand all Loading... |
237 | 241 |
238 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( | 242 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( |
239 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 243 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
240 DCHECK(context_thread_checker_.CalledOnValidThread()); | 244 DCHECK(context_thread_checker_.CalledOnValidThread()); |
241 DCHECK(memory_policy_changed_callback_.is_null() || | 245 DCHECK(memory_policy_changed_callback_.is_null() || |
242 memory_policy_changed_callback.is_null()); | 246 memory_policy_changed_callback.is_null()); |
243 memory_policy_changed_callback_ = memory_policy_changed_callback; | 247 memory_policy_changed_callback_ = memory_policy_changed_callback; |
244 } | 248 } |
245 | 249 |
246 } // namespace content | 250 } // namespace content |
OLD | NEW |