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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 attributes.depth_size = -1; | 49 attributes.depth_size = -1; |
50 attributes.samples = 0; | 50 attributes.samples = 0; |
51 attributes.sample_buffers = 0; | 51 attributes.sample_buffers = 0; |
52 attributes.bind_generates_resource = false; | 52 attributes.bind_generates_resource = false; |
53 context_.reset(gpu::GLInProcessContext::Create( | 53 context_.reset(gpu::GLInProcessContext::Create( |
54 service, surface, surface->IsOffscreen(), gfx::kNullAcceleratedWidget, | 54 service, surface, surface->IsOffscreen(), gfx::kNullAcceleratedWidget, |
55 surface->GetSize(), nullptr /* share_context */, attributes, | 55 surface->GetSize(), nullptr /* share_context */, attributes, |
56 gfx::PreferDiscreteGpu, gpu::GLInProcessContextSharedMemoryLimits(), | 56 gfx::PreferDiscreteGpu, gpu::GLInProcessContextSharedMemoryLimits(), |
57 nullptr, nullptr)); | 57 nullptr, nullptr)); |
58 | 58 |
59 context_->SetContextLostCallback(base::Bind( | 59 context_->GetImplementation()->SetLostContextCallback(base::Bind( |
60 &AwRenderThreadContextProvider::OnLostContext, base::Unretained(this))); | 60 &AwRenderThreadContextProvider::OnLostContext, base::Unretained(this))); |
61 | 61 |
62 capabilities_.gpu = context_->GetImplementation()->capabilities(); | 62 capabilities_.gpu = context_->GetImplementation()->capabilities(); |
63 } | 63 } |
64 | 64 |
65 AwRenderThreadContextProvider::~AwRenderThreadContextProvider() { | 65 AwRenderThreadContextProvider::~AwRenderThreadContextProvider() { |
66 DCHECK(main_thread_checker_.CalledOnValidThread()); | 66 DCHECK(main_thread_checker_.CalledOnValidThread()); |
67 if (gr_context_) | 67 if (gr_context_) |
68 gr_context_->releaseResourcesAndAbandonContext(); | 68 gr_context_->releaseResourcesAndAbandonContext(); |
69 } | 69 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 void AwRenderThreadContextProvider::SetLostContextCallback( | 139 void AwRenderThreadContextProvider::SetLostContextCallback( |
140 const LostContextCallback& lost_context_callback) { | 140 const LostContextCallback& lost_context_callback) { |
141 lost_context_callback_ = lost_context_callback; | 141 lost_context_callback_ = lost_context_callback; |
142 } | 142 } |
143 | 143 |
144 void AwRenderThreadContextProvider::OnLostContext() { | 144 void AwRenderThreadContextProvider::OnLostContext() { |
145 DCHECK(main_thread_checker_.CalledOnValidThread()); | 145 DCHECK(main_thread_checker_.CalledOnValidThread()); |
146 | 146 |
147 if (!lost_context_callback_.is_null()) | 147 if (!lost_context_callback_.is_null()) |
148 base::ResetAndReturn(&lost_context_callback_).Run(); | 148 lost_context_callback_.Run(); |
149 if (gr_context_) | 149 if (gr_context_) |
150 gr_context_->abandonContext(); | 150 gr_context_->abandonContext(); |
151 } | 151 } |
152 | 152 |
153 } // namespace android_webview | 153 } // namespace android_webview |
OLD | NEW |