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

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

Issue 594703002: cc: Don't activate rasterize on demand when we have 0 memory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update 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/resources/tile_priority.h ('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 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 {
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 DidCommit() OVERRIDE { layer_tree_host()->SetVisible(false); }
danakj 2014/09/23 21:42:10 i really liked your comment explaining about the p
vmpstr 2014/09/23 22:31:50 There shouldn't be races here.. However, I did a b
5056
5057 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
5058 ++activation_count_;
5059 std::vector<Tile*> tiles = impl->tile_manager()->AllTilesForTesting();
5060 EXPECT_GT(tiles.size(), 0u);
5061 // When activating, ensure that all tiles are ready to draw with a mode
5062 // other than rasterize on demand.
5063 int resource_tiles_count = 0;
5064 for (std::vector<Tile*>::iterator it = tiles.begin(); it != tiles.end();
5065 ++it) {
5066 Tile* tile = *it;
5067 const ManagedTileState::TileVersion& tile_version =
5068 tile->GetTileVersionForDrawing();
5069 EXPECT_TRUE(tile_version.IsReadyToDraw());
5070 EXPECT_NE(ManagedTileState::TileVersion::PICTURE_PILE_MODE,
5071 tile_version.mode());
5072 resource_tiles_count +=
5073 tile_version.mode() == ManagedTileState::TileVersion::RESOURCE_MODE;
5074 }
5075 EXPECT_GT(resource_tiles_count, 0);
5076
5077 EndTest();
5078 }
5079
5080 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl,
5081 bool visible) OVERRIDE {
5082 // Once invisible, we can go visible again.
5083 if (!visible)
5084 PostSetVisibleToMainThread(true);
5085 }
5086
5087 virtual void AfterTest() OVERRIDE {
5088 // Double check that we activated once.
5089 EXPECT_EQ(1, activation_count_);
5090 }
5091
5092 private:
5093 int activation_count_;
5094
5095 FakeContentLayerClient client_;
5096 scoped_refptr<FakePictureLayer> picture_layer_;
5097 };
5098
5099 // TODO(vmpstr): Enable with single thread impl-side painting.
5100 MULTI_THREAD_TEST_F(LayerTreeHostTestInvisibleDoesntActivate);
5101
5026 } // namespace cc 5102 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_priority.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698