Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 605823002: cc: Activate when going invisible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 { 5026 class LayerTreeHostTestActivateOnInvisible : public LayerTreeHostTest {
5027 public: 5027 public:
5028 LayerTreeHostTestInvisibleDoesntActivate() : activation_count_(0) {} 5028 LayerTreeHostTestActivateOnInvisible()
5029 : activation_count_(0), visible_(true) {}
5029 5030
5030 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 5031 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
5031 settings->impl_side_painting = true; 5032 settings->impl_side_painting = true;
5032 } 5033 }
5033 5034
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 { 5035 virtual void BeginTest() OVERRIDE {
5051 // Kick off the test with a commit. 5036 // Kick off the test with a commit.
5052 PostSetNeedsCommitToMainThread(); 5037 PostSetNeedsCommitToMainThread();
5053 } 5038 }
5054 5039
5055 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 5040 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
5056 // Make sure we don't activate before going invisible. 5041 // Make sure we don't activate using the notify signal from tile manager.
5057 host_impl->BlockNotifyReadyToActivateForTesting(true); 5042 host_impl->BlockNotifyReadyToActivateForTesting(true);
5058 } 5043 }
5059 5044
5060 virtual void DidCommit() OVERRIDE { layer_tree_host()->SetVisible(false); } 5045 virtual void DidCommit() OVERRIDE { layer_tree_host()->SetVisible(false); }
5061 5046
5062 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, 5047 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl,
5063 bool visible) OVERRIDE { 5048 bool visible) OVERRIDE {
5049 visible_ = visible;
5050
5064 // Once invisible, we can go visible again. 5051 // Once invisible, we can go visible again.
5065 if (!visible) { 5052 if (!visible) {
5066 // Allow activation from now on.
5067 host_impl->BlockNotifyReadyToActivateForTesting(false);
5068 PostSetVisibleToMainThread(true); 5053 PostSetVisibleToMainThread(true);
5054 } else {
5055 EndTest();
5069 } 5056 }
5070 } 5057 }
5071 5058
5072 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 5059 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
5073 ++activation_count_; 5060 ++activation_count_;
danakj 2014/09/25 18:38:32 can you test that RequiresHighRes was true when we
danakj 2014/09/25 18:40:27 Maybe the scheduler test could demonstrate that it
vmpstr 2014/09/25 19:42:12 The activation with this change happens as a part
5074 std::vector<Tile*> tiles = host_impl->tile_manager()->AllTilesForTesting(); 5061 EXPECT_FALSE(visible_);
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 } 5062 }
5094 5063
5095 virtual void AfterTest() OVERRIDE { 5064 virtual void AfterTest() OVERRIDE {
5096 // Double check that we activated once. 5065 // Ensure we activated even though the signal was blocked.
5097 EXPECT_EQ(1, activation_count_); 5066 EXPECT_EQ(1, activation_count_);
5067 EXPECT_TRUE(visible_);
5098 } 5068 }
5099 5069
5100 private: 5070 private:
5101 int activation_count_; 5071 int activation_count_;
5072 bool visible_;
5102 5073
5103 FakeContentLayerClient client_; 5074 FakeContentLayerClient client_;
5104 scoped_refptr<FakePictureLayer> picture_layer_; 5075 scoped_refptr<FakePictureLayer> picture_layer_;
5105 }; 5076 };
5106 5077
5107 // TODO(vmpstr): Enable with single thread impl-side painting. 5078 // TODO(vmpstr): Enable with single thread impl-side painting.
5108 MULTI_THREAD_TEST_F(LayerTreeHostTestInvisibleDoesntActivate); 5079 MULTI_THREAD_TEST_F(LayerTreeHostTestActivateOnInvisible);
5109 5080
5110 } // namespace cc 5081 } // namespace cc
OLDNEW
« cc/scheduler/scheduler_state_machine.cc ('K') | « cc/scheduler/scheduler_state_machine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698