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 class TestContextProvider::LostContextCallbackProxy | 20 class TestContextProvider::LostContextCallbackProxy |
19 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 21 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
20 public: | 22 public: |
21 explicit LostContextCallbackProxy(TestContextProvider* provider) | 23 explicit LostContextCallbackProxy(TestContextProvider* provider) |
22 : provider_(provider) { | 24 : provider_(provider) { |
23 provider_->context3d_->setContextLostCallback(this); | 25 provider_->context3d_->setContextLostCallback(this); |
24 } | 26 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } | 110 } |
109 | 111 |
110 gpu::ContextSupport* TestContextProvider::ContextSupport() { | 112 gpu::ContextSupport* TestContextProvider::ContextSupport() { |
111 return &support_; | 113 return &support_; |
112 } | 114 } |
113 | 115 |
114 class GrContext* TestContextProvider::GrContext() { | 116 class GrContext* TestContextProvider::GrContext() { |
115 DCHECK(bound_); | 117 DCHECK(bound_); |
116 DCHECK(context_thread_checker_.CalledOnValidThread()); | 118 DCHECK(context_thread_checker_.CalledOnValidThread()); |
117 | 119 |
118 // TODO(danakj): Make a test GrContext that works with a test Context3d. | 120 if (!gr_context_) { |
119 return NULL; | 121 gr_context_ = skia::AdoptRef(GrContext::Create( |
| 122 kOpenGL_GrBackend, |
| 123 reinterpret_cast<GrBackendContext>(GrGLCreateNullInterface()))); |
| 124 } |
| 125 return gr_context_.get(); |
120 } | 126 } |
121 | 127 |
122 void TestContextProvider::MakeGrContextCurrent() {} | 128 void TestContextProvider::MakeGrContextCurrent() {} |
123 | 129 |
124 bool TestContextProvider::IsContextLost() { | 130 bool TestContextProvider::IsContextLost() { |
125 DCHECK(bound_); | 131 DCHECK(bound_); |
126 DCHECK(context_thread_checker_.CalledOnValidThread()); | 132 DCHECK(context_thread_checker_.CalledOnValidThread()); |
127 | 133 |
128 return context3d_->isContextLost(); | 134 return context3d_->isContextLost(); |
129 } | 135 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null()); | 194 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null()); |
189 memory_policy_changed_callback_ = cb; | 195 memory_policy_changed_callback_ = cb; |
190 } | 196 } |
191 | 197 |
192 void TestContextProvider::SetMaxTransferBufferUsageBytes( | 198 void TestContextProvider::SetMaxTransferBufferUsageBytes( |
193 size_t max_transfer_buffer_usage_bytes) { | 199 size_t max_transfer_buffer_usage_bytes) { |
194 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); | 200 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); |
195 } | 201 } |
196 | 202 |
197 } // namespace cc | 203 } // namespace cc |
OLD | NEW |