| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 131 } |
| 132 | 132 |
| 133 void AwRenderThreadContextProvider::DeleteCachedResources() { | 133 void AwRenderThreadContextProvider::DeleteCachedResources() { |
| 134 DCHECK(main_thread_checker_.CalledOnValidThread()); | 134 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 135 | 135 |
| 136 if (gr_context_) { | 136 if (gr_context_) { |
| 137 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", | 137 TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", |
| 138 TRACE_EVENT_SCOPE_THREAD); | 138 TRACE_EVENT_SCOPE_THREAD); |
| 139 gr_context_->freeGpuResources(); | 139 gr_context_->freeGpuResources(); |
| 140 } | 140 } |
| 141 |
| 142 ContextSupport()->TrimResources(); |
| 141 } | 143 } |
| 142 | 144 |
| 143 void AwRenderThreadContextProvider::SetLostContextCallback( | 145 void AwRenderThreadContextProvider::SetLostContextCallback( |
| 144 const LostContextCallback& lost_context_callback) { | 146 const LostContextCallback& lost_context_callback) { |
| 145 lost_context_callback_ = lost_context_callback; | 147 lost_context_callback_ = lost_context_callback; |
| 146 } | 148 } |
| 147 | 149 |
| 148 void AwRenderThreadContextProvider::OnLostContext() { | 150 void AwRenderThreadContextProvider::OnLostContext() { |
| 149 DCHECK(main_thread_checker_.CalledOnValidThread()); | 151 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 150 | 152 |
| 151 if (!lost_context_callback_.is_null()) | 153 if (!lost_context_callback_.is_null()) |
| 152 lost_context_callback_.Run(); | 154 lost_context_callback_.Run(); |
| 153 if (gr_context_) | 155 if (gr_context_) |
| 154 gr_context_->abandonContext(); | 156 gr_context_->abandonContext(); |
| 155 } | 157 } |
| 156 | 158 |
| 157 } // namespace android_webview | 159 } // namespace android_webview |
| OLD | NEW |