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

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, 3 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 22:45:10 nit: move this below BeginCommitOnThread since it
vmpstr 2014/09/23 22:53:33 Done.
5056
5057 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
5058 // Make sure we don't activate before going invisible.
5059 host_impl->BlockNotifyReadyToActivateForTesting(true);
5060 }
5061
5062 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
5063 ++activation_count_;
5064 std::vector<Tile*> tiles = host_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 int resource_tiles_count = 0;
5069 for (std::vector<Tile*>::iterator it = tiles.begin(); it != tiles.end();
5070 ++it) {
5071 Tile* tile = *it;
5072 const ManagedTileState::TileVersion& tile_version =
5073 tile->GetTileVersionForDrawing();
5074 EXPECT_TRUE(tile_version.IsReadyToDraw());
5075 EXPECT_NE(ManagedTileState::TileVersion::PICTURE_PILE_MODE,
5076 tile_version.mode());
5077 resource_tiles_count +=
5078 tile_version.mode() == ManagedTileState::TileVersion::RESOURCE_MODE;
5079 }
5080 EXPECT_GT(resource_tiles_count, 0);
5081
5082 EndTest();
5083 }
5084
5085 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl,
danakj 2014/09/23 22:45:10 nit: move this above DidActivate
vmpstr 2014/09/23 22:53:32 Done.
5086 bool visible) OVERRIDE {
5087 // Once invisible, we can go visible again.
5088 if (!visible) {
5089 // Allow activation from now on.
5090 host_impl->BlockNotifyReadyToActivateForTesting(false);
5091 PostSetVisibleToMainThread(true);
5092 }
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
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