Chromium Code Reviews| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/callback_helpers.h" | 14 #include "base/callback_helpers.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "cc/test/test_gles2_interface.h" | 16 #include "cc/test/test_gles2_interface.h" |
| 17 #include "cc/test/test_web_graphics_context_3d.h" | 17 #include "cc/test/test_web_graphics_context_3d.h" |
| 18 #include "third_party/skia/include/gpu/GrContext.h" | 18 #include "third_party/skia/include/gpu/GrContext.h" |
| 19 #include "third_party/skia/include/gpu/gl/SkNullGLContext.h" | 19 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
| 20 | 20 |
| 21 namespace cc { | 21 namespace cc { |
| 22 | 22 |
| 23 // static | 23 // static |
| 24 scoped_refptr<TestContextProvider> TestContextProvider::Create() { | 24 scoped_refptr<TestContextProvider> TestContextProvider::Create() { |
| 25 return Create(TestWebGraphicsContext3D::Create()); | 25 return Create(TestWebGraphicsContext3D::Create()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 // static | 28 // static |
| 29 scoped_refptr<TestContextProvider> TestContextProvider::CreateWorker() { | 29 scoped_refptr<TestContextProvider> TestContextProvider::CreateWorker() { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 return &support_; | 105 return &support_; |
| 106 } | 106 } |
| 107 | 107 |
| 108 class GrContext* TestContextProvider::GrContext() { | 108 class GrContext* TestContextProvider::GrContext() { |
| 109 DCHECK(bound_); | 109 DCHECK(bound_); |
| 110 DCHECK(context_thread_checker_.CalledOnValidThread()); | 110 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 111 | 111 |
| 112 if (gr_context_) | 112 if (gr_context_) |
| 113 return gr_context_.get(); | 113 return gr_context_.get(); |
| 114 | 114 |
| 115 scoped_ptr<class SkGLContext> gl_context(SkNullGLContext::Create()); | 115 auto gl_interface = skia::AdoptRef(GrGLCreateNullInterface()); |
|
danakj
2016/03/25 18:09:36
re: past chromium-dev threads, don't use auto for
bsalomon
2016/03/25 19:02:45
Done.
| |
| 116 gl_context->makeCurrent(); | |
| 117 gr_context_ = skia::AdoptRef(GrContext::Create( | 116 gr_context_ = skia::AdoptRef(GrContext::Create( |
| 118 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(gl_context->gl()))); | 117 kOpenGL_GrBackend, |
| 118 reinterpret_cast<GrBackendContext>(gl_interface.get()))); | |
| 119 | 119 |
| 120 // If GlContext is already lost, also abandon the new GrContext. | 120 // If GlContext is already lost, also abandon the new GrContext. |
| 121 if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) | 121 if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) |
| 122 gr_context_->abandonContext(); | 122 gr_context_->abandonContext(); |
| 123 | 123 |
| 124 return gr_context_.get(); | 124 return gr_context_.get(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void TestContextProvider::InvalidateGrContext(uint32_t state) { | 127 void TestContextProvider::InvalidateGrContext(uint32_t state) { |
| 128 DCHECK(bound_); | 128 DCHECK(bound_); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 DCHECK(lost_context_callback_.is_null() || cb.is_null()); | 167 DCHECK(lost_context_callback_.is_null() || cb.is_null()); |
| 168 lost_context_callback_ = cb; | 168 lost_context_callback_ = cb; |
| 169 } | 169 } |
| 170 | 170 |
| 171 void TestContextProvider::SetMaxTransferBufferUsageBytes( | 171 void TestContextProvider::SetMaxTransferBufferUsageBytes( |
| 172 size_t max_transfer_buffer_usage_bytes) { | 172 size_t max_transfer_buffer_usage_bytes) { |
| 173 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); | 173 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); |
| 174 } | 174 } |
| 175 | 175 |
| 176 } // namespace cc | 176 } // namespace cc |
| OLD | NEW |