| 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 "ui/compositor/test/in_process_context_provider.h" | 5 #include "ui/compositor/test/in_process_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/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 DCHECK(context_thread_checker_.CalledOnValidThread()); | 154 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 155 | 155 |
| 156 if (gr_context_) | 156 if (gr_context_) |
| 157 return gr_context_.get(); | 157 return gr_context_.get(); |
| 158 | 158 |
| 159 // The GrGLInterface factory will make GL calls using the C GLES2 interface. | 159 // The GrGLInterface factory will make GL calls using the C GLES2 interface. |
| 160 // Make sure the gles2 library is initialized first on exactly one thread. | 160 // Make sure the gles2 library is initialized first on exactly one thread. |
| 161 g_gles2_initializer.Get(); | 161 g_gles2_initializer.Get(); |
| 162 gles2::SetGLContext(ContextGL()); | 162 gles2::SetGLContext(ContextGL()); |
| 163 | 163 |
| 164 skia::RefPtr<GrGLInterface> interface = skia::AdoptRef(new GrGLInterface); | 164 skia::RefPtr<GrGLInterface> interface = |
| 165 skia_bindings::InitCommandBufferSkiaGLBinding(interface.get()); | 165 skia::AdoptRef(skia_bindings::CreateCommandBufferSkiaGLBinding()); |
| 166 interface->fCallback = BindGrContextCallback; | 166 interface->fCallback = BindGrContextCallback; |
| 167 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this); | 167 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this); |
| 168 | 168 |
| 169 gr_context_ = skia::AdoptRef(GrContext::Create( | 169 gr_context_ = skia::AdoptRef(GrContext::Create( |
| 170 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); | 170 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); |
| 171 | 171 |
| 172 return gr_context_.get(); | 172 return gr_context_.get(); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void InProcessContextProvider::InvalidateGrContext(uint32_t state) { | 175 void InProcessContextProvider::InvalidateGrContext(uint32_t state) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 203 | 203 |
| 204 void InProcessContextProvider::OnLostContext() { | 204 void InProcessContextProvider::OnLostContext() { |
| 205 DCHECK(context_thread_checker_.CalledOnValidThread()); | 205 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 206 if (!lost_context_callback_.is_null()) | 206 if (!lost_context_callback_.is_null()) |
| 207 base::ResetAndReturn(&lost_context_callback_).Run(); | 207 base::ResetAndReturn(&lost_context_callback_).Run(); |
| 208 if (gr_context_) | 208 if (gr_context_) |
| 209 gr_context_->abandonContext(); | 209 gr_context_->abandonContext(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 } // namespace ui | 212 } // namespace ui |
| OLD | NEW |