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