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/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "cc/content_layer.h" | 8 #include "cc/content_layer.h" |
9 #include "cc/delegated_renderer_layer.h" | 9 #include "cc/delegated_renderer_layer.h" |
10 #include "cc/delegated_renderer_layer_impl.h" | 10 #include "cc/delegated_renderer_layer_impl.h" |
11 #include "cc/heads_up_display_layer.h" | 11 #include "cc/heads_up_display_layer.h" |
12 #include "cc/io_surface_layer.h" | 12 #include "cc/io_surface_layer.h" |
13 #include "cc/layer_impl.h" | 13 #include "cc/layer_impl.h" |
14 #include "cc/layer_tree_host_impl.h" | 14 #include "cc/layer_tree_host_impl.h" |
15 #include "cc/layer_tree_impl.h" | 15 #include "cc/layer_tree_impl.h" |
16 #include "cc/picture_layer.h" | 16 #include "cc/picture_layer.h" |
17 #include "cc/scrollbar_layer.h" | 17 #include "cc/scrollbar_layer.h" |
18 #include "cc/single_thread_proxy.h" | 18 #include "cc/single_thread_proxy.h" |
19 #include "cc/test/fake_content_layer.h" | 19 #include "cc/test/fake_content_layer.h" |
20 #include "cc/test/fake_content_layer_client.h" | 20 #include "cc/test/fake_content_layer_client.h" |
21 #include "cc/test/fake_content_layer_impl.h" | 21 #include "cc/test/fake_content_layer_impl.h" |
22 #include "cc/test/fake_output_surface.h" | 22 #include "cc/test/fake_output_surface.h" |
23 #include "cc/test/fake_scrollbar_layer.h" | 23 #include "cc/test/fake_scrollbar_layer.h" |
24 #include "cc/test/fake_scrollbar_theme_painter.h" | 24 #include "cc/test/fake_scrollbar_theme_painter.h" |
25 #include "cc/test/fake_video_frame_provider.h" | 25 #include "cc/test/fake_video_frame_provider.h" |
26 #include "cc/test/fake_web_graphics_context_3d.h" | |
27 #include "cc/test/fake_web_scrollbar.h" | 26 #include "cc/test/fake_web_scrollbar.h" |
28 #include "cc/test/fake_web_scrollbar_theme_geometry.h" | 27 #include "cc/test/fake_web_scrollbar_theme_geometry.h" |
29 #include "cc/test/layer_tree_test_common.h" | 28 #include "cc/test/layer_tree_test_common.h" |
30 #include "cc/test/render_pass_test_common.h" | 29 #include "cc/test/render_pass_test_common.h" |
| 30 #include "cc/test/test_web_graphics_context_3d.h" |
31 #include "cc/texture_layer.h" | 31 #include "cc/texture_layer.h" |
32 #include "cc/video_layer.h" | 32 #include "cc/video_layer.h" |
33 #include "cc/video_layer_impl.h" | 33 #include "cc/video_layer_impl.h" |
34 #include "gpu/GLES2/gl2extchromium.h" | 34 #include "gpu/GLES2/gl2extchromium.h" |
35 #include "media/base/media.h" | 35 #include "media/base/media.h" |
36 | 36 |
37 using media::VideoFrame; | 37 using media::VideoFrame; |
38 using WebKit::WebGraphicsContext3D; | 38 using WebKit::WebGraphicsContext3D; |
39 | 39 |
40 namespace cc { | 40 namespace cc { |
(...skipping 15 matching lines...) Expand all Loading... |
56 times_to_lose_on_recreate_(0) { | 56 times_to_lose_on_recreate_(0) { |
57 media::InitializeMediaLibraryForTesting(); | 57 media::InitializeMediaLibraryForTesting(); |
58 } | 58 } |
59 | 59 |
60 void LoseContext() { | 60 void LoseContext() { |
61 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 61 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
62 GL_INNOCENT_CONTEXT_RESET_ARB); | 62 GL_INNOCENT_CONTEXT_RESET_ARB); |
63 context3d_ = NULL; | 63 context3d_ = NULL; |
64 } | 64 } |
65 | 65 |
66 virtual scoped_ptr<FakeWebGraphicsContext3D> CreateContext3d() { | 66 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() { |
67 return FakeWebGraphicsContext3D::Create(); | 67 return TestWebGraphicsContext3D::Create(); |
68 } | 68 } |
69 | 69 |
70 virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE { | 70 virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE { |
71 if (times_to_fail_create_) { | 71 if (times_to_fail_create_) { |
72 --times_to_fail_create_; | 72 --times_to_fail_create_; |
73 return scoped_ptr<OutputSurface>(); | 73 return scoped_ptr<OutputSurface>(); |
74 } | 74 } |
75 | 75 |
76 scoped_ptr<FakeWebGraphicsContext3D> context3d = CreateContext3d(); | 76 scoped_ptr<TestWebGraphicsContext3D> context3d = CreateContext3d(); |
77 context3d_ = context3d.get(); | 77 context3d_ = context3d.get(); |
78 | 78 |
79 if (times_to_fail_initialize_) { | 79 if (times_to_fail_initialize_) { |
80 --times_to_fail_initialize_; | 80 --times_to_fail_initialize_; |
81 // Make the context get lost during reinitialization. | 81 // Make the context get lost during reinitialization. |
82 // The number of times MakeCurrent succeeds is not important, and | 82 // The number of times MakeCurrent succeeds is not important, and |
83 // can be changed if needed to make this pass with future changes. | 83 // can be changed if needed to make this pass with future changes. |
84 context3d_->set_times_make_current_succeeds(2); | 84 context3d_->set_times_make_current_succeeds(2); |
85 } else if (times_to_lose_on_create_) { | 85 } else if (times_to_lose_on_create_) { |
86 --times_to_lose_on_create_; | 86 --times_to_lose_on_create_; |
(...skipping 25 matching lines...) Expand all Loading... |
112 | 112 |
113 times_to_fail_create_ = times_to_fail_recreate_; | 113 times_to_fail_create_ = times_to_fail_recreate_; |
114 times_to_fail_recreate_ = 0; | 114 times_to_fail_recreate_ = 0; |
115 times_to_fail_initialize_ = times_to_fail_reinitialize_; | 115 times_to_fail_initialize_ = times_to_fail_reinitialize_; |
116 times_to_fail_reinitialize_ = 0; | 116 times_to_fail_reinitialize_ = 0; |
117 times_to_lose_on_create_ = times_to_lose_on_recreate_; | 117 times_to_lose_on_create_ = times_to_lose_on_recreate_; |
118 times_to_lose_on_recreate_ = 0; | 118 times_to_lose_on_recreate_ = 0; |
119 } | 119 } |
120 | 120 |
121 protected: | 121 protected: |
122 FakeWebGraphicsContext3D* context3d_; | 122 TestWebGraphicsContext3D* context3d_; |
123 int times_to_fail_create_; | 123 int times_to_fail_create_; |
124 int times_to_fail_initialize_; | 124 int times_to_fail_initialize_; |
125 int times_to_lose_on_create_; | 125 int times_to_lose_on_create_; |
126 int times_to_lose_during_commit_; | 126 int times_to_lose_during_commit_; |
127 int times_to_lose_during_draw_; | 127 int times_to_lose_during_draw_; |
128 int times_to_fail_reinitialize_; | 128 int times_to_fail_reinitialize_; |
129 int times_to_fail_recreate_; | 129 int times_to_fail_recreate_; |
130 int times_to_lose_on_recreate_; | 130 int times_to_lose_on_recreate_; |
131 }; | 131 }; |
132 | 132 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 // surface. We want to make sure to test the drawing paths for drawing to | 297 // surface. We want to make sure to test the drawing paths for drawing to |
298 // a child surface. | 298 // a child surface. |
299 content_->setNeedsDisplay(); | 299 content_->setNeedsDisplay(); |
300 LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit(); | 300 LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit(); |
301 } | 301 } |
302 | 302 |
303 virtual void drawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 303 virtual void drawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
304 FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>( | 304 FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>( |
305 host_impl->rootLayer()->children()[0]); | 305 host_impl->rootLayer()->children()[0]); |
306 // Even though the context was lost, we should have a resource. The | 306 // Even though the context was lost, we should have a resource. The |
307 // FakeWebGraphicsContext3D ensures that this resource is created with | 307 // TestWebGraphicsContext3D ensures that this resource is created with |
308 // the active context. | 308 // the active context. |
309 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); | 309 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); |
310 } | 310 } |
311 | 311 |
312 protected: | 312 protected: |
313 bool use_surface_; | 313 bool use_surface_; |
314 FakeContentLayerClient client_; | 314 FakeContentLayerClient client_; |
315 scoped_refptr<Layer> root_; | 315 scoped_refptr<Layer> root_; |
316 scoped_refptr<ContentLayer> content_; | 316 scoped_refptr<ContentLayer> content_; |
317 }; | 317 }; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 | 542 |
543 class LayerTreeHostContextTestLostContextWhileUpdatingResources : | 543 class LayerTreeHostContextTestLostContextWhileUpdatingResources : |
544 public LayerTreeHostContextTest { | 544 public LayerTreeHostContextTest { |
545 public: | 545 public: |
546 LayerTreeHostContextTestLostContextWhileUpdatingResources() | 546 LayerTreeHostContextTestLostContextWhileUpdatingResources() |
547 : parent_(FakeContentLayer::Create(&client_)), | 547 : parent_(FakeContentLayer::Create(&client_)), |
548 num_children_(50), | 548 num_children_(50), |
549 times_to_lose_on_end_query_(3) { | 549 times_to_lose_on_end_query_(3) { |
550 } | 550 } |
551 | 551 |
552 virtual scoped_ptr<FakeWebGraphicsContext3D> CreateContext3d() OVERRIDE { | 552 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() OVERRIDE { |
553 scoped_ptr<FakeWebGraphicsContext3D> context = | 553 scoped_ptr<TestWebGraphicsContext3D> context = |
554 LayerTreeHostContextTest::CreateContext3d(); | 554 LayerTreeHostContextTest::CreateContext3d(); |
555 if (times_to_lose_on_end_query_) { | 555 if (times_to_lose_on_end_query_) { |
556 --times_to_lose_on_end_query_; | 556 --times_to_lose_on_end_query_; |
557 context->set_times_end_query_succeeds(5); | 557 context->set_times_end_query_succeeds(5); |
558 } | 558 } |
559 return context.Pass(); | 559 return context.Pass(); |
560 } | 560 } |
561 | 561 |
562 virtual void setupTree() OVERRIDE { | 562 virtual void setupTree() OVERRIDE { |
563 parent_->setBounds(gfx::Size(num_children_, 1)); | 563 parent_->setBounds(gfx::Size(num_children_, 1)); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 | 703 |
704 scoped_refptr<ContentLayer> content_ = ContentLayer::create(&client_); | 704 scoped_refptr<ContentLayer> content_ = ContentLayer::create(&client_); |
705 content_->setBounds(gfx::Size(10, 10)); | 705 content_->setBounds(gfx::Size(10, 10)); |
706 content_->setAnchorPoint(gfx::PointF()); | 706 content_->setAnchorPoint(gfx::PointF()); |
707 content_->setIsDrawable(true); | 707 content_->setIsDrawable(true); |
708 root_->addChild(content_); | 708 root_->addChild(content_); |
709 | 709 |
710 scoped_refptr<TextureLayer> texture_ = TextureLayer::create(NULL); | 710 scoped_refptr<TextureLayer> texture_ = TextureLayer::create(NULL); |
711 texture_->setBounds(gfx::Size(10, 10)); | 711 texture_->setBounds(gfx::Size(10, 10)); |
712 texture_->setAnchorPoint(gfx::PointF()); | 712 texture_->setAnchorPoint(gfx::PointF()); |
713 texture_->setTextureId(FakeWebGraphicsContext3D::kExternalTextureId); | 713 texture_->setTextureId(TestWebGraphicsContext3D::kExternalTextureId); |
714 texture_->setIsDrawable(true); | 714 texture_->setIsDrawable(true); |
715 root_->addChild(texture_); | 715 root_->addChild(texture_); |
716 | 716 |
717 scoped_refptr<ContentLayer> mask_ = ContentLayer::create(&client_); | 717 scoped_refptr<ContentLayer> mask_ = ContentLayer::create(&client_); |
718 mask_->setBounds(gfx::Size(10, 10)); | 718 mask_->setBounds(gfx::Size(10, 10)); |
719 mask_->setAnchorPoint(gfx::PointF()); | 719 mask_->setAnchorPoint(gfx::PointF()); |
720 | 720 |
721 scoped_refptr<ContentLayer> content_with_mask_ = | 721 scoped_refptr<ContentLayer> content_with_mask_ = |
722 ContentLayer::create(&client_); | 722 ContentLayer::create(&client_); |
723 content_with_mask_->setBounds(gfx::Size(10, 10)); | 723 content_with_mask_->setBounds(gfx::Size(10, 10)); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 | 908 |
909 virtual ~LayerTreeHostContextTestFailsImmediately() {} | 909 virtual ~LayerTreeHostContextTestFailsImmediately() {} |
910 | 910 |
911 virtual void beginTest() OVERRIDE { | 911 virtual void beginTest() OVERRIDE { |
912 postSetNeedsCommitToMainThread(); | 912 postSetNeedsCommitToMainThread(); |
913 } | 913 } |
914 | 914 |
915 virtual void afterTest() OVERRIDE { | 915 virtual void afterTest() OVERRIDE { |
916 } | 916 } |
917 | 917 |
918 virtual scoped_ptr<FakeWebGraphicsContext3D> CreateContext3d() OVERRIDE { | 918 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() OVERRIDE { |
919 scoped_ptr<FakeWebGraphicsContext3D> context = | 919 scoped_ptr<TestWebGraphicsContext3D> context = |
920 LayerTreeHostContextTest::CreateContext3d(); | 920 LayerTreeHostContextTest::CreateContext3d(); |
921 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 921 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
922 GL_INNOCENT_CONTEXT_RESET_ARB); | 922 GL_INNOCENT_CONTEXT_RESET_ARB); |
923 return context.Pass(); | 923 return context.Pass(); |
924 } | 924 } |
925 | 925 |
926 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE { | 926 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE { |
927 EXPECT_FALSE(succeeded); | 927 EXPECT_FALSE(succeeded); |
928 // If we make it this far without crashing, we pass! | 928 // If we make it this far without crashing, we pass! |
929 endTest(); | 929 endTest(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 | 1020 |
1021 private: | 1021 private: |
1022 int commits_; | 1022 int commits_; |
1023 scoped_refptr<FakeScrollbarLayer> scrollbar_layer_; | 1023 scoped_refptr<FakeScrollbarLayer> scrollbar_layer_; |
1024 }; | 1024 }; |
1025 | 1025 |
1026 SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext) | 1026 SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext) |
1027 | 1027 |
1028 } // namespace | 1028 } // namespace |
1029 } // namespace cc | 1029 } // namespace cc |
OLD | NEW |