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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 context_thread_checker_.CalledOnValidThread()); | 61 context_thread_checker_.CalledOnValidThread()); |
62 | 62 |
63 // Destroy references to the context3d_ before leaking it. | 63 // Destroy references to the context3d_ before leaking it. |
64 if (WebContext3DNoChecks()->GetCommandBufferProxy()) | 64 if (WebContext3DNoChecks()->GetCommandBufferProxy()) |
65 WebContext3DNoChecks()->GetCommandBufferProxy()->SetLock(nullptr); | 65 WebContext3DNoChecks()->GetCommandBufferProxy()->SetLock(nullptr); |
66 lost_context_callback_proxy_.reset(); | 66 lost_context_callback_proxy_.reset(); |
67 } | 67 } |
68 | 68 |
69 | 69 |
70 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() { | 70 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() { |
71 return WebContext3D()->GetCommandBufferProxy(); | 71 return WebContext3DNoChecks()->GetCommandBufferProxy(); |
72 } | 72 } |
73 | 73 |
74 WebGraphicsContext3DCommandBufferImpl* | 74 WebGraphicsContext3DCommandBufferImpl* |
75 ContextProviderCommandBuffer::WebContext3D() { | 75 ContextProviderCommandBuffer::WebContext3D() { |
76 DCHECK(gr_interface_); | 76 DCHECK(gr_interface_); |
77 DCHECK(gr_interface_->WebContext3D()); | 77 DCHECK(gr_interface_->WebContext3D()); |
78 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 78 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
79 DCHECK(context_thread_checker_.CalledOnValidThread()); | 79 DCHECK(context_thread_checker_.CalledOnValidThread()); |
80 | 80 |
81 return WebContext3DNoChecks(); | 81 return WebContext3DNoChecks(); |
(...skipping 30 matching lines...) Expand all Loading... | |
112 return true; | 112 return true; |
113 } | 113 } |
114 | 114 |
115 void ContextProviderCommandBuffer::DetachFromThread() { | 115 void ContextProviderCommandBuffer::DetachFromThread() { |
116 context_thread_checker_.DetachFromThread(); | 116 context_thread_checker_.DetachFromThread(); |
117 } | 117 } |
118 | 118 |
119 gpu::gles2::GLES2Interface* ContextProviderCommandBuffer::ContextGL() { | 119 gpu::gles2::GLES2Interface* ContextProviderCommandBuffer::ContextGL() { |
120 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 120 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
121 | 121 |
122 return WebContext3DNoChecks()->GetImplementation(); | 122 return WebContext3D()->GetImplementation(); |
123 } | 123 } |
124 | 124 |
125 gpu::ContextSupport* ContextProviderCommandBuffer::ContextSupport() { | 125 gpu::ContextSupport* ContextProviderCommandBuffer::ContextSupport() { |
126 return WebContext3D()->GetContextSupport(); | 126 return WebContext3DNoChecks()->GetContextSupport(); |
127 } | 127 } |
128 | 128 |
129 class GrContext* ContextProviderCommandBuffer::GrContext() { | 129 class GrContext* ContextProviderCommandBuffer::GrContext() { |
130 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 130 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
131 DCHECK(context_thread_checker_.CalledOnValidThread()); | 131 DCHECK(context_thread_checker_.CalledOnValidThread()); |
132 | 132 |
133 if (gr_context_) | 133 if (gr_context_) |
134 return gr_context_->get(); | 134 return gr_context_->get(); |
135 | 135 |
136 gr_context_.reset(new GrContextForWebGraphicsContext3D(gr_interface_)); | 136 gr_context_.reset(new GrContextForWebGraphicsContext3D(gr_interface_)); |
137 | 137 |
138 // If GlContext is already lost, also abandon the new GrContext. | 138 // If GlContext is already lost, also abandon the new GrContext. |
139 if (gr_context_->get() && | 139 if (gr_context_->get() && |
140 ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) | 140 ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) |
141 gr_context_->get()->abandonContext(); | 141 gr_context_->get()->abandonContext(); |
142 | 142 |
143 return gr_context_->get(); | 143 return gr_context_->get(); |
144 } | 144 } |
145 | 145 |
146 void ContextProviderCommandBuffer::InvalidateGrContext(uint32_t state) { | 146 void ContextProviderCommandBuffer::InvalidateGrContext(uint32_t state) { |
147 if (gr_context_) { | 147 if (gr_context_) { |
148 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 148 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
149 DCHECK(context_thread_checker_.CalledOnValidThread()); | 149 DCHECK(context_thread_checker_.CalledOnValidThread()); |
150 gr_context_->get()->resetContext(state); | 150 gr_context_->get()->resetContext(state); |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 void ContextProviderCommandBuffer::SetupLock() { | 154 void ContextProviderCommandBuffer::SetupLock() { |
155 WebContext3D()->GetCommandBufferProxy()->SetLock(&context_lock_); | 155 WebContext3DNoChecks()->GetCommandBufferProxy()->SetLock(&context_lock_); |
piman
2015/11/20 04:54:35
I think this one should stay as WebContext3D(), be
| |
156 } | 156 } |
157 | 157 |
158 base::Lock* ContextProviderCommandBuffer::GetLock() { | 158 base::Lock* ContextProviderCommandBuffer::GetLock() { |
159 return &context_lock_; | 159 return &context_lock_; |
160 } | 160 } |
161 | 161 |
162 cc::ContextProvider::Capabilities | 162 cc::ContextProvider::Capabilities |
163 ContextProviderCommandBuffer::ContextCapabilities() { | 163 ContextProviderCommandBuffer::ContextCapabilities() { |
164 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 164 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
165 DCHECK(context_thread_checker_.CalledOnValidThread()); | 165 DCHECK(context_thread_checker_.CalledOnValidThread()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 | 197 |
198 void ContextProviderCommandBuffer::SetLostContextCallback( | 198 void ContextProviderCommandBuffer::SetLostContextCallback( |
199 const LostContextCallback& lost_context_callback) { | 199 const LostContextCallback& lost_context_callback) { |
200 DCHECK(context_thread_checker_.CalledOnValidThread()); | 200 DCHECK(context_thread_checker_.CalledOnValidThread()); |
201 DCHECK(lost_context_callback_.is_null() || | 201 DCHECK(lost_context_callback_.is_null() || |
202 lost_context_callback.is_null()); | 202 lost_context_callback.is_null()); |
203 lost_context_callback_ = lost_context_callback; | 203 lost_context_callback_ = lost_context_callback; |
204 } | 204 } |
205 | 205 |
206 } // namespace content | 206 } // namespace content |
OLD | NEW |