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 <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "cc/test/test_gles2_interface.h" | 13 #include "cc/test/test_gles2_interface.h" |
14 #include "cc/test/test_web_graphics_context_3d.h" | 14 #include "cc/test/test_web_graphics_context_3d.h" |
| 15 #include "third_party/skia/include/gpu/GrContext.h" |
| 16 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
15 | 17 |
16 namespace cc { | 18 namespace cc { |
17 | 19 |
18 // static | 20 // static |
19 scoped_refptr<TestContextProvider> TestContextProvider::Create() { | 21 scoped_refptr<TestContextProvider> TestContextProvider::Create() { |
20 return Create(TestWebGraphicsContext3D::Create().Pass()); | 22 return Create(TestWebGraphicsContext3D::Create().Pass()); |
21 } | 23 } |
22 | 24 |
23 // static | 25 // static |
24 scoped_refptr<TestContextProvider> TestContextProvider::Create( | 26 scoped_refptr<TestContextProvider> TestContextProvider::Create( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 85 } |
84 | 86 |
85 gpu::ContextSupport* TestContextProvider::ContextSupport() { | 87 gpu::ContextSupport* TestContextProvider::ContextSupport() { |
86 return &support_; | 88 return &support_; |
87 } | 89 } |
88 | 90 |
89 class GrContext* TestContextProvider::GrContext() { | 91 class GrContext* TestContextProvider::GrContext() { |
90 DCHECK(bound_); | 92 DCHECK(bound_); |
91 DCHECK(context_thread_checker_.CalledOnValidThread()); | 93 DCHECK(context_thread_checker_.CalledOnValidThread()); |
92 | 94 |
93 // TODO(danakj): Make a test GrContext that works with a test Context3d. | 95 if (gr_context_) |
94 return NULL; | 96 return gr_context_.get(); |
| 97 |
| 98 auto null_interface = skia::AdoptRef(GrGLCreateNullInterface()); |
| 99 gr_context_ = skia::AdoptRef(GrContext::Create( |
| 100 kOpenGL_GrBackend, |
| 101 reinterpret_cast<GrBackendContext>(null_interface.get()))); |
| 102 return gr_context_.get(); |
95 } | 103 } |
96 | 104 |
97 bool TestContextProvider::IsContextLost() { | 105 bool TestContextProvider::IsContextLost() { |
98 DCHECK(bound_); | 106 DCHECK(bound_); |
99 DCHECK(context_thread_checker_.CalledOnValidThread()); | 107 DCHECK(context_thread_checker_.CalledOnValidThread()); |
100 | 108 |
101 return context3d_->isContextLost(); | 109 return context3d_->isContextLost(); |
102 } | 110 } |
103 | 111 |
104 void TestContextProvider::VerifyContexts() { | 112 void TestContextProvider::VerifyContexts() { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null()); | 172 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null()); |
165 memory_policy_changed_callback_ = cb; | 173 memory_policy_changed_callback_ = cb; |
166 } | 174 } |
167 | 175 |
168 void TestContextProvider::SetMaxTransferBufferUsageBytes( | 176 void TestContextProvider::SetMaxTransferBufferUsageBytes( |
169 size_t max_transfer_buffer_usage_bytes) { | 177 size_t max_transfer_buffer_usage_bytes) { |
170 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); | 178 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); |
171 } | 179 } |
172 | 180 |
173 } // namespace cc | 181 } // namespace cc |
OLD | NEW |