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 <stddef.h> | 7 #include <stddef.h> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 DCHECK(context_thread_checker_.CalledOnValidThread()); | 166 DCHECK(context_thread_checker_.CalledOnValidThread()); |
167 | 167 |
168 if (gr_context_) | 168 if (gr_context_) |
169 gr_context_->FreeGpuResources(); | 169 gr_context_->FreeGpuResources(); |
170 } | 170 } |
171 | 171 |
172 void ContextProviderCommandBuffer::OnLostContext() { | 172 void ContextProviderCommandBuffer::OnLostContext() { |
173 DCHECK(context_thread_checker_.CalledOnValidThread()); | 173 DCHECK(context_thread_checker_.CalledOnValidThread()); |
174 | 174 |
175 if (!lost_context_callback_.is_null()) | 175 if (!lost_context_callback_.is_null()) |
176 lost_context_callback_.Run(); | 176 base::ResetAndReturn(&lost_context_callback_).Run(); |
177 if (gr_context_) | 177 if (gr_context_) |
178 gr_context_->OnLostContext(); | 178 gr_context_->OnLostContext(); |
179 } | 179 } |
180 | 180 |
181 void ContextProviderCommandBuffer::InitializeCapabilities() { | 181 void ContextProviderCommandBuffer::InitializeCapabilities() { |
182 Capabilities caps; | 182 Capabilities caps; |
183 caps.gpu = context3d_->GetImplementation()->capabilities(); | 183 caps.gpu = context3d_->GetImplementation()->capabilities(); |
184 | 184 |
185 size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit(); | 185 size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit(); |
186 caps.max_transfer_buffer_usage_bytes = | 186 caps.max_transfer_buffer_usage_bytes = |
187 mapped_memory_limit == WebGraphicsContext3DCommandBufferImpl::kNoLimit | 187 mapped_memory_limit == WebGraphicsContext3DCommandBufferImpl::kNoLimit |
188 ? std::numeric_limits<size_t>::max() : mapped_memory_limit; | 188 ? std::numeric_limits<size_t>::max() : mapped_memory_limit; |
189 | 189 |
190 capabilities_ = caps; | 190 capabilities_ = caps; |
191 } | 191 } |
192 | 192 |
193 void ContextProviderCommandBuffer::SetLostContextCallback( | 193 void ContextProviderCommandBuffer::SetLostContextCallback( |
194 const LostContextCallback& lost_context_callback) { | 194 const LostContextCallback& lost_context_callback) { |
195 DCHECK(context_thread_checker_.CalledOnValidThread()); | 195 DCHECK(context_thread_checker_.CalledOnValidThread()); |
196 DCHECK(lost_context_callback_.is_null() || | 196 DCHECK(lost_context_callback_.is_null() || |
197 lost_context_callback.is_null()); | 197 lost_context_callback.is_null()); |
198 lost_context_callback_ = lost_context_callback; | 198 lost_context_callback_ = lost_context_callback; |
199 } | 199 } |
200 | 200 |
201 } // namespace content | 201 } // namespace content |
OLD | NEW |