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 5005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5016 int num_draws_; | 5016 int num_draws_; |
5017 const gfx::Size bounds_; | 5017 const gfx::Size bounds_; |
5018 FakeContentLayerClient client_; | 5018 FakeContentLayerClient client_; |
5019 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 5019 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
5020 scoped_refptr<FakePictureLayer> picture_layer_; | 5020 scoped_refptr<FakePictureLayer> picture_layer_; |
5021 Layer* child_layer_; | 5021 Layer* child_layer_; |
5022 }; | 5022 }; |
5023 | 5023 |
5024 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 5024 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
5025 | 5025 |
| 5026 class LayerTreeHostTestInvisibleDoesntActivate : public LayerTreeHostTest { |
| 5027 public: |
| 5028 LayerTreeHostTestInvisibleDoesntActivate() : activation_count_(0) {} |
| 5029 |
| 5030 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 5031 settings->impl_side_painting = true; |
| 5032 } |
| 5033 |
| 5034 virtual void SetupTree() OVERRIDE { |
| 5035 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 5036 root_layer->SetBounds(gfx::Size(1000, 1000)); |
| 5037 |
| 5038 // Set up a non-solid layer with a bunch of tiles. |
| 5039 client_.set_fill_with_nonsolid_color(true); |
| 5040 picture_layer_ = FakePictureLayer::Create(&client_); |
| 5041 picture_layer_->SetBounds(gfx::Size(1000, 1000)); |
| 5042 picture_layer_->SetIsDrawable(true); |
| 5043 picture_layer_->SetNeedsDisplayRect(gfx::Rect(1000, 1000)); |
| 5044 root_layer->AddChild(picture_layer_.get()); |
| 5045 |
| 5046 layer_tree_host()->SetRootLayer(root_layer); |
| 5047 LayerTreeHostTest::SetupTree(); |
| 5048 } |
| 5049 |
| 5050 virtual void BeginTest() OVERRIDE { |
| 5051 // Kick off the test with a commit. |
| 5052 PostSetNeedsCommitToMainThread(); |
| 5053 } |
| 5054 |
| 5055 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 5056 // Make sure we don't activate before going invisible. |
| 5057 host_impl->BlockNotifyReadyToActivateForTesting(true); |
| 5058 } |
| 5059 |
| 5060 virtual void DidCommit() OVERRIDE { layer_tree_host()->SetVisible(false); } |
| 5061 |
| 5062 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, |
| 5063 bool visible) OVERRIDE { |
| 5064 // Once invisible, we can go visible again. |
| 5065 if (!visible) { |
| 5066 // Allow activation from now on. |
| 5067 host_impl->BlockNotifyReadyToActivateForTesting(false); |
| 5068 PostSetVisibleToMainThread(true); |
| 5069 } |
| 5070 } |
| 5071 |
| 5072 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 5073 ++activation_count_; |
| 5074 std::vector<Tile*> tiles = host_impl->tile_manager()->AllTilesForTesting(); |
| 5075 EXPECT_GT(tiles.size(), 0u); |
| 5076 // When activating, ensure that all tiles are ready to draw with a mode |
| 5077 // other than rasterize on demand. |
| 5078 int resource_tiles_count = 0; |
| 5079 for (std::vector<Tile*>::iterator it = tiles.begin(); it != tiles.end(); |
| 5080 ++it) { |
| 5081 Tile* tile = *it; |
| 5082 const ManagedTileState::TileVersion& tile_version = |
| 5083 tile->GetTileVersionForDrawing(); |
| 5084 EXPECT_TRUE(tile_version.IsReadyToDraw()); |
| 5085 EXPECT_NE(ManagedTileState::TileVersion::PICTURE_PILE_MODE, |
| 5086 tile_version.mode()); |
| 5087 resource_tiles_count += |
| 5088 tile_version.mode() == ManagedTileState::TileVersion::RESOURCE_MODE; |
| 5089 } |
| 5090 EXPECT_GT(resource_tiles_count, 0); |
| 5091 |
| 5092 EndTest(); |
| 5093 } |
| 5094 |
| 5095 virtual void AfterTest() OVERRIDE { |
| 5096 // Double check that we activated once. |
| 5097 EXPECT_EQ(1, activation_count_); |
| 5098 } |
| 5099 |
| 5100 private: |
| 5101 int activation_count_; |
| 5102 |
| 5103 FakeContentLayerClient client_; |
| 5104 scoped_refptr<FakePictureLayer> picture_layer_; |
| 5105 }; |
| 5106 |
| 5107 // TODO(vmpstr): Enable with single thread impl-side painting. |
| 5108 MULTI_THREAD_TEST_F(LayerTreeHostTestInvisibleDoesntActivate); |
| 5109 |
5026 } // namespace cc | 5110 } // namespace cc |
OLD | NEW |