| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 175 } |
| 176 | 176 |
| 177 void ContextProviderCommandBuffer::DeleteCachedResources() { | 177 void ContextProviderCommandBuffer::DeleteCachedResources() { |
| 178 DCHECK(context_thread_checker_.CalledOnValidThread()); | 178 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 179 | 179 |
| 180 if (gr_context_) | 180 if (gr_context_) |
| 181 gr_context_->FreeGpuResources(); | 181 gr_context_->FreeGpuResources(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void ContextProviderCommandBuffer::OnLostContext() { | 184 void ContextProviderCommandBuffer::OnLostContext() { |
| 185 DCHECK(context_thread_checker_.CalledOnValidThread()); | 185 // Note: no thread check here as this should not change the thread for which |
| 186 // this context is currently bound. e.g. a worker context might be unbound |
| 187 // and this should not result in it being bound to the current thread. |
| 186 { | 188 { |
| 187 base::AutoLock lock(main_thread_lock_); | 189 base::AutoLock lock(main_thread_lock_); |
| 188 if (destroyed_) | 190 if (destroyed_) |
| 189 return; | 191 return; |
| 190 destroyed_ = true; | 192 destroyed_ = true; |
| 191 } | 193 } |
| 192 if (!lost_context_callback_.is_null()) | 194 if (!lost_context_callback_.is_null()) |
| 193 base::ResetAndReturn(&lost_context_callback_).Run(); | 195 base::ResetAndReturn(&lost_context_callback_).Run(); |
| 194 if (gr_context_) | 196 if (gr_context_) |
| 195 gr_context_->OnLostContext(); | 197 gr_context_->OnLostContext(); |
| 196 } | 198 } |
| 197 | 199 |
| 198 void ContextProviderCommandBuffer::OnMemoryAllocationChanged( | 200 void ContextProviderCommandBuffer::OnMemoryAllocationChanged( |
| 199 const gpu::MemoryAllocation& allocation) { | 201 const gpu::MemoryAllocation& allocation) { |
| 200 DCHECK(context_thread_checker_.CalledOnValidThread()); | 202 // Note: no thread check here as this should not change the thread for which |
| 201 | 203 // this context is currently bound. e.g. a worker context might be unbound |
| 204 // and this should not result in it being bound to the current thread. |
| 202 if (memory_policy_changed_callback_.is_null()) | 205 if (memory_policy_changed_callback_.is_null()) |
| 203 return; | 206 return; |
| 204 | 207 |
| 205 memory_policy_changed_callback_.Run(cc::ManagedMemoryPolicy(allocation)); | 208 memory_policy_changed_callback_.Run(cc::ManagedMemoryPolicy(allocation)); |
| 206 } | 209 } |
| 207 | 210 |
| 208 void ContextProviderCommandBuffer::InitializeCapabilities() { | 211 void ContextProviderCommandBuffer::InitializeCapabilities() { |
| 209 Capabilities caps; | 212 Capabilities caps; |
| 210 caps.gpu = context3d_->GetImplementation()->capabilities(); | 213 caps.gpu = context3d_->GetImplementation()->capabilities(); |
| 211 | 214 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 241 | 244 |
| 242 if (!memory_policy_changed_callback_.is_null()) { | 245 if (!memory_policy_changed_callback_.is_null()) { |
| 243 DCHECK(context3d_->GetCommandBufferProxy()); | 246 DCHECK(context3d_->GetCommandBufferProxy()); |
| 244 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( | 247 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( |
| 245 base::Bind(&ContextProviderCommandBuffer::OnMemoryAllocationChanged, | 248 base::Bind(&ContextProviderCommandBuffer::OnMemoryAllocationChanged, |
| 246 base::Unretained(this))); | 249 base::Unretained(this))); |
| 247 } | 250 } |
| 248 } | 251 } |
| 249 | 252 |
| 250 } // namespace content | 253 } // namespace content |
| OLD | NEW |