| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/test/test_context_provider.h" | 5 #include "cc/test/test_context_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 return &support_; | 104 return &support_; |
| 105 } | 105 } |
| 106 | 106 |
| 107 class GrContext* TestContextProvider::GrContext() { | 107 class GrContext* TestContextProvider::GrContext() { |
| 108 DCHECK(bound_); | 108 DCHECK(bound_); |
| 109 DCHECK(context_thread_checker_.CalledOnValidThread()); | 109 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 110 | 110 |
| 111 if (gr_context_) | 111 if (gr_context_) |
| 112 return gr_context_.get(); | 112 return gr_context_.get(); |
| 113 | 113 |
| 114 skia::RefPtr<const GrGLInterface> gl_interface = | 114 sk_sp<const GrGLInterface> gl_interface(GrGLCreateNullInterface()); |
| 115 skia::AdoptRef(GrGLCreateNullInterface()); | 115 gr_context_ = sk_sp<::GrContext>(GrContext::Create( |
| 116 gr_context_ = skia::AdoptRef(GrContext::Create( | |
| 117 kOpenGL_GrBackend, | 116 kOpenGL_GrBackend, |
| 118 reinterpret_cast<GrBackendContext>(gl_interface.get()))); | 117 reinterpret_cast<GrBackendContext>(gl_interface.get()))); |
| 119 | 118 |
| 120 // If GlContext is already lost, also abandon the new GrContext. | 119 // If GlContext is already lost, also abandon the new GrContext. |
| 121 if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) | 120 if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) |
| 122 gr_context_->abandonContext(); | 121 gr_context_->abandonContext(); |
| 123 | 122 |
| 124 return gr_context_.get(); | 123 return gr_context_.get(); |
| 125 } | 124 } |
| 126 | 125 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 161 } |
| 163 | 162 |
| 164 void TestContextProvider::SetLostContextCallback( | 163 void TestContextProvider::SetLostContextCallback( |
| 165 const LostContextCallback& cb) { | 164 const LostContextCallback& cb) { |
| 166 DCHECK(context_thread_checker_.CalledOnValidThread()); | 165 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 167 DCHECK(lost_context_callback_.is_null() || cb.is_null()); | 166 DCHECK(lost_context_callback_.is_null() || cb.is_null()); |
| 168 lost_context_callback_ = cb; | 167 lost_context_callback_ = cb; |
| 169 } | 168 } |
| 170 | 169 |
| 171 } // namespace cc | 170 } // namespace cc |
| OLD | NEW |