| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "android_webview/browser/aw_render_thread_context_provider.h" | 5 #include "android_webview/browser/aw_render_thread_context_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 scoped_refptr<AwRenderThreadContextProvider> | 41 scoped_refptr<AwRenderThreadContextProvider> |
| 42 AwRenderThreadContextProvider::Create( | 42 AwRenderThreadContextProvider::Create( |
| 43 scoped_refptr<gfx::GLSurface> surface, | 43 scoped_refptr<gfx::GLSurface> surface, |
| 44 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { | 44 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { |
| 45 return new AwRenderThreadContextProvider(surface, service); | 45 return new AwRenderThreadContextProvider(surface, service); |
| 46 } | 46 } |
| 47 | 47 |
| 48 AwRenderThreadContextProvider::AwRenderThreadContextProvider( | 48 AwRenderThreadContextProvider::AwRenderThreadContextProvider( |
| 49 scoped_refptr<gfx::GLSurface> surface, | 49 scoped_refptr<gfx::GLSurface> surface, |
| 50 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) | 50 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) |
| 51 : destroyed_(false) { | 51 : lost_(false) { |
| 52 DCHECK(main_thread_checker_.CalledOnValidThread()); | 52 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 53 | 53 |
| 54 blink::WebGraphicsContext3D::Attributes attributes; | 54 blink::WebGraphicsContext3D::Attributes attributes; |
| 55 attributes.antialias = false; | 55 attributes.antialias = false; |
| 56 attributes.depth = false; | 56 attributes.depth = false; |
| 57 attributes.stencil = false; | 57 attributes.stencil = false; |
| 58 attributes.shareResources = true; | 58 attributes.shareResources = true; |
| 59 attributes.noAutomaticFlushes = true; | 59 attributes.noAutomaticFlushes = true; |
| 60 gpu::gles2::ContextCreationAttribHelper attribs_for_gles2; | 60 gpu::gles2::ContextCreationAttribHelper attribs_for_gles2; |
| 61 gpu_blink::WebGraphicsContext3DImpl::ConvertAttributes(attributes, | 61 gpu_blink::WebGraphicsContext3DImpl::ConvertAttributes(attributes, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 void AwRenderThreadContextProvider::DeleteCachedResources() { | 163 void AwRenderThreadContextProvider::DeleteCachedResources() { |
| 164 DCHECK(main_thread_checker_.CalledOnValidThread()); | 164 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 165 | 165 |
| 166 if (gr_context_) { | 166 if (gr_context_) { |
| 167 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", | 167 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", |
| 168 TRACE_EVENT_SCOPE_THREAD); | 168 TRACE_EVENT_SCOPE_THREAD); |
| 169 gr_context_->freeGpuResources(); | 169 gr_context_->freeGpuResources(); |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 | 172 |
| 173 bool AwRenderThreadContextProvider::DestroyedOnMainThread() { | 173 bool AwRenderThreadContextProvider::HasBeenLostOnMainThread() { |
| 174 DCHECK(main_thread_checker_.CalledOnValidThread()); | 174 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 175 | 175 |
| 176 return destroyed_; | 176 return lost_; |
| 177 } | 177 } |
| 178 | 178 |
| 179 void AwRenderThreadContextProvider::SetLostContextCallback( | 179 void AwRenderThreadContextProvider::SetLostContextCallback( |
| 180 const LostContextCallback& lost_context_callback) { | 180 const LostContextCallback& lost_context_callback) { |
| 181 lost_context_callback_ = lost_context_callback; | 181 lost_context_callback_ = lost_context_callback; |
| 182 } | 182 } |
| 183 | 183 |
| 184 void AwRenderThreadContextProvider::SetMemoryPolicyChangedCallback( | 184 void AwRenderThreadContextProvider::SetMemoryPolicyChangedCallback( |
| 185 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 185 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
| 186 // There's no memory manager for the in-process implementation. | 186 // There's no memory manager for the in-process implementation. |
| 187 } | 187 } |
| 188 | 188 |
| 189 void AwRenderThreadContextProvider::OnLostContext() { | 189 void AwRenderThreadContextProvider::OnLostContext() { |
| 190 DCHECK(main_thread_checker_.CalledOnValidThread()); | 190 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 191 | 191 |
| 192 if (destroyed_) | 192 if (lost_) |
| 193 return; | 193 return; |
| 194 destroyed_ = true; | 194 lost_ = true; |
| 195 | 195 |
| 196 if (!lost_context_callback_.is_null()) | 196 if (!lost_context_callback_.is_null()) |
| 197 base::ResetAndReturn(&lost_context_callback_).Run(); | 197 base::ResetAndReturn(&lost_context_callback_).Run(); |
| 198 if (gr_context_) | 198 if (gr_context_) |
| 199 gr_context_->abandonContext(); | 199 gr_context_->abandonContext(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 bool AwRenderThreadContextProvider::HasBeenDestroyed() { |
| 203 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 204 return false; |
| 205 } |
| 206 |
| 202 } // namespace android_webview | 207 } // namespace android_webview |
| OLD | NEW |