OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "cc/layers/content_layer.h" | 8 #include "cc/layers/content_layer.h" |
9 #include "cc/layers/heads_up_display_layer.h" | 9 #include "cc/layers/heads_up_display_layer.h" |
10 #include "cc/layers/io_surface_layer.h" | 10 #include "cc/layers/io_surface_layer.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 ++times_to_expect_recreate_retried_; | 206 ++times_to_expect_recreate_retried_; |
207 } | 207 } |
208 | 208 |
209 protected: | 209 protected: |
210 TestWebGraphicsContext3D* context3d_; | 210 TestWebGraphicsContext3D* context3d_; |
211 int times_to_fail_create_; | 211 int times_to_fail_create_; |
212 int times_to_fail_initialize_; | 212 int times_to_fail_initialize_; |
213 int times_to_lose_on_create_; | 213 int times_to_lose_on_create_; |
214 int times_to_lose_during_commit_; | 214 int times_to_lose_during_commit_; |
215 int times_to_lose_during_draw_; | 215 int times_to_lose_during_draw_; |
| 216 int times_to_fail_reinitialize_; |
216 int times_to_fail_recreate_; | 217 int times_to_fail_recreate_; |
217 int times_to_fail_reinitialize_; | |
218 int times_to_lose_on_recreate_; | 218 int times_to_lose_on_recreate_; |
219 int times_to_fail_create_offscreen_; | 219 int times_to_fail_create_offscreen_; |
220 int times_to_fail_recreate_offscreen_; | 220 int times_to_fail_recreate_offscreen_; |
221 int times_to_expect_recreate_retried_; | 221 int times_to_expect_recreate_retried_; |
222 int times_recreate_retried_; | 222 int times_recreate_retried_; |
223 int times_offscreen_created_; | 223 int times_offscreen_created_; |
224 bool committed_at_least_once_; | 224 bool committed_at_least_once_; |
225 | 225 |
226 scoped_refptr<FakeContextProvider> offscreen_contexts_main_thread_; | 226 scoped_refptr<FakeContextProvider> offscreen_contexts_main_thread_; |
227 scoped_refptr<FakeContextProvider> offscreen_contexts_compositor_thread_; | 227 scoped_refptr<FakeContextProvider> offscreen_contexts_compositor_thread_; |
(...skipping 12 matching lines...) Expand all Loading... |
240 PostSetNeedsCommitToMainThread(); | 240 PostSetNeedsCommitToMainThread(); |
241 } | 241 } |
242 | 242 |
243 virtual void DidRecreateOutputSurface(bool succeeded) OVERRIDE { | 243 virtual void DidRecreateOutputSurface(bool succeeded) OVERRIDE { |
244 EXPECT_TRUE(succeeded); | 244 EXPECT_TRUE(succeeded); |
245 ++num_losses_; | 245 ++num_losses_; |
246 recovered_context_ = true; | 246 recovered_context_ = true; |
247 } | 247 } |
248 | 248 |
249 virtual void AfterTest() OVERRIDE { | 249 virtual void AfterTest() OVERRIDE { |
250 EXPECT_EQ(10u, test_case_); | 250 EXPECT_EQ(10, test_case_); |
251 EXPECT_EQ(8 + 10 + 10, num_losses_); | 251 EXPECT_EQ(8 + 10 + 10, num_losses_); |
252 } | 252 } |
253 | 253 |
254 virtual void DidCommitAndDrawFrame() OVERRIDE { | 254 virtual void DidCommitAndDrawFrame() OVERRIDE { |
255 // If the last frame had a context loss, then we'll commit again to | 255 // If the last frame had a context loss, then we'll commit again to |
256 // recover. | 256 // recover. |
257 if (!recovered_context_) | 257 if (!recovered_context_) |
258 return; | 258 return; |
259 if (times_to_lose_during_commit_) | 259 if (times_to_lose_during_commit_) |
260 return; | 260 return; |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1196 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
1197 | 1197 |
1198 ++commits_; | 1198 ++commits_; |
1199 size_t upload_count = scrollbar_layer_->last_update_full_upload_size() + | 1199 size_t upload_count = scrollbar_layer_->last_update_full_upload_size() + |
1200 scrollbar_layer_->last_update_partial_upload_size(); | 1200 scrollbar_layer_->last_update_partial_upload_size(); |
1201 switch (commits_) { | 1201 switch (commits_) { |
1202 case 1: | 1202 case 1: |
1203 // First (regular) update, we should upload 2 resources (thumb, and | 1203 // First (regular) update, we should upload 2 resources (thumb, and |
1204 // backtrack). | 1204 // backtrack). |
1205 EXPECT_EQ(1, scrollbar_layer_->update_count()); | 1205 EXPECT_EQ(1, scrollbar_layer_->update_count()); |
1206 EXPECT_EQ(2u, upload_count); | 1206 EXPECT_EQ(2, upload_count); |
1207 LoseContext(); | 1207 LoseContext(); |
1208 break; | 1208 break; |
1209 case 2: | 1209 case 2: |
1210 // Second update, after the lost context, we should still upload 2 | 1210 // Second update, after the lost context, we should still upload 2 |
1211 // resources even if the contents haven't changed. | 1211 // resources even if the contents haven't changed. |
1212 EXPECT_EQ(2, scrollbar_layer_->update_count()); | 1212 EXPECT_EQ(2, scrollbar_layer_->update_count()); |
1213 EXPECT_EQ(2u, upload_count); | 1213 EXPECT_EQ(2, upload_count); |
1214 EndTest(); | 1214 EndTest(); |
1215 break; | 1215 break; |
1216 default: | 1216 default: |
1217 NOTREACHED(); | 1217 NOTREACHED(); |
1218 } | 1218 } |
1219 } | 1219 } |
1220 | 1220 |
1221 private: | 1221 private: |
1222 int commits_; | 1222 int commits_; |
1223 scoped_refptr<FakeScrollbarLayer> scrollbar_layer_; | 1223 scoped_refptr<FakeScrollbarLayer> scrollbar_layer_; |
1224 }; | 1224 }; |
1225 | 1225 |
1226 SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext); | 1226 SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext); |
1227 | 1227 |
1228 } // namespace | 1228 } // namespace |
1229 } // namespace cc | 1229 } // namespace cc |
OLD | NEW |