Chromium Code Reviews| 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 layer_tree_host()->SetViewportSize(gfx::Size(1000, 1000)); | |
|
danakj
2014/09/23 20:55:29
the base class does this for you based on the root
vmpstr
2014/09/23 21:39:32
Done.
| |
| 5048 LayerTreeHostTest::SetupTree(); | |
| 5049 } | |
| 5050 | |
| 5051 virtual void BeginTest() OVERRIDE { | |
| 5052 // Kick off the test with a commit. | |
| 5053 PostSetNeedsCommitToMainThread(); | |
| 5054 } | |
| 5055 | |
| 5056 virtual void WillCommit() OVERRIDE { | |
| 5057 // As soon as we're in the will commit state (created a pending tree), go | |
| 5058 // invisible. | |
| 5059 PostSetVisibleToMainThread(false); | |
|
danakj
2014/09/23 20:55:29
you're on the main thread, you can layer_tree_host
vmpstr
2014/09/23 21:39:32
Done.
| |
| 5060 } | |
| 5061 | |
| 5062 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
| 5063 ++activation_count_; | |
| 5064 std::vector<Tile*> tiles = impl->tile_manager()->AllTilesForTesting(); | |
| 5065 EXPECT_GT(tiles.size(), 0u); | |
| 5066 // When activating, ensure that all tiles are ready to draw with a mode | |
| 5067 // other than rasterize on demand. | |
| 5068 for (std::vector<Tile*>::iterator it = tiles.begin(); it != tiles.end(); | |
| 5069 ++it) { | |
| 5070 Tile* tile = *it; | |
| 5071 const ManagedTileState::TileVersion& tile_version = | |
| 5072 tile->GetTileVersionForDrawing(); | |
| 5073 EXPECT_TRUE(tile_version.IsReadyToDraw()); | |
| 5074 EXPECT_NE(ManagedTileState::TileVersion::PICTURE_PILE_MODE, | |
|
danakj
2014/09/23 20:55:28
can you EXPECT that some tiles are RESOURCE mode (
vmpstr
2014/09/23 21:39:32
Done.
| |
| 5075 tile_version.mode()); | |
| 5076 } | |
| 5077 | |
| 5078 // We can finish the test now. | |
|
danakj
2014/09/23 20:55:28
remove, this doesn't explain anything
vmpstr
2014/09/23 21:39:31
Done.
| |
| 5079 EndTest(); | |
| 5080 } | |
| 5081 | |
| 5082 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, | |
| 5083 bool visible) OVERRIDE { | |
| 5084 // Once invisible, we can go visible again. | |
| 5085 if (!visible) | |
| 5086 PostSetVisibleToMainThread(true); | |
| 5087 } | |
| 5088 | |
| 5089 virtual void AfterTest() OVERRIDE { | |
| 5090 // Double check that we activated once. | |
| 5091 EXPECT_EQ(1, activation_count_); | |
| 5092 } | |
| 5093 | |
| 5094 private: | |
| 5095 int activation_count_; | |
| 5096 | |
| 5097 FakeContentLayerClient client_; | |
| 5098 scoped_refptr<FakePictureLayer> picture_layer_; | |
| 5099 }; | |
| 5100 | |
| 5101 MULTI_THREAD_TEST_F(LayerTreeHostTestInvisibleDoesntActivate); | |
|
danakj
2014/09/23 20:55:28
Can you TODO to enable with single thread impl-sid
vmpstr
2014/09/23 21:39:32
Done.
| |
| 5102 | |
| 5026 } // namespace cc | 5103 } // namespace cc |
| OLD | NEW |