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 "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" |
18 #include "third_party/skia/include/gpu/GrContext.h" | 19 #include "third_party/skia/include/gpu/GrContext.h" |
19 #include "third_party/skia/include/gpu/gl/SkNullGLContext.h" | 20 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
20 | 21 |
21 namespace cc { | 22 namespace cc { |
22 | 23 |
23 // static | 24 // static |
24 scoped_refptr<TestContextProvider> TestContextProvider::Create() { | 25 scoped_refptr<TestContextProvider> TestContextProvider::Create() { |
25 return Create(TestWebGraphicsContext3D::Create()); | 26 return Create(TestWebGraphicsContext3D::Create()); |
26 } | 27 } |
27 | 28 |
28 // static | 29 // static |
29 scoped_refptr<TestContextProvider> TestContextProvider::CreateWorker() { | 30 scoped_refptr<TestContextProvider> TestContextProvider::CreateWorker() { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 return &support_; | 106 return &support_; |
106 } | 107 } |
107 | 108 |
108 class GrContext* TestContextProvider::GrContext() { | 109 class GrContext* TestContextProvider::GrContext() { |
109 DCHECK(bound_); | 110 DCHECK(bound_); |
110 DCHECK(context_thread_checker_.CalledOnValidThread()); | 111 DCHECK(context_thread_checker_.CalledOnValidThread()); |
111 | 112 |
112 if (gr_context_) | 113 if (gr_context_) |
113 return gr_context_.get(); | 114 return gr_context_.get(); |
114 | 115 |
115 scoped_ptr<class SkGLContext> gl_context(SkNullGLContext::Create()); | 116 skia::RefPtr<GrGLInterface> gr_gl_interface = |
116 gl_context->makeCurrent(); | 117 skia::AdoptRef(new GrGLInterface); |
| 118 skia_bindings::InitGLES2InterfaceBindings(gr_gl_interface.get(), ContextGL()); |
| 119 |
117 gr_context_ = skia::AdoptRef(GrContext::Create( | 120 gr_context_ = skia::AdoptRef(GrContext::Create( |
118 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(gl_context->gl()))); | 121 kOpenGL_GrBackend, |
| 122 reinterpret_cast<GrBackendContext>(gr_gl_interface.get()))); |
119 | 123 |
120 // If GlContext is already lost, also abandon the new GrContext. | 124 // If GlContext is already lost, also abandon the new GrContext. |
121 if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) | 125 if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) |
122 gr_context_->abandonContext(); | 126 gr_context_->abandonContext(); |
123 | 127 |
124 return gr_context_.get(); | 128 return gr_context_.get(); |
125 } | 129 } |
126 | 130 |
127 void TestContextProvider::InvalidateGrContext(uint32_t state) { | 131 void TestContextProvider::InvalidateGrContext(uint32_t state) { |
128 DCHECK(bound_); | 132 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()); | 171 DCHECK(lost_context_callback_.is_null() || cb.is_null()); |
168 lost_context_callback_ = cb; | 172 lost_context_callback_ = cb; |
169 } | 173 } |
170 | 174 |
171 void TestContextProvider::SetMaxTransferBufferUsageBytes( | 175 void TestContextProvider::SetMaxTransferBufferUsageBytes( |
172 size_t max_transfer_buffer_usage_bytes) { | 176 size_t max_transfer_buffer_usage_bytes) { |
173 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); | 177 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); |
174 } | 178 } |
175 | 179 |
176 } // namespace cc | 180 } // namespace cc |
OLD | NEW |