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

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

Powered by Google App Engine
This is Rietveld 408576698