| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 4701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4712 } | 4712 } |
| 4713 | 4713 |
| 4714 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 4714 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 4715 | 4715 |
| 4716 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 4716 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 4717 host_impl->EvictAllUIResources(); | 4717 host_impl->EvictAllUIResources(); |
| 4718 // Existence of evicted UI resources will trigger NEW_CONTENT_TAKES_PRIORITY | 4718 // Existence of evicted UI resources will trigger NEW_CONTENT_TAKES_PRIORITY |
| 4719 // mode. Active tree should require high-res to draw after entering this | 4719 // mode. Active tree should require high-res to draw after entering this |
| 4720 // mode to ensure that high-res tiles are also required for a pending tree | 4720 // mode to ensure that high-res tiles are also required for a pending tree |
| 4721 // to be activated. | 4721 // to be activated. |
| 4722 EXPECT_TRUE(host_impl->active_tree()->RequiresHighResToDraw()); | 4722 EXPECT_TRUE(host_impl->RequiresHighResToDraw()); |
| 4723 } | 4723 } |
| 4724 | 4724 |
| 4725 virtual void DidCommit() override { | 4725 virtual void DidCommit() override { |
| 4726 int frame = layer_tree_host()->source_frame_number(); | 4726 int frame = layer_tree_host()->source_frame_number(); |
| 4727 switch (frame) { | 4727 switch (frame) { |
| 4728 case 1: | 4728 case 1: |
| 4729 PostSetNeedsCommitToMainThread(); | 4729 PostSetNeedsCommitToMainThread(); |
| 4730 break; | 4730 break; |
| 4731 case 2: | 4731 case 2: |
| 4732 ui_resource_ = nullptr; | 4732 ui_resource_ = nullptr; |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5045 virtual void DidCommit() override { layer_tree_host()->SetVisible(false); } | 5045 virtual void DidCommit() override { layer_tree_host()->SetVisible(false); } |
| 5046 | 5046 |
| 5047 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, | 5047 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, |
| 5048 bool visible) override { | 5048 bool visible) override { |
| 5049 visible_ = visible; | 5049 visible_ = visible; |
| 5050 | 5050 |
| 5051 // Once invisible, we can go visible again. | 5051 // Once invisible, we can go visible again. |
| 5052 if (!visible) { | 5052 if (!visible) { |
| 5053 PostSetVisibleToMainThread(true); | 5053 PostSetVisibleToMainThread(true); |
| 5054 } else { | 5054 } else { |
| 5055 EXPECT_TRUE(host_impl->active_tree()->RequiresHighResToDraw()); | 5055 EXPECT_TRUE(host_impl->RequiresHighResToDraw()); |
| 5056 EndTest(); | 5056 EndTest(); |
| 5057 } | 5057 } |
| 5058 } | 5058 } |
| 5059 | 5059 |
| 5060 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 5060 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 5061 ++activation_count_; | 5061 ++activation_count_; |
| 5062 EXPECT_FALSE(visible_); | 5062 EXPECT_FALSE(visible_); |
| 5063 } | 5063 } |
| 5064 | 5064 |
| 5065 virtual void AfterTest() override { | 5065 virtual void AfterTest() override { |
| 5066 // Ensure we activated even though the signal was blocked. | 5066 // Ensure we activated even though the signal was blocked. |
| 5067 EXPECT_EQ(1, activation_count_); | 5067 EXPECT_EQ(1, activation_count_); |
| 5068 EXPECT_TRUE(visible_); | 5068 EXPECT_TRUE(visible_); |
| 5069 } | 5069 } |
| 5070 | 5070 |
| 5071 private: | 5071 private: |
| 5072 int activation_count_; | 5072 int activation_count_; |
| 5073 bool visible_; | 5073 bool visible_; |
| 5074 | 5074 |
| 5075 FakeContentLayerClient client_; | 5075 FakeContentLayerClient client_; |
| 5076 scoped_refptr<FakePictureLayer> picture_layer_; | 5076 scoped_refptr<FakePictureLayer> picture_layer_; |
| 5077 }; | 5077 }; |
| 5078 | 5078 |
| 5079 // TODO(vmpstr): Enable with single thread impl-side painting. | 5079 // TODO(vmpstr): Enable with single thread impl-side painting. |
| 5080 MULTI_THREAD_TEST_F(LayerTreeHostTestActivateOnInvisible); | 5080 MULTI_THREAD_TEST_F(LayerTreeHostTestActivateOnInvisible); |
| 5081 | 5081 |
| 5082 } // namespace cc | 5082 } // namespace cc |
| OLD | NEW |