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

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

Issue 900073003: cc: Rework how picture layer tiling set gets into raster queues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 5 years, 10 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/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | 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_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 8026 matching lines...) Expand 10 before | Expand all | Expand 10 after
8037 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); 8037 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer());
8038 8038
8039 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); 8039 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250));
8040 host_impl_->UpdateAnimationState(true); 8040 host_impl_->UpdateAnimationState(true);
8041 8041
8042 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), 8042 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
8043 scrolling_layer->CurrentScrollOffset()); 8043 scrolling_layer->CurrentScrollOffset());
8044 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 8044 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
8045 } 8045 }
8046 8046
8047 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) {
8048 host_impl_->CreatePendingTree();
8049
8050 scoped_ptr<PictureLayerImpl> layer =
8051 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 10);
8052 layer->SetBounds(gfx::Size(10, 10));
8053
8054 scoped_refptr<RasterSource> pile(FakePicturePileImpl::CreateEmptyPile(
8055 gfx::Size(10, 10), gfx::Size(10, 10)));
8056 Region empty_invalidation;
8057 const PictureLayerTilingSet* null_tiling_set = nullptr;
8058 layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set);
8059
8060 host_impl_->pending_tree()->SetRootLayer(layer.Pass());
8061
8062 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
8063 LayerImpl* pending_layer = pending_tree->root_layer();
8064
8065 std::vector<PictureLayerImpl::Pair> layer_pairs;
8066 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true);
8067 EXPECT_EQ(1u, layer_pairs.size());
8068 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
8069 EXPECT_EQ(nullptr, layer_pairs[0].active);
8070
8071 host_impl_->ActivateSyncTree();
8072
8073 LayerTreeImpl* active_tree = host_impl_->active_tree();
8074 LayerImpl* active_layer = active_tree->root_layer();
8075 EXPECT_NE(active_tree, pending_tree);
8076 EXPECT_NE(active_layer, pending_layer);
8077 EXPECT_NE(nullptr, active_tree);
8078 EXPECT_NE(nullptr, active_layer);
8079
8080 host_impl_->CreatePendingTree();
8081
8082 layer_pairs.clear();
8083 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true);
8084 EXPECT_EQ(1u, layer_pairs.size());
8085 EXPECT_EQ(active_layer, layer_pairs[0].active);
8086 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
8087
8088 // Activate, the active layer has no twin now.
8089 host_impl_->ActivateSyncTree();
8090
8091 layer_pairs.clear();
8092 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true);
8093 EXPECT_EQ(1u, layer_pairs.size());
8094 EXPECT_EQ(active_layer, layer_pairs[0].active);
8095 EXPECT_EQ(nullptr, layer_pairs[0].pending);
8096
8097 // Create another layer in the pending tree that's not in the active tree. We
8098 // should get two pairs.
8099 host_impl_->CreatePendingTree();
8100 host_impl_->pending_tree()->root_layer()->AddChild(
8101 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11));
8102
8103 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0];
8104
8105 layer_pairs.clear();
8106 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true);
8107 EXPECT_EQ(2u, layer_pairs.size());
8108
8109 // The pair ordering is flaky, so make it consistent.
8110 if (layer_pairs[0].active != active_layer)
8111 std::swap(layer_pairs[0], layer_pairs[1]);
8112
8113 EXPECT_EQ(active_layer, layer_pairs[0].active);
8114 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
8115 EXPECT_EQ(new_pending_layer, layer_pairs[1].pending);
8116 EXPECT_EQ(nullptr, layer_pairs[1].active);
8117 }
8118
8119 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { 8047 TEST_F(LayerTreeHostImplTest, DidBecomeActive) {
8120 host_impl_->CreatePendingTree(); 8048 host_impl_->CreatePendingTree();
8121 host_impl_->ActivateSyncTree(); 8049 host_impl_->ActivateSyncTree();
8122 host_impl_->CreatePendingTree(); 8050 host_impl_->CreatePendingTree();
8123 8051
8124 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 8052 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
8125 8053
8126 scoped_ptr<FakePictureLayerImpl> pending_layer = 8054 scoped_ptr<FakePictureLayerImpl> pending_layer =
8127 FakePictureLayerImpl::Create(pending_tree, 10); 8055 FakePictureLayerImpl::Create(pending_tree, 10);
8128 FakePictureLayerImpl* raw_pending_layer = pending_layer.get(); 8056 FakePictureLayerImpl* raw_pending_layer = pending_layer.get();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
8215 // surface. 8143 // surface.
8216 EXPECT_EQ(0, num_lost_surfaces_); 8144 EXPECT_EQ(0, num_lost_surfaces_);
8217 host_impl_->DidLoseOutputSurface(); 8145 host_impl_->DidLoseOutputSurface();
8218 EXPECT_EQ(1, num_lost_surfaces_); 8146 EXPECT_EQ(1, num_lost_surfaces_);
8219 host_impl_->DidLoseOutputSurface(); 8147 host_impl_->DidLoseOutputSurface();
8220 EXPECT_LE(1, num_lost_surfaces_); 8148 EXPECT_LE(1, num_lost_surfaces_);
8221 } 8149 }
8222 8150
8223 } // namespace 8151 } // namespace
8224 } // namespace cc 8152 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698