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" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 // static | 64 // static |
65 scoped_refptr<TestContextProvider> TestContextProvider::Create( | 65 scoped_refptr<TestContextProvider> TestContextProvider::Create( |
66 scoped_ptr<TestWebGraphicsContext3D> context) { | 66 scoped_ptr<TestWebGraphicsContext3D> context) { |
67 if (!context) | 67 if (!context) |
68 return NULL; | 68 return NULL; |
69 return new TestContextProvider(context.Pass()); | 69 return new TestContextProvider(context.Pass()); |
70 } | 70 } |
71 | 71 |
72 TestContextProvider::TestContextProvider( | 72 TestContextProvider::TestContextProvider( |
73 scoped_ptr<TestWebGraphicsContext3D> context) | 73 scoped_ptr<TestWebGraphicsContext3D> context) |
74 : context3d_(context.Pass()), bound_(false), destroyed_(false) { | 74 : context3d_(context.Pass()), |
75 bound_(false), | |
76 destroyed_(false), | |
77 context_lost_(false) { | |
75 DCHECK(main_thread_checker_.CalledOnValidThread()); | 78 DCHECK(main_thread_checker_.CalledOnValidThread()); |
76 DCHECK(context3d_); | 79 DCHECK(context3d_); |
77 context_thread_checker_.DetachFromThread(); | 80 context_thread_checker_.DetachFromThread(); |
78 context3d_->set_test_support(&support_); | 81 context3d_->set_test_support(&support_); |
79 } | 82 } |
80 | 83 |
81 TestContextProvider::~TestContextProvider() { | 84 TestContextProvider::~TestContextProvider() { |
82 DCHECK(main_thread_checker_.CalledOnValidThread() || | 85 DCHECK(main_thread_checker_.CalledOnValidThread() || |
83 context_thread_checker_.CalledOnValidThread()); | 86 context_thread_checker_.CalledOnValidThread()); |
84 } | 87 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 | 135 |
133 class GrContext* TestContextProvider::GrContext() { | 136 class GrContext* TestContextProvider::GrContext() { |
134 DCHECK(context3d_); | 137 DCHECK(context3d_); |
135 DCHECK(bound_); | 138 DCHECK(bound_); |
136 DCHECK(context_thread_checker_.CalledOnValidThread()); | 139 DCHECK(context_thread_checker_.CalledOnValidThread()); |
137 | 140 |
138 // TODO(danakj): Make a test GrContext that works with a test Context3d. | 141 // TODO(danakj): Make a test GrContext that works with a test Context3d. |
139 return NULL; | 142 return NULL; |
140 } | 143 } |
141 | 144 |
145 bool TestContextProvider::IsContextLost() { | |
146 DCHECK(context3d_); | |
147 DCHECK(bound_); | |
148 DCHECK(context_thread_checker_.CalledOnValidThread()); | |
149 | |
150 if (context_lost_) | |
piman
2013/11/01 23:15:35
I couldn't locate a place where this is set.
| |
151 return true; | |
152 | |
153 return context3d_->isContextLost(); | |
154 } | |
155 | |
142 void TestContextProvider::VerifyContexts() { | 156 void TestContextProvider::VerifyContexts() { |
143 DCHECK(context3d_); | 157 DCHECK(context3d_); |
144 DCHECK(bound_); | 158 DCHECK(bound_); |
145 DCHECK(context_thread_checker_.CalledOnValidThread()); | 159 DCHECK(context_thread_checker_.CalledOnValidThread()); |
146 | 160 |
147 if (context3d_->isContextLost()) { | 161 if (context3d_->isContextLost()) { |
148 base::AutoLock lock(destroyed_lock_); | 162 base::AutoLock lock(destroyed_lock_); |
149 destroyed_ = true; | 163 destroyed_ = true; |
150 } | 164 } |
151 } | 165 } |
(...skipping 26 matching lines...) Expand all Loading... | |
178 TestWebGraphicsContext3D* TestContextProvider::TestContext3d() { | 192 TestWebGraphicsContext3D* TestContextProvider::TestContext3d() { |
179 DCHECK(context3d_); | 193 DCHECK(context3d_); |
180 DCHECK(bound_); | 194 DCHECK(bound_); |
181 DCHECK(context_thread_checker_.CalledOnValidThread()); | 195 DCHECK(context_thread_checker_.CalledOnValidThread()); |
182 | 196 |
183 return context3d_.get(); | 197 return context3d_.get(); |
184 } | 198 } |
185 | 199 |
186 TestWebGraphicsContext3D* TestContextProvider::UnboundTestContext3d() { | 200 TestWebGraphicsContext3D* TestContextProvider::UnboundTestContext3d() { |
187 DCHECK(context3d_); | 201 DCHECK(context3d_); |
188 DCHECK(context_thread_checker_.CalledOnValidThread()); | |
189 | 202 |
190 return context3d_.get(); | 203 return context3d_.get(); |
191 } | 204 } |
192 | 205 |
193 void TestContextProvider::SetMemoryAllocation( | 206 void TestContextProvider::SetMemoryAllocation( |
194 const ManagedMemoryPolicy& policy) { | 207 const ManagedMemoryPolicy& policy) { |
195 if (memory_policy_changed_callback_.is_null()) | 208 if (memory_policy_changed_callback_.is_null()) |
196 return; | 209 return; |
197 memory_policy_changed_callback_.Run(policy); | 210 memory_policy_changed_callback_.Run(policy); |
198 } | 211 } |
(...skipping 18 matching lines...) Expand all Loading... | |
217 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null()); | 230 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null()); |
218 memory_policy_changed_callback_ = cb; | 231 memory_policy_changed_callback_ = cb; |
219 } | 232 } |
220 | 233 |
221 void TestContextProvider::SetMaxTransferBufferUsageBytes( | 234 void TestContextProvider::SetMaxTransferBufferUsageBytes( |
222 size_t max_transfer_buffer_usage_bytes) { | 235 size_t max_transfer_buffer_usage_bytes) { |
223 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); | 236 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); |
224 } | 237 } |
225 | 238 |
226 } // namespace cc | 239 } // namespace cc |
OLD | NEW |