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

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: removed unrelated changes 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
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 8020 matching lines...) Expand 10 before | Expand all | Expand 10 after
8031 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); 8031 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer());
8032 8032
8033 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); 8033 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250));
8034 host_impl_->UpdateAnimationState(true); 8034 host_impl_->UpdateAnimationState(true);
8035 8035
8036 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), 8036 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
8037 scrolling_layer->CurrentScrollOffset()); 8037 scrolling_layer->CurrentScrollOffset());
8038 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 8038 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
8039 } 8039 }
8040 8040
8041 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) {
8042 host_impl_->CreatePendingTree();
8043
8044 scoped_ptr<PictureLayerImpl> layer =
8045 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 10);
8046 layer->SetBounds(gfx::Size(10, 10));
8047
8048 scoped_refptr<RasterSource> pile(FakePicturePileImpl::CreateEmptyPile(
8049 gfx::Size(10, 10), gfx::Size(10, 10)));
8050 Region empty_invalidation;
8051 const PictureLayerTilingSet* null_tiling_set = nullptr;
8052 layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set);
8053
8054 host_impl_->pending_tree()->SetRootLayer(layer.Pass());
8055
8056 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
8057 LayerImpl* pending_layer = pending_tree->root_layer();
8058
8059 std::vector<PictureLayerImpl::Pair> layer_pairs;
8060 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true);
8061 EXPECT_EQ(1u, layer_pairs.size());
8062 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
8063 EXPECT_EQ(nullptr, layer_pairs[0].active);
8064
8065 host_impl_->ActivateSyncTree();
8066
8067 LayerTreeImpl* active_tree = host_impl_->active_tree();
8068 LayerImpl* active_layer = active_tree->root_layer();
8069 EXPECT_NE(active_tree, pending_tree);
8070 EXPECT_NE(active_layer, pending_layer);
8071 EXPECT_NE(nullptr, active_tree);
8072 EXPECT_NE(nullptr, active_layer);
8073
8074 host_impl_->CreatePendingTree();
8075
8076 layer_pairs.clear();
8077 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true);
8078 EXPECT_EQ(1u, layer_pairs.size());
8079 EXPECT_EQ(active_layer, layer_pairs[0].active);
8080 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
8081
8082 // Activate, the active layer has no twin now.
8083 host_impl_->ActivateSyncTree();
8084
8085 layer_pairs.clear();
8086 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true);
8087 EXPECT_EQ(1u, layer_pairs.size());
8088 EXPECT_EQ(active_layer, layer_pairs[0].active);
8089 EXPECT_EQ(nullptr, layer_pairs[0].pending);
8090
8091 // Create another layer in the pending tree that's not in the active tree. We
8092 // should get two pairs.
8093 host_impl_->CreatePendingTree();
8094 host_impl_->pending_tree()->root_layer()->AddChild(
8095 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11));
8096
8097 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0];
8098
8099 layer_pairs.clear();
8100 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true);
8101 EXPECT_EQ(2u, layer_pairs.size());
8102
8103 // The pair ordering is flaky, so make it consistent.
8104 if (layer_pairs[0].active != active_layer)
8105 std::swap(layer_pairs[0], layer_pairs[1]);
8106
8107 EXPECT_EQ(active_layer, layer_pairs[0].active);
8108 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
8109 EXPECT_EQ(new_pending_layer, layer_pairs[1].pending);
8110 EXPECT_EQ(nullptr, layer_pairs[1].active);
8111 }
8112
8113 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { 8041 TEST_F(LayerTreeHostImplTest, DidBecomeActive) {
8114 host_impl_->CreatePendingTree(); 8042 host_impl_->CreatePendingTree();
8115 host_impl_->ActivateSyncTree(); 8043 host_impl_->ActivateSyncTree();
8116 host_impl_->CreatePendingTree(); 8044 host_impl_->CreatePendingTree();
8117 8045
8118 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 8046 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
8119 8047
8120 scoped_ptr<FakePictureLayerImpl> pending_layer = 8048 scoped_ptr<FakePictureLayerImpl> pending_layer =
8121 FakePictureLayerImpl::Create(pending_tree, 10); 8049 FakePictureLayerImpl::Create(pending_tree, 10);
8122 FakePictureLayerImpl* raw_pending_layer = pending_layer.get(); 8050 FakePictureLayerImpl* raw_pending_layer = pending_layer.get();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
8209 // surface. 8137 // surface.
8210 EXPECT_EQ(0, num_lost_surfaces_); 8138 EXPECT_EQ(0, num_lost_surfaces_);
8211 host_impl_->DidLoseOutputSurface(); 8139 host_impl_->DidLoseOutputSurface();
8212 EXPECT_EQ(1, num_lost_surfaces_); 8140 EXPECT_EQ(1, num_lost_surfaces_);
8213 host_impl_->DidLoseOutputSurface(); 8141 host_impl_->DidLoseOutputSurface();
8214 EXPECT_LE(1, num_lost_surfaces_); 8142 EXPECT_LE(1, num_lost_surfaces_);
8215 } 8143 }
8216 8144
8217 } // namespace 8145 } // namespace
8218 } // namespace cc 8146 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698