| 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 "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
| 14 #include "cc/test/test_gles2_interface.h" |
| 14 #include "cc/test/test_web_graphics_context_3d.h" | 15 #include "cc/test/test_web_graphics_context_3d.h" |
| 15 | 16 |
| 16 namespace cc { | 17 namespace cc { |
| 17 | 18 |
| 18 class TestContextProvider::LostContextCallbackProxy | 19 class TestContextProvider::LostContextCallbackProxy |
| 19 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 20 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
| 20 public: | 21 public: |
| 21 explicit LostContextCallbackProxy(TestContextProvider* provider) | 22 explicit LostContextCallbackProxy(TestContextProvider* provider) |
| 22 : provider_(provider) { | 23 : provider_(provider) { |
| 23 provider_->context3d_->setContextLostCallback(this); | 24 provider_->context3d_->setContextLostCallback(this); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 scoped_refptr<TestContextProvider> TestContextProvider::Create( | 66 scoped_refptr<TestContextProvider> TestContextProvider::Create( |
| 66 scoped_ptr<TestWebGraphicsContext3D> context) { | 67 scoped_ptr<TestWebGraphicsContext3D> context) { |
| 67 if (!context) | 68 if (!context) |
| 68 return NULL; | 69 return NULL; |
| 69 return new TestContextProvider(context.Pass()); | 70 return new TestContextProvider(context.Pass()); |
| 70 } | 71 } |
| 71 | 72 |
| 72 TestContextProvider::TestContextProvider( | 73 TestContextProvider::TestContextProvider( |
| 73 scoped_ptr<TestWebGraphicsContext3D> context) | 74 scoped_ptr<TestWebGraphicsContext3D> context) |
| 74 : context3d_(context.Pass()), | 75 : context3d_(context.Pass()), |
| 76 context_gl_stub_(TestGLES2Interface::Create()), |
| 75 bound_(false), | 77 bound_(false), |
| 76 destroyed_(false) { | 78 destroyed_(false) { |
| 77 DCHECK(main_thread_checker_.CalledOnValidThread()); | 79 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 78 DCHECK(context3d_); | 80 DCHECK(context3d_); |
| 79 context_thread_checker_.DetachFromThread(); | 81 context_thread_checker_.DetachFromThread(); |
| 80 context3d_->set_test_support(&support_); | 82 context3d_->set_test_support(&support_); |
| 81 } | 83 } |
| 82 | 84 |
| 83 TestContextProvider::~TestContextProvider() { | 85 TestContextProvider::~TestContextProvider() { |
| 84 DCHECK(main_thread_checker_.CalledOnValidThread() || | 86 DCHECK(main_thread_checker_.CalledOnValidThread() || |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 DCHECK(context_thread_checker_.CalledOnValidThread()); | 124 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 123 | 125 |
| 124 return context3d_.get(); | 126 return context3d_.get(); |
| 125 } | 127 } |
| 126 | 128 |
| 127 gpu::gles2::GLES2Interface* TestContextProvider::ContextGL() { | 129 gpu::gles2::GLES2Interface* TestContextProvider::ContextGL() { |
| 128 DCHECK(context3d_); | 130 DCHECK(context3d_); |
| 129 DCHECK(bound_); | 131 DCHECK(bound_); |
| 130 DCHECK(context_thread_checker_.CalledOnValidThread()); | 132 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 131 | 133 |
| 132 return &context_gl_stub_; | 134 return context_gl_stub_.get();; |
| 133 } | 135 } |
| 134 | 136 |
| 135 gpu::ContextSupport* TestContextProvider::ContextSupport() { | 137 gpu::ContextSupport* TestContextProvider::ContextSupport() { |
| 136 DCHECK(context3d_); | 138 DCHECK(context3d_); |
| 137 DCHECK(bound_); | 139 DCHECK(bound_); |
| 138 DCHECK(context_thread_checker_.CalledOnValidThread()); | 140 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 139 | 141 |
| 140 return &support_; | 142 return &support_; |
| 141 } | 143 } |
| 142 | 144 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null()); | 236 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null()); |
| 235 memory_policy_changed_callback_ = cb; | 237 memory_policy_changed_callback_ = cb; |
| 236 } | 238 } |
| 237 | 239 |
| 238 void TestContextProvider::SetMaxTransferBufferUsageBytes( | 240 void TestContextProvider::SetMaxTransferBufferUsageBytes( |
| 239 size_t max_transfer_buffer_usage_bytes) { | 241 size_t max_transfer_buffer_usage_bytes) { |
| 240 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); | 242 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); |
| 241 } | 243 } |
| 242 | 244 |
| 243 } // namespace cc | 245 } // namespace cc |
| OLD | NEW |