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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 return NULL; | 43 return NULL; |
44 | 44 |
45 return new ContextProviderCommandBuffer(context3d.Pass(), debug_name); | 45 return new ContextProviderCommandBuffer(context3d.Pass(), debug_name); |
46 } | 46 } |
47 | 47 |
48 ContextProviderCommandBuffer::ContextProviderCommandBuffer( | 48 ContextProviderCommandBuffer::ContextProviderCommandBuffer( |
49 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, | 49 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, |
50 const std::string& debug_name) | 50 const std::string& debug_name) |
51 : context3d_(context3d.Pass()), | 51 : context3d_(context3d.Pass()), |
52 debug_name_(debug_name), | 52 debug_name_(debug_name), |
53 leak_on_destroy_(false), | |
54 destroyed_(false) { | 53 destroyed_(false) { |
55 DCHECK(main_thread_checker_.CalledOnValidThread()); | 54 DCHECK(main_thread_checker_.CalledOnValidThread()); |
56 DCHECK(context3d_); | 55 DCHECK(context3d_); |
57 context_thread_checker_.DetachFromThread(); | 56 context_thread_checker_.DetachFromThread(); |
58 } | 57 } |
59 | 58 |
60 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() { | 59 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() { |
61 DCHECK(main_thread_checker_.CalledOnValidThread() || | 60 DCHECK(main_thread_checker_.CalledOnValidThread() || |
62 context_thread_checker_.CalledOnValidThread()); | 61 context_thread_checker_.CalledOnValidThread()); |
63 | 62 |
64 base::AutoLock lock(main_thread_lock_); | 63 base::AutoLock lock(main_thread_lock_); |
65 | 64 |
66 // Destroy references to the context3d_ before leaking it. | 65 // Destroy references to the context3d_ before leaking it. |
67 if (context3d_->GetCommandBufferProxy()) { | 66 if (context3d_->GetCommandBufferProxy()) { |
68 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( | 67 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( |
69 CommandBufferProxyImpl::MemoryAllocationChangedCallback()); | 68 CommandBufferProxyImpl::MemoryAllocationChangedCallback()); |
70 } | 69 } |
71 lost_context_callback_proxy_.reset(); | 70 lost_context_callback_proxy_.reset(); |
72 | |
73 if (leak_on_destroy_) { | |
74 WebGraphicsContext3DCommandBufferImpl* context3d ALLOW_UNUSED = | |
75 context3d_.release(); | |
76 webkit::gpu::GrContextForWebGraphicsContext3D* gr_context ALLOW_UNUSED = | |
77 gr_context_.release(); | |
78 } | |
79 } | 71 } |
80 | 72 |
81 | 73 |
82 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() { | 74 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() { |
83 return context3d_->GetCommandBufferProxy(); | 75 return context3d_->GetCommandBufferProxy(); |
84 } | 76 } |
85 | 77 |
86 WebGraphicsContext3DCommandBufferImpl* | 78 WebGraphicsContext3DCommandBufferImpl* |
87 ContextProviderCommandBuffer::WebContext3D() { | 79 ContextProviderCommandBuffer::WebContext3D() { |
88 DCHECK(context3d_); | 80 DCHECK(context3d_); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 213 |
222 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( | 214 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( |
223 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 215 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
224 DCHECK(context_thread_checker_.CalledOnValidThread()); | 216 DCHECK(context_thread_checker_.CalledOnValidThread()); |
225 DCHECK(memory_policy_changed_callback_.is_null() || | 217 DCHECK(memory_policy_changed_callback_.is_null() || |
226 memory_policy_changed_callback.is_null()); | 218 memory_policy_changed_callback.is_null()); |
227 memory_policy_changed_callback_ = memory_policy_changed_callback; | 219 memory_policy_changed_callback_ = memory_policy_changed_callback; |
228 } | 220 } |
229 | 221 |
230 } // namespace content | 222 } // namespace content |
OLD | NEW |