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/delegated_frame_provider.h" | 9 #include "cc/layers/delegated_frame_provider.h" |
10 #include "cc/layers/delegated_frame_resource_collection.h" | 10 #include "cc/layers/delegated_frame_resource_collection.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 void LoseContext() { | 69 void LoseContext() { |
70 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 70 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
71 GL_INNOCENT_CONTEXT_RESET_ARB); | 71 GL_INNOCENT_CONTEXT_RESET_ARB); |
72 context3d_ = NULL; | 72 context3d_ = NULL; |
73 } | 73 } |
74 | 74 |
75 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() { | 75 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() { |
76 return TestWebGraphicsContext3D::Create(); | 76 return TestWebGraphicsContext3D::Create(); |
77 } | 77 } |
78 | 78 |
79 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) | 79 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurfaceForTest( |
80 OVERRIDE { | 80 bool fallback) OVERRIDE { |
81 if (times_to_fail_create_) { | 81 if (times_to_fail_create_) { |
82 --times_to_fail_create_; | 82 --times_to_fail_create_; |
83 ExpectCreateToFail(); | 83 ExpectCreateToFail(); |
84 return scoped_ptr<OutputSurface>(); | 84 return scoped_ptr<FakeOutputSurface>(); |
85 } | 85 } |
86 | 86 |
87 scoped_ptr<TestWebGraphicsContext3D> context3d = CreateContext3d(); | 87 scoped_ptr<TestWebGraphicsContext3D> context3d = CreateContext3d(); |
88 context3d_ = context3d.get(); | 88 context3d_ = context3d.get(); |
89 | 89 |
90 if (context_should_support_io_surface_) { | 90 if (context_should_support_io_surface_) { |
91 context3d_->set_have_extension_io_surface(true); | 91 context3d_->set_have_extension_io_surface(true); |
92 context3d_->set_have_extension_egl_image(true); | 92 context3d_->set_have_extension_egl_image(true); |
93 } | 93 } |
94 | 94 |
95 if (delegating_renderer()) { | 95 if (delegating_renderer()) |
96 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()) | 96 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); |
97 .PassAs<OutputSurface>(); | 97 else |
98 } | 98 return FakeOutputSurface::Create3d(context3d.Pass()); |
99 return FakeOutputSurface::Create3d(context3d.Pass()) | |
100 .PassAs<OutputSurface>(); | |
101 } | 99 } |
102 | 100 |
103 scoped_ptr<TestWebGraphicsContext3D> CreateOffscreenContext3d() { | 101 scoped_ptr<TestWebGraphicsContext3D> CreateOffscreenContext3d() { |
104 if (!context3d_) | 102 if (!context3d_) |
105 return scoped_ptr<TestWebGraphicsContext3D>(); | 103 return scoped_ptr<TestWebGraphicsContext3D>(); |
106 | 104 |
107 ++times_offscreen_created_; | 105 ++times_offscreen_created_; |
108 | 106 |
109 if (times_to_fail_create_offscreen_) { | 107 if (times_to_fail_create_offscreen_) { |
110 --times_to_fail_create_offscreen_; | 108 --times_to_fail_create_offscreen_; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 161 |
164 virtual void DidFailToInitializeOutputSurface() OVERRIDE { | 162 virtual void DidFailToInitializeOutputSurface() OVERRIDE { |
165 ++times_create_failed_; | 163 ++times_create_failed_; |
166 } | 164 } |
167 | 165 |
168 virtual void TearDown() OVERRIDE { | 166 virtual void TearDown() OVERRIDE { |
169 LayerTreeTest::TearDown(); | 167 LayerTreeTest::TearDown(); |
170 EXPECT_EQ(times_to_expect_create_failed_, times_create_failed_); | 168 EXPECT_EQ(times_to_expect_create_failed_, times_create_failed_); |
171 } | 169 } |
172 | 170 |
173 void ExpectCreateToFail() { | 171 void ExpectCreateToFail() { ++times_to_expect_create_failed_; } |
174 ++times_to_expect_create_failed_; | |
175 } | |
176 | 172 |
177 protected: | 173 protected: |
178 TestWebGraphicsContext3D* context3d_; | 174 TestWebGraphicsContext3D* context3d_; |
179 int times_to_fail_create_; | 175 int times_to_fail_create_; |
180 int times_to_lose_during_commit_; | 176 int times_to_lose_during_commit_; |
181 int times_to_lose_during_draw_; | 177 int times_to_lose_during_draw_; |
182 int times_to_fail_recreate_; | 178 int times_to_fail_recreate_; |
183 int times_to_fail_create_offscreen_; | 179 int times_to_fail_create_offscreen_; |
184 int times_to_fail_recreate_offscreen_; | 180 int times_to_fail_recreate_offscreen_; |
185 int times_to_expect_create_failed_; | 181 int times_to_expect_create_failed_; |
(...skipping 10 matching lines...) Expand all Loading... |
196 : public LayerTreeHostContextTest { | 192 : public LayerTreeHostContextTest { |
197 public: | 193 public: |
198 LayerTreeHostContextTestLostContextSucceeds() | 194 LayerTreeHostContextTestLostContextSucceeds() |
199 : LayerTreeHostContextTest(), | 195 : LayerTreeHostContextTest(), |
200 test_case_(0), | 196 test_case_(0), |
201 num_losses_(0), | 197 num_losses_(0), |
202 num_losses_last_test_case_(-1), | 198 num_losses_last_test_case_(-1), |
203 recovered_context_(true), | 199 recovered_context_(true), |
204 first_initialized_(false) {} | 200 first_initialized_(false) {} |
205 | 201 |
206 virtual void BeginTest() OVERRIDE { | 202 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
207 PostSetNeedsCommitToMainThread(); | |
208 } | |
209 | 203 |
210 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { | 204 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { |
211 EXPECT_TRUE(succeeded); | 205 EXPECT_TRUE(succeeded); |
212 | 206 |
213 if (first_initialized_) | 207 if (first_initialized_) |
214 ++num_losses_; | 208 ++num_losses_; |
215 else | 209 else |
216 first_initialized_ = true; | 210 first_initialized_ = true; |
217 | 211 |
218 recovered_context_ = true; | 212 recovered_context_ = true; |
(...skipping 19 matching lines...) Expand all Loading... |
238 } | 232 } |
239 | 233 |
240 virtual void InvalidateAndSetNeedsCommit() { | 234 virtual void InvalidateAndSetNeedsCommit() { |
241 // Cause damage so we try to draw. | 235 // Cause damage so we try to draw. |
242 layer_tree_host()->root_layer()->SetNeedsDisplay(); | 236 layer_tree_host()->root_layer()->SetNeedsDisplay(); |
243 layer_tree_host()->SetNeedsCommit(); | 237 layer_tree_host()->SetNeedsCommit(); |
244 } | 238 } |
245 | 239 |
246 bool NextTestCase() { | 240 bool NextTestCase() { |
247 static const TestCase kTests[] = { | 241 static const TestCase kTests[] = { |
248 // Losing the context and failing to recreate it (or losing it again | 242 // Losing the context and failing to recreate it (or losing it again |
249 // immediately) a small number of times should succeed. | 243 // immediately) a small number of times should succeed. |
250 { 1, // times_to_lose_during_commit | 244 {1, // times_to_lose_during_commit |
251 0, // times_to_lose_during_draw | 245 0, // times_to_lose_during_draw |
252 0, // times_to_fail_recreate | 246 0, // times_to_fail_recreate |
253 0, // times_to_fail_recreate_offscreen | 247 0, // times_to_fail_recreate_offscreen |
254 false, // fallback_context_works | 248 false, // fallback_context_works |
255 }, | 249 }, |
256 { 0, // times_to_lose_during_commit | 250 {0, // times_to_lose_during_commit |
257 1, // times_to_lose_during_draw | 251 1, // times_to_lose_during_draw |
258 0, // times_to_fail_recreate | 252 0, // times_to_fail_recreate |
259 0, // times_to_fail_recreate_offscreen | 253 0, // times_to_fail_recreate_offscreen |
260 false, // fallback_context_works | 254 false, // fallback_context_works |
261 }, | 255 }, |
262 { 1, // times_to_lose_during_commit | 256 {1, // times_to_lose_during_commit |
263 0, // times_to_lose_during_draw | 257 0, // times_to_lose_during_draw |
264 3, // times_to_fail_recreate | 258 3, // times_to_fail_recreate |
265 0, // times_to_fail_recreate_offscreen | 259 0, // times_to_fail_recreate_offscreen |
266 false, // fallback_context_works | 260 false, // fallback_context_works |
267 }, | 261 }, |
268 { 0, // times_to_lose_during_commit | 262 {0, // times_to_lose_during_commit |
269 1, // times_to_lose_during_draw | 263 1, // times_to_lose_during_draw |
270 3, // times_to_fail_recreate | 264 3, // times_to_fail_recreate |
271 0, // times_to_fail_recreate_offscreen | 265 0, // times_to_fail_recreate_offscreen |
272 false, // fallback_context_works | 266 false, // fallback_context_works |
273 }, | 267 }, |
274 { 1, // times_to_lose_during_commit | 268 {1, // times_to_lose_during_commit |
275 0, // times_to_lose_during_draw | 269 0, // times_to_lose_during_draw |
276 0, // times_to_fail_recreate | 270 0, // times_to_fail_recreate |
277 3, // times_to_fail_recreate_offscreen | 271 3, // times_to_fail_recreate_offscreen |
278 false, // fallback_context_works | 272 false, // fallback_context_works |
279 }, | 273 }, |
280 { 0, // times_to_lose_during_commit | 274 {0, // times_to_lose_during_commit |
281 1, // times_to_lose_during_draw | 275 1, // times_to_lose_during_draw |
282 0, // times_to_fail_recreate | 276 0, // times_to_fail_recreate |
283 3, // times_to_fail_recreate_offscreen | 277 3, // times_to_fail_recreate_offscreen |
284 false, // fallback_context_works | 278 false, // fallback_context_works |
285 }, | 279 }, |
286 // Losing the context and recreating it any number of times should | 280 // Losing the context and recreating it any number of times should |
287 // succeed. | 281 // succeed. |
288 { 10, // times_to_lose_during_commit | 282 {10, // times_to_lose_during_commit |
289 0, // times_to_lose_during_draw | 283 0, // times_to_lose_during_draw |
290 0, // times_to_fail_recreate | 284 0, // times_to_fail_recreate |
291 0, // times_to_fail_recreate_offscreen | 285 0, // times_to_fail_recreate_offscreen |
292 false, // fallback_context_works | 286 false, // fallback_context_works |
293 }, | 287 }, |
294 { 0, // times_to_lose_during_commit | 288 {0, // times_to_lose_during_commit |
295 10, // times_to_lose_during_draw | 289 10, // times_to_lose_during_draw |
296 0, // times_to_fail_recreate | 290 0, // times_to_fail_recreate |
297 0, // times_to_fail_recreate_offscreen | 291 0, // times_to_fail_recreate_offscreen |
298 false, // fallback_context_works | 292 false, // fallback_context_works |
299 }, | 293 }, |
300 // Losing the context, failing to reinitialize it, and making a fallback | 294 // Losing the context, failing to reinitialize it, and making a fallback |
301 // context should work. | 295 // context should work. |
302 { 0, // times_to_lose_during_commit | 296 {0, // times_to_lose_during_commit |
303 1, // times_to_lose_during_draw | 297 1, // times_to_lose_during_draw |
304 0, // times_to_fail_recreate | 298 0, // times_to_fail_recreate |
305 0, // times_to_fail_recreate_offscreen | 299 0, // times_to_fail_recreate_offscreen |
306 true, // fallback_context_works | 300 true, // fallback_context_works |
307 }, | 301 }, }; |
308 }; | |
309 | 302 |
310 if (test_case_ >= arraysize(kTests)) | 303 if (test_case_ >= arraysize(kTests)) |
311 return false; | 304 return false; |
312 // Make sure that we lost our context at least once in the last test run so | 305 // Make sure that we lost our context at least once in the last test run so |
313 // the test did something. | 306 // the test did something. |
314 EXPECT_GT(num_losses_, num_losses_last_test_case_); | 307 EXPECT_GT(num_losses_, num_losses_last_test_case_); |
315 num_losses_last_test_case_ = num_losses_; | 308 num_losses_last_test_case_ = num_losses_; |
316 | 309 |
317 times_to_lose_during_commit_ = | 310 times_to_lose_during_commit_ = |
318 kTests[test_case_].times_to_lose_during_commit; | 311 kTests[test_case_].times_to_lose_during_commit; |
319 times_to_lose_during_draw_ = | 312 times_to_lose_during_draw_ = kTests[test_case_].times_to_lose_during_draw; |
320 kTests[test_case_].times_to_lose_during_draw; | |
321 times_to_fail_recreate_ = kTests[test_case_].times_to_fail_recreate; | 313 times_to_fail_recreate_ = kTests[test_case_].times_to_fail_recreate; |
322 times_to_fail_recreate_offscreen_ = | 314 times_to_fail_recreate_offscreen_ = |
323 kTests[test_case_].times_to_fail_recreate_offscreen; | 315 kTests[test_case_].times_to_fail_recreate_offscreen; |
324 fallback_context_works_ = kTests[test_case_].fallback_context_works; | 316 fallback_context_works_ = kTests[test_case_].fallback_context_works; |
325 ++test_case_; | 317 ++test_case_; |
326 return true; | 318 return true; |
327 } | 319 } |
328 | 320 |
329 struct TestCase { | 321 struct TestCase { |
330 int times_to_lose_during_commit; | 322 int times_to_lose_during_commit; |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 scoped_refptr<Layer> root_; | 621 scoped_refptr<Layer> root_; |
630 scoped_refptr<ContentLayer> content_; | 622 scoped_refptr<ContentLayer> content_; |
631 }; | 623 }; |
632 | 624 |
633 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestOffscreenContextFails); | 625 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestOffscreenContextFails); |
634 | 626 |
635 class LayerTreeHostContextTestLostContextFails | 627 class LayerTreeHostContextTestLostContextFails |
636 : public LayerTreeHostContextTest { | 628 : public LayerTreeHostContextTest { |
637 public: | 629 public: |
638 LayerTreeHostContextTestLostContextFails() | 630 LayerTreeHostContextTestLostContextFails() |
639 : LayerTreeHostContextTest(), | 631 : LayerTreeHostContextTest(), num_commits_(0), first_initialized_(false) { |
640 num_commits_(0), | |
641 first_initialized_(false) { | |
642 times_to_lose_during_commit_ = 1; | 632 times_to_lose_during_commit_ = 1; |
643 } | 633 } |
644 | 634 |
645 virtual void BeginTest() OVERRIDE { | 635 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
646 PostSetNeedsCommitToMainThread(); | |
647 } | |
648 | 636 |
649 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { | 637 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { |
650 if (first_initialized_) { | 638 if (first_initialized_) { |
651 EXPECT_FALSE(succeeded); | 639 EXPECT_FALSE(succeeded); |
652 EndTest(); | 640 EndTest(); |
653 } else { | 641 } else { |
654 first_initialized_ = true; | 642 first_initialized_ = true; |
655 } | 643 } |
656 } | 644 } |
657 | 645 |
(...skipping 30 matching lines...) Expand all Loading... |
688 layer_(FakeContentLayer::Create(&client_)), | 676 layer_(FakeContentLayer::Create(&client_)), |
689 impl_host_(0), | 677 impl_host_(0), |
690 num_commits_(0) {} | 678 num_commits_(0) {} |
691 | 679 |
692 virtual void SetupTree() OVERRIDE { | 680 virtual void SetupTree() OVERRIDE { |
693 layer_->SetBounds(gfx::Size(10, 20)); | 681 layer_->SetBounds(gfx::Size(10, 20)); |
694 layer_tree_host()->SetRootLayer(layer_); | 682 layer_tree_host()->SetRootLayer(layer_); |
695 LayerTreeHostContextTest::SetupTree(); | 683 LayerTreeHostContextTest::SetupTree(); |
696 } | 684 } |
697 | 685 |
698 virtual void BeginTest() OVERRIDE { | 686 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
699 PostSetNeedsCommitToMainThread(); | |
700 } | |
701 | 687 |
702 void PostEvictTextures() { | 688 void PostEvictTextures() { |
703 if (HasImplThread()) { | 689 if (HasImplThread()) { |
704 ImplThreadTaskRunner()->PostTask( | 690 ImplThreadTaskRunner()->PostTask( |
705 FROM_HERE, | 691 FROM_HERE, |
706 base::Bind( | 692 base::Bind(&LayerTreeHostContextTestLostContextAndEvictTextures:: |
707 &LayerTreeHostContextTestLostContextAndEvictTextures:: | 693 EvictTexturesOnImplThread, |
708 EvictTexturesOnImplThread, | 694 base::Unretained(this))); |
709 base::Unretained(this))); | |
710 } else { | 695 } else { |
711 DebugScopedSetImplThread impl(proxy()); | 696 DebugScopedSetImplThread impl(proxy()); |
712 EvictTexturesOnImplThread(); | 697 EvictTexturesOnImplThread(); |
713 } | 698 } |
714 } | 699 } |
715 | 700 |
716 void EvictTexturesOnImplThread() { | 701 void EvictTexturesOnImplThread() { |
717 impl_host_->EvictTexturesForTesting(); | 702 impl_host_->EvictTexturesForTesting(); |
718 if (lose_after_evict_) | 703 if (lose_after_evict_) |
719 LoseContext(); | 704 LoseContext(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 FakeContentLayer::Create(&client_); | 829 FakeContentLayer::Create(&client_); |
845 child->SetPosition(gfx::PointF(i, 0.f)); | 830 child->SetPosition(gfx::PointF(i, 0.f)); |
846 child->SetBounds(gfx::Size(1, 1)); | 831 child->SetBounds(gfx::Size(1, 1)); |
847 parent_->AddChild(child); | 832 parent_->AddChild(child); |
848 } | 833 } |
849 | 834 |
850 layer_tree_host()->SetRootLayer(parent_); | 835 layer_tree_host()->SetRootLayer(parent_); |
851 LayerTreeHostContextTest::SetupTree(); | 836 LayerTreeHostContextTest::SetupTree(); |
852 } | 837 } |
853 | 838 |
854 virtual void BeginTest() OVERRIDE { | 839 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
855 PostSetNeedsCommitToMainThread(); | |
856 } | |
857 | 840 |
858 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 841 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
859 EXPECT_EQ(0, times_to_lose_on_end_query_); | 842 EXPECT_EQ(0, times_to_lose_on_end_query_); |
860 EndTest(); | 843 EndTest(); |
861 } | 844 } |
862 | 845 |
863 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { | 846 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { |
864 EXPECT_TRUE(succeeded); | 847 EXPECT_TRUE(succeeded); |
865 } | 848 } |
866 | 849 |
867 virtual void AfterTest() OVERRIDE { | 850 virtual void AfterTest() OVERRIDE { |
868 EXPECT_EQ(0, times_to_lose_on_end_query_); | 851 EXPECT_EQ(0, times_to_lose_on_end_query_); |
869 } | 852 } |
870 | 853 |
871 private: | 854 private: |
872 FakeContentLayerClient client_; | 855 FakeContentLayerClient client_; |
873 scoped_refptr<FakeContentLayer> parent_; | 856 scoped_refptr<FakeContentLayer> parent_; |
874 int num_children_; | 857 int num_children_; |
875 int times_to_lose_on_end_query_; | 858 int times_to_lose_on_end_query_; |
876 }; | 859 }; |
877 | 860 |
878 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( | 861 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( |
879 LayerTreeHostContextTestLostContextWhileUpdatingResources); | 862 LayerTreeHostContextTestLostContextWhileUpdatingResources); |
880 | 863 |
881 class LayerTreeHostContextTestLayersNotified | 864 class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest { |
882 : public LayerTreeHostContextTest { | |
883 public: | 865 public: |
884 LayerTreeHostContextTestLayersNotified() | 866 LayerTreeHostContextTestLayersNotified() |
885 : LayerTreeHostContextTest(), | 867 : LayerTreeHostContextTest(), num_commits_(0) {} |
886 num_commits_(0) {} | |
887 | 868 |
888 virtual void SetupTree() OVERRIDE { | 869 virtual void SetupTree() OVERRIDE { |
889 root_ = FakeContentLayer::Create(&client_); | 870 root_ = FakeContentLayer::Create(&client_); |
890 child_ = FakeContentLayer::Create(&client_); | 871 child_ = FakeContentLayer::Create(&client_); |
891 grandchild_ = FakeContentLayer::Create(&client_); | 872 grandchild_ = FakeContentLayer::Create(&client_); |
892 | 873 |
893 root_->AddChild(child_); | 874 root_->AddChild(child_); |
894 child_->AddChild(grandchild_); | 875 child_->AddChild(grandchild_); |
895 | 876 |
896 layer_tree_host()->SetRootLayer(root_); | 877 layer_tree_host()->SetRootLayer(root_); |
897 LayerTreeHostContextTest::SetupTree(); | 878 LayerTreeHostContextTest::SetupTree(); |
898 } | 879 } |
899 | 880 |
900 virtual void BeginTest() OVERRIDE { | 881 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
901 PostSetNeedsCommitToMainThread(); | |
902 } | |
903 | 882 |
904 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 883 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
905 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); | 884 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); |
906 | 885 |
907 FakeContentLayerImpl* root = static_cast<FakeContentLayerImpl*>( | 886 FakeContentLayerImpl* root = static_cast<FakeContentLayerImpl*>( |
908 host_impl->active_tree()->root_layer()); | 887 host_impl->active_tree()->root_layer()); |
909 FakeContentLayerImpl* child = static_cast<FakeContentLayerImpl*>( | 888 FakeContentLayerImpl* child = |
910 root->children()[0]); | 889 static_cast<FakeContentLayerImpl*>(root->children()[0]); |
911 FakeContentLayerImpl* grandchild = static_cast<FakeContentLayerImpl*>( | 890 FakeContentLayerImpl* grandchild = |
912 child->children()[0]); | 891 static_cast<FakeContentLayerImpl*>(child->children()[0]); |
913 | 892 |
914 ++num_commits_; | 893 ++num_commits_; |
915 switch (num_commits_) { | 894 switch (num_commits_) { |
916 case 1: | 895 case 1: |
917 EXPECT_EQ(0u, root->lost_output_surface_count()); | 896 EXPECT_EQ(0u, root->lost_output_surface_count()); |
918 EXPECT_EQ(0u, child->lost_output_surface_count()); | 897 EXPECT_EQ(0u, child->lost_output_surface_count()); |
919 EXPECT_EQ(0u, grandchild->lost_output_surface_count()); | 898 EXPECT_EQ(0u, grandchild->lost_output_surface_count()); |
920 // Lose the context and struggle to recreate it. | 899 // Lose the context and struggle to recreate it. |
921 LoseContext(); | 900 LoseContext(); |
922 times_to_fail_create_ = 1; | 901 times_to_fail_create_ = 1; |
(...skipping 18 matching lines...) Expand all Loading... |
941 scoped_refptr<FakeContentLayer> root_; | 920 scoped_refptr<FakeContentLayer> root_; |
942 scoped_refptr<FakeContentLayer> child_; | 921 scoped_refptr<FakeContentLayer> child_; |
943 scoped_refptr<FakeContentLayer> grandchild_; | 922 scoped_refptr<FakeContentLayer> grandchild_; |
944 }; | 923 }; |
945 | 924 |
946 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified); | 925 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified); |
947 | 926 |
948 class LayerTreeHostContextTestDontUseLostResources | 927 class LayerTreeHostContextTestDontUseLostResources |
949 : public LayerTreeHostContextTest { | 928 : public LayerTreeHostContextTest { |
950 public: | 929 public: |
951 LayerTreeHostContextTestDontUseLostResources() | 930 LayerTreeHostContextTestDontUseLostResources() : lost_context_(false) { |
952 : lost_context_(false) { | |
953 context_should_support_io_surface_ = true; | 931 context_should_support_io_surface_ = true; |
954 | 932 |
955 child_output_surface_ = FakeOutputSurface::Create3d(); | 933 child_output_surface_ = FakeOutputSurface::Create3d(); |
956 child_output_surface_->BindToClient(&output_surface_client_); | 934 child_output_surface_->BindToClient(&output_surface_client_); |
957 child_resource_provider_ = | 935 child_resource_provider_ = ResourceProvider::Create( |
958 ResourceProvider::Create(child_output_surface_.get(), | 936 child_output_surface_.get(), NULL, 0, false, 1); |
959 NULL, | |
960 0, | |
961 false, | |
962 1); | |
963 } | 937 } |
964 | 938 |
965 static void EmptyReleaseCallback(unsigned sync_point, bool lost) {} | 939 static void EmptyReleaseCallback(unsigned sync_point, bool lost) {} |
966 | 940 |
967 virtual void SetupTree() OVERRIDE { | 941 virtual void SetupTree() OVERRIDE { |
968 gpu::gles2::GLES2Interface* gl = | 942 gpu::gles2::GLES2Interface* gl = |
969 child_output_surface_->context_provider()->ContextGL(); | 943 child_output_surface_->context_provider()->ContextGL(); |
970 | 944 |
971 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 945 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
972 | 946 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 content->SetAnchorPoint(gfx::PointF()); | 997 content->SetAnchorPoint(gfx::PointF()); |
1024 content->SetIsDrawable(true); | 998 content->SetIsDrawable(true); |
1025 root->AddChild(content); | 999 root->AddChild(content); |
1026 | 1000 |
1027 scoped_refptr<TextureLayer> texture = TextureLayer::CreateForMailbox(NULL); | 1001 scoped_refptr<TextureLayer> texture = TextureLayer::CreateForMailbox(NULL); |
1028 texture->SetBounds(gfx::Size(10, 10)); | 1002 texture->SetBounds(gfx::Size(10, 10)); |
1029 texture->SetAnchorPoint(gfx::PointF()); | 1003 texture->SetAnchorPoint(gfx::PointF()); |
1030 texture->SetIsDrawable(true); | 1004 texture->SetIsDrawable(true); |
1031 texture->SetTextureMailbox( | 1005 texture->SetTextureMailbox( |
1032 TextureMailbox(mailbox, sync_point), | 1006 TextureMailbox(mailbox, sync_point), |
1033 SingleReleaseCallback::Create(base::Bind( | 1007 SingleReleaseCallback::Create( |
1034 &LayerTreeHostContextTestDontUseLostResources:: | 1008 base::Bind(&LayerTreeHostContextTestDontUseLostResources:: |
1035 EmptyReleaseCallback))); | 1009 EmptyReleaseCallback))); |
1036 root->AddChild(texture); | 1010 root->AddChild(texture); |
1037 | 1011 |
1038 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client_); | 1012 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client_); |
1039 mask->SetBounds(gfx::Size(10, 10)); | 1013 mask->SetBounds(gfx::Size(10, 10)); |
1040 mask->SetAnchorPoint(gfx::PointF()); | 1014 mask->SetAnchorPoint(gfx::PointF()); |
1041 | 1015 |
1042 scoped_refptr<ContentLayer> content_with_mask = | 1016 scoped_refptr<ContentLayer> content_with_mask = |
1043 ContentLayer::Create(&client_); | 1017 ContentLayer::Create(&client_); |
1044 content_with_mask->SetBounds(gfx::Size(10, 10)); | 1018 content_with_mask->SetBounds(gfx::Size(10, 10)); |
1045 content_with_mask->SetAnchorPoint(gfx::PointF()); | 1019 content_with_mask->SetAnchorPoint(gfx::PointF()); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 LayerTreeHostImpl::FrameData* frame, | 1118 LayerTreeHostImpl::FrameData* frame, |
1145 bool result) OVERRIDE { | 1119 bool result) OVERRIDE { |
1146 if (host_impl->active_tree()->source_frame_number() == 2) { | 1120 if (host_impl->active_tree()->source_frame_number() == 2) { |
1147 // Lose the context during draw on the second commit. This will cause | 1121 // Lose the context during draw on the second commit. This will cause |
1148 // a third commit to recover. | 1122 // a third commit to recover. |
1149 context3d_->set_times_bind_texture_succeeds(0); | 1123 context3d_->set_times_bind_texture_succeeds(0); |
1150 } | 1124 } |
1151 return true; | 1125 return true; |
1152 } | 1126 } |
1153 | 1127 |
1154 virtual scoped_ptr<OutputSurface> CreateOutputSurface( | 1128 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) |
1155 bool fallback) OVERRIDE { | 1129 OVERRIDE { |
1156 // This will get called twice: | 1130 // This will get called twice: |
1157 // First when we create the initial output surface... | 1131 // First when we create the initial output surface... |
1158 if (layer_tree_host()->source_frame_number() > 0) { | 1132 if (layer_tree_host()->source_frame_number() > 0) { |
1159 // ... and then again after we forced the context to be lost on the third | 1133 // ... and then again after we forced the context to be lost on the third |
1160 // frame. Verify this assumption here. | 1134 // frame. Verify this assumption here. |
1161 lost_context_ = true; | 1135 lost_context_ = true; |
1162 EXPECT_EQ(layer_tree_host()->source_frame_number(), 3); | 1136 EXPECT_EQ(layer_tree_host()->source_frame_number(), 3); |
1163 } | 1137 } |
1164 return LayerTreeHostContextTest::CreateOutputSurface(fallback); | 1138 return LayerTreeHostContextTest::CreateOutputSurface(fallback); |
1165 } | 1139 } |
1166 | 1140 |
1167 virtual void DidCommitAndDrawFrame() OVERRIDE { | 1141 virtual void DidCommitAndDrawFrame() OVERRIDE { |
1168 ASSERT_TRUE(layer_tree_host()->hud_layer()); | 1142 ASSERT_TRUE(layer_tree_host()->hud_layer()); |
1169 // End the test once we know the 3nd frame drew. | 1143 // End the test once we know the 3nd frame drew. |
1170 if (layer_tree_host()->source_frame_number() < 4) { | 1144 if (layer_tree_host()->source_frame_number() < 4) { |
1171 layer_tree_host()->root_layer()->SetNeedsDisplay(); | 1145 layer_tree_host()->root_layer()->SetNeedsDisplay(); |
1172 layer_tree_host()->SetNeedsCommit(); | 1146 layer_tree_host()->SetNeedsCommit(); |
1173 } else { | 1147 } else { |
1174 EndTest(); | 1148 EndTest(); |
1175 } | 1149 } |
1176 } | 1150 } |
1177 | 1151 |
1178 virtual void AfterTest() OVERRIDE { | 1152 virtual void AfterTest() OVERRIDE { EXPECT_TRUE(lost_context_); } |
1179 EXPECT_TRUE(lost_context_); | |
1180 } | |
1181 | 1153 |
1182 private: | 1154 private: |
1183 FakeContentLayerClient client_; | 1155 FakeContentLayerClient client_; |
1184 bool lost_context_; | 1156 bool lost_context_; |
1185 | 1157 |
1186 FakeOutputSurfaceClient output_surface_client_; | 1158 FakeOutputSurfaceClient output_surface_client_; |
1187 scoped_ptr<FakeOutputSurface> child_output_surface_; | 1159 scoped_ptr<FakeOutputSurface> child_output_surface_; |
1188 scoped_ptr<ResourceProvider> child_resource_provider_; | 1160 scoped_ptr<ResourceProvider> child_resource_provider_; |
1189 | 1161 |
1190 scoped_refptr<DelegatedFrameResourceCollection> | 1162 scoped_refptr<DelegatedFrameResourceCollection> |
(...skipping 20 matching lines...) Expand all Loading... |
1211 ASSERT_TRUE(layer_tree_host()->output_surface_lost()); | 1183 ASSERT_TRUE(layer_tree_host()->output_surface_lost()); |
1212 | 1184 |
1213 times_output_surface_created_ = 0; | 1185 times_output_surface_created_ = 0; |
1214 | 1186 |
1215 // Post the SetNeedsCommit before the readback to make sure it is run | 1187 // Post the SetNeedsCommit before the readback to make sure it is run |
1216 // on the main thread before the readback's replacement commit when | 1188 // on the main thread before the readback's replacement commit when |
1217 // we have a threaded compositor. | 1189 // we have a threaded compositor. |
1218 PostSetNeedsCommitToMainThread(); | 1190 PostSetNeedsCommitToMainThread(); |
1219 | 1191 |
1220 char pixels[4]; | 1192 char pixels[4]; |
1221 bool result = layer_tree_host()->CompositeAndReadback( | 1193 bool result = |
1222 &pixels, gfx::Rect(1, 1)); | 1194 layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(1, 1)); |
1223 EXPECT_EQ(!delegating_renderer(), result); | 1195 EXPECT_EQ(!delegating_renderer(), result); |
1224 EXPECT_EQ(1, times_output_surface_created_); | 1196 EXPECT_EQ(1, times_output_surface_created_); |
1225 } | 1197 } |
1226 | 1198 |
1227 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { | 1199 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { |
1228 EXPECT_TRUE(succeeded); | 1200 EXPECT_TRUE(succeeded); |
1229 ++times_output_surface_created_; | 1201 ++times_output_surface_created_; |
1230 } | 1202 } |
1231 | 1203 |
1232 virtual void DidCommitAndDrawFrame() OVERRIDE { | 1204 virtual void DidCommitAndDrawFrame() OVERRIDE { EndTest(); } |
1233 EndTest(); | |
1234 } | |
1235 | 1205 |
1236 virtual void AfterTest() OVERRIDE { | 1206 virtual void AfterTest() OVERRIDE { |
1237 // Should not try to create output surface again after successfully | 1207 // Should not try to create output surface again after successfully |
1238 // created by CompositeAndReadback. | 1208 // created by CompositeAndReadback. |
1239 EXPECT_EQ(1, times_output_surface_created_); | 1209 EXPECT_EQ(1, times_output_surface_created_); |
1240 } | 1210 } |
1241 | 1211 |
1242 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 1212 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
1243 LayerTreeHostImpl::FrameData* frame_data, | 1213 LayerTreeHostImpl::FrameData* frame_data, |
1244 bool result) OVERRIDE { | 1214 bool result) OVERRIDE { |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 }; | 1448 }; |
1479 | 1449 |
1480 MULTI_THREAD_TEST_F(LayerTreeHostContextTestImplSidePainting); | 1450 MULTI_THREAD_TEST_F(LayerTreeHostContextTestImplSidePainting); |
1481 | 1451 |
1482 class ScrollbarLayerLostContext : public LayerTreeHostContextTest { | 1452 class ScrollbarLayerLostContext : public LayerTreeHostContextTest { |
1483 public: | 1453 public: |
1484 ScrollbarLayerLostContext() : commits_(0) {} | 1454 ScrollbarLayerLostContext() : commits_(0) {} |
1485 | 1455 |
1486 virtual void BeginTest() OVERRIDE { | 1456 virtual void BeginTest() OVERRIDE { |
1487 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 1457 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
1488 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( | 1458 scrollbar_layer_ = |
1489 false, true, scroll_layer->id()); | 1459 FakePaintedScrollbarLayer::Create(false, true, scroll_layer->id()); |
1490 scrollbar_layer_->SetBounds(gfx::Size(10, 100)); | 1460 scrollbar_layer_->SetBounds(gfx::Size(10, 100)); |
1491 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); | 1461 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); |
1492 layer_tree_host()->root_layer()->AddChild(scroll_layer); | 1462 layer_tree_host()->root_layer()->AddChild(scroll_layer); |
1493 PostSetNeedsCommitToMainThread(); | 1463 PostSetNeedsCommitToMainThread(); |
1494 } | 1464 } |
1495 | 1465 |
1496 virtual void AfterTest() OVERRIDE {} | 1466 virtual void AfterTest() OVERRIDE {} |
1497 | 1467 |
1498 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1468 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
1499 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1469 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 // DidActivateTreeOnThread, which happens after DidCommit with impl-side | 1517 // DidActivateTreeOnThread, which happens after DidCommit with impl-side |
1548 // painting. | 1518 // painting. |
1549 virtual void StepCompleteOnMainThread(int time_step) = 0; | 1519 virtual void StepCompleteOnMainThread(int time_step) = 0; |
1550 | 1520 |
1551 // Called after DidActivateTreeOnThread. If this is done during the commit, | 1521 // Called after DidActivateTreeOnThread. If this is done during the commit, |
1552 // the call to StepCompleteOnMainThread will not occur until after | 1522 // the call to StepCompleteOnMainThread will not occur until after |
1553 // the commit completes, because the main thread is blocked. | 1523 // the commit completes, because the main thread is blocked. |
1554 void PostStepCompleteToMainThread() { | 1524 void PostStepCompleteToMainThread() { |
1555 proxy()->MainThreadTaskRunner()->PostTask( | 1525 proxy()->MainThreadTaskRunner()->PostTask( |
1556 FROM_HERE, | 1526 FROM_HERE, |
1557 base::Bind( | 1527 base::Bind(&UIResourceLostTest::StepCompleteOnMainThreadInternal, |
1558 &UIResourceLostTest::StepCompleteOnMainThreadInternal, | 1528 base::Unretained(this), |
1559 base::Unretained(this), | 1529 time_step_)); |
1560 time_step_)); | |
1561 } | 1530 } |
1562 | 1531 |
1563 void PostLoseContextToImplThread() { | 1532 void PostLoseContextToImplThread() { |
1564 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); | 1533 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
1565 base::SingleThreadTaskRunner* task_runner = | 1534 base::SingleThreadTaskRunner* task_runner = |
1566 HasImplThread() ? ImplThreadTaskRunner() | 1535 HasImplThread() ? ImplThreadTaskRunner() |
1567 : base::MessageLoopProxy::current(); | 1536 : base::MessageLoopProxy::current(); |
1568 task_runner->PostTask( | 1537 task_runner->PostTask(FROM_HERE, |
1569 FROM_HERE, | 1538 base::Bind(&LayerTreeHostContextTest::LoseContext, |
1570 base::Bind( | 1539 base::Unretained(this))); |
1571 &LayerTreeHostContextTest::LoseContext, | |
1572 base::Unretained(this))); | |
1573 } | 1540 } |
1574 | 1541 |
1575 protected: | 1542 protected: |
1576 int time_step_; | 1543 int time_step_; |
1577 scoped_ptr<FakeScopedUIResource> ui_resource_; | 1544 scoped_ptr<FakeScopedUIResource> ui_resource_; |
1578 | 1545 |
1579 private: | 1546 private: |
1580 void StepCompleteOnMainThreadInternal(int step) { | 1547 void StepCompleteOnMainThreadInternal(int step) { |
1581 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); | 1548 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
1582 StepCompleteOnMainThread(step); | 1549 StepCompleteOnMainThread(step); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1664 // of creation/deletion are considered: | 1631 // of creation/deletion are considered: |
1665 // 1. Create one resource -> Context Lost => Expect the resource to have been | 1632 // 1. Create one resource -> Context Lost => Expect the resource to have been |
1666 // created. | 1633 // created. |
1667 // 2. Delete an exisiting resource (test_id0_) -> create a second resource | 1634 // 2. Delete an exisiting resource (test_id0_) -> create a second resource |
1668 // (test_id1_) -> Context Lost => Expect the test_id0_ to be removed and | 1635 // (test_id1_) -> Context Lost => Expect the test_id0_ to be removed and |
1669 // test_id1_ to have been created. | 1636 // test_id1_ to have been created. |
1670 // 3. Create one resource -> Delete that same resource -> Context Lost => Expect | 1637 // 3. Create one resource -> Delete that same resource -> Context Lost => Expect |
1671 // the resource to not exist in the manager. | 1638 // the resource to not exist in the manager. |
1672 class UIResourceLostBeforeCommit : public UIResourceLostTestSimple { | 1639 class UIResourceLostBeforeCommit : public UIResourceLostTestSimple { |
1673 public: | 1640 public: |
1674 UIResourceLostBeforeCommit() | 1641 UIResourceLostBeforeCommit() : test_id0_(0), test_id1_(0) {} |
1675 : test_id0_(0), | |
1676 test_id1_(0) {} | |
1677 | 1642 |
1678 virtual void StepCompleteOnMainThread(int step) OVERRIDE { | 1643 virtual void StepCompleteOnMainThread(int step) OVERRIDE { |
1679 switch (step) { | 1644 switch (step) { |
1680 case 0: | 1645 case 0: |
1681 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1646 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
1682 // Lose the context on the impl thread before the commit. | 1647 // Lose the context on the impl thread before the commit. |
1683 PostLoseContextToImplThread(); | 1648 PostLoseContextToImplThread(); |
1684 break; | 1649 break; |
1685 case 2: | 1650 case 2: |
1686 // Sequence 2: | 1651 // Sequence 2: |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 ui_resource_.reset(); | 1856 ui_resource_.reset(); |
1892 EndTest(); | 1857 EndTest(); |
1893 break; | 1858 break; |
1894 case 4: | 1859 case 4: |
1895 NOTREACHED(); | 1860 NOTREACHED(); |
1896 } | 1861 } |
1897 } | 1862 } |
1898 | 1863 |
1899 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* impl, | 1864 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* impl, |
1900 bool visible) OVERRIDE { | 1865 bool visible) OVERRIDE { |
1901 TestWebGraphicsContext3D* context = static_cast<TestContextProvider*>( | 1866 TestWebGraphicsContext3D* context = TestContext(); |
1902 impl->output_surface()->context_provider().get())->TestContext3d(); | |
1903 if (!visible) { | 1867 if (!visible) { |
1904 // All resources should have been evicted. | 1868 // All resources should have been evicted. |
1905 ASSERT_EQ(0u, context->NumTextures()); | 1869 ASSERT_EQ(0u, context->NumTextures()); |
1906 EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | 1870 EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
1907 EXPECT_EQ(2, ui_resource_->resource_create_count); | 1871 EXPECT_EQ(2, ui_resource_->resource_create_count); |
1908 EXPECT_EQ(1, ui_resource_->lost_resource_count); | 1872 EXPECT_EQ(1, ui_resource_->lost_resource_count); |
1909 // Drawing is disabled both because of the evicted resources and | 1873 // Drawing is disabled both because of the evicted resources and |
1910 // because the renderer is not visible. | 1874 // because the renderer is not visible. |
1911 EXPECT_FALSE(impl->CanDraw()); | 1875 EXPECT_FALSE(impl->CanDraw()); |
1912 // Make the renderer visible again. | 1876 // Make the renderer visible again. |
1913 PostSetVisibleToMainThread(true); | 1877 PostSetVisibleToMainThread(true); |
1914 } | 1878 } |
1915 } | 1879 } |
1916 | 1880 |
1917 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) OVERRIDE { | 1881 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) OVERRIDE { |
1918 TestWebGraphicsContext3D* context = static_cast<TestContextProvider*>( | 1882 TestWebGraphicsContext3D* context = TestContext(); |
1919 impl->output_surface()->context_provider().get())->TestContext3d(); | |
1920 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1883 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
1921 switch (time_step_) { | 1884 switch (time_step_) { |
1922 case 1: | 1885 case 1: |
1923 // The resource should have been created on LTHI after the commit. | 1886 // The resource should have been created on LTHI after the commit. |
1924 ASSERT_EQ(1u, context->NumTextures()); | 1887 ASSERT_EQ(1u, context->NumTextures()); |
1925 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | 1888 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
1926 EXPECT_EQ(1, ui_resource_->resource_create_count); | 1889 EXPECT_EQ(1, ui_resource_->resource_create_count); |
1927 EXPECT_EQ(0, ui_resource_->lost_resource_count); | 1890 EXPECT_EQ(0, ui_resource_->lost_resource_count); |
1928 EXPECT_TRUE(impl->CanDraw()); | 1891 EXPECT_TRUE(impl->CanDraw()); |
1929 // Evict all UI resources. This will trigger a commit. | 1892 // Evict all UI resources. This will trigger a commit. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1964 : LayerTreeHostContextTest(), | 1927 : LayerTreeHostContextTest(), |
1965 layer_(FakeContentLayer::Create(&client_)), | 1928 layer_(FakeContentLayer::Create(&client_)), |
1966 num_commits_(0) {} | 1929 num_commits_(0) {} |
1967 | 1930 |
1968 virtual void SetupTree() OVERRIDE { | 1931 virtual void SetupTree() OVERRIDE { |
1969 layer_->SetBounds(gfx::Size(10, 20)); | 1932 layer_->SetBounds(gfx::Size(10, 20)); |
1970 layer_tree_host()->SetRootLayer(layer_); | 1933 layer_tree_host()->SetRootLayer(layer_); |
1971 LayerTreeHostContextTest::SetupTree(); | 1934 LayerTreeHostContextTest::SetupTree(); |
1972 } | 1935 } |
1973 | 1936 |
1974 virtual void BeginTest() OVERRIDE { | 1937 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
1975 PostSetNeedsCommitToMainThread(); | |
1976 } | |
1977 | 1938 |
1978 virtual void DidCommit() OVERRIDE { | 1939 virtual void DidCommit() OVERRIDE { |
1979 switch (num_commits_) { | 1940 switch (num_commits_) { |
1980 case 0: | 1941 case 0: |
1981 EXPECT_EQ(1u, layer_->output_surface_created_count()); | 1942 EXPECT_EQ(1u, layer_->output_surface_created_count()); |
1982 layer_tree_host()->SetNeedsCommit(); | 1943 layer_tree_host()->SetNeedsCommit(); |
1983 break; | 1944 break; |
1984 case 1: | 1945 case 1: |
1985 EXPECT_EQ(1u, layer_->output_surface_created_count()); | 1946 EXPECT_EQ(1u, layer_->output_surface_created_count()); |
1986 layer_tree_host()->SetNeedsCommit(); | 1947 layer_tree_host()->SetNeedsCommit(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 protected: | 1982 protected: |
2022 FakeContentLayerClient client_; | 1983 FakeContentLayerClient client_; |
2023 scoped_refptr<FakeContentLayer> layer_; | 1984 scoped_refptr<FakeContentLayer> layer_; |
2024 int num_commits_; | 1985 int num_commits_; |
2025 }; | 1986 }; |
2026 | 1987 |
2027 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); | 1988 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); |
2028 | 1989 |
2029 } // namespace | 1990 } // namespace |
2030 } // namespace cc | 1991 } // namespace cc |
OLD | NEW |