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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 DCHECK(main_thread_checker_.CalledOnValidThread()); | 123 DCHECK(main_thread_checker_.CalledOnValidThread()); |
124 | 124 |
125 if (gr_context_) | 125 if (gr_context_) |
126 return gr_context_.get(); | 126 return gr_context_.get(); |
127 | 127 |
128 // The GrGLInterface factory will make GL calls using the C GLES2 interface. | 128 // The GrGLInterface factory will make GL calls using the C GLES2 interface. |
129 // Make sure the gles2 library is initialized first on exactly one thread. | 129 // Make sure the gles2 library is initialized first on exactly one thread. |
130 g_gles2_initializer.Get(); | 130 g_gles2_initializer.Get(); |
131 gles2::SetGLContext(ContextGL()); | 131 gles2::SetGLContext(ContextGL()); |
132 | 132 |
133 skia::RefPtr<GrGLInterface> interface = | 133 skia::RefPtr<GrGLInterface> interface = skia::AdoptRef(new GrGLInterface); |
134 skia::AdoptRef(skia_bindings::CreateCommandBufferSkiaGLBinding()); | 134 skia_bindings::InitCommandBufferSkiaGLBinding(interface.get()); |
135 interface->fCallback = BindGrContextCallback; | 135 interface->fCallback = BindGrContextCallback; |
136 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this); | 136 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this); |
137 | 137 |
138 gr_context_ = skia::AdoptRef(GrContext::Create( | 138 gr_context_ = skia::AdoptRef(GrContext::Create( |
139 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); | 139 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); |
140 | 140 |
141 return gr_context_.get(); | 141 return gr_context_.get(); |
142 } | 142 } |
143 | 143 |
144 void AwRenderThreadContextProvider::InvalidateGrContext(uint32_t state) { | 144 void AwRenderThreadContextProvider::InvalidateGrContext(uint32_t state) { |
(...skipping 29 matching lines...) Expand all Loading... |
174 void AwRenderThreadContextProvider::OnLostContext() { | 174 void AwRenderThreadContextProvider::OnLostContext() { |
175 DCHECK(main_thread_checker_.CalledOnValidThread()); | 175 DCHECK(main_thread_checker_.CalledOnValidThread()); |
176 | 176 |
177 if (!lost_context_callback_.is_null()) | 177 if (!lost_context_callback_.is_null()) |
178 base::ResetAndReturn(&lost_context_callback_).Run(); | 178 base::ResetAndReturn(&lost_context_callback_).Run(); |
179 if (gr_context_) | 179 if (gr_context_) |
180 gr_context_->abandonContext(); | 180 gr_context_->abandonContext(); |
181 } | 181 } |
182 | 182 |
183 } // namespace android_webview | 183 } // namespace android_webview |
OLD | NEW |