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

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

Issue 692213002: Create PageScaleAnimation after ImplTree is activated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month 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_impl.h » ('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 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 1157
1158 // Non-anchor zoom-in 1158 // Non-anchor zoom-in
1159 { 1159 {
1160 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1160 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
1161 min_page_scale, 1161 min_page_scale,
1162 max_page_scale); 1162 max_page_scale);
1163 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); 1163 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
1164 1164
1165 did_request_redraw_ = false; 1165 did_request_redraw_ = false;
1166 did_request_animate_ = false; 1166 did_request_animate_ = false;
1167 host_impl_->active_tree()->SetPageScaleAnimation( 1167 host_impl_->active_tree()->SetPendingPageScaleAnimation(
1168 gfx::Vector2d(), 1168 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
1169 false, 1169 gfx::Vector2d(),
1170 2.f, 1170 false,
1171 duration); 1171 2.f,
1172 duration)));
1172 host_impl_->ActivateSyncTree(); 1173 host_impl_->ActivateSyncTree();
1173 EXPECT_FALSE(did_request_redraw_); 1174 EXPECT_FALSE(did_request_redraw_);
1174 EXPECT_TRUE(did_request_animate_); 1175 EXPECT_TRUE(did_request_animate_);
1175 1176
1176 did_request_redraw_ = false; 1177 did_request_redraw_ = false;
1177 did_request_animate_ = false; 1178 did_request_animate_ = false;
1178 host_impl_->Animate(start_time); 1179 host_impl_->Animate(start_time);
1179 EXPECT_TRUE(did_request_redraw_); 1180 EXPECT_TRUE(did_request_redraw_);
1180 EXPECT_TRUE(did_request_animate_); 1181 EXPECT_TRUE(did_request_animate_);
1181 1182
(...skipping 18 matching lines...) Expand all
1200 1201
1201 // Anchor zoom-out 1202 // Anchor zoom-out
1202 { 1203 {
1203 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1204 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
1204 min_page_scale, 1205 min_page_scale,
1205 max_page_scale); 1206 max_page_scale);
1206 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); 1207 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
1207 1208
1208 did_request_redraw_ = false; 1209 did_request_redraw_ = false;
1209 did_request_animate_ = false; 1210 did_request_animate_ = false;
1210 host_impl_->active_tree()->SetPageScaleAnimation( 1211 host_impl_->active_tree()->SetPendingPageScaleAnimation(
1211 gfx::Vector2d(25, 25), true, min_page_scale, duration); 1212 scoped_ptr<PendingPageScaleAnimation> (new PendingPageScaleAnimation(
1213 gfx::Vector2d(25, 25),
1214 true,
1215 min_page_scale,
1216 duration)));
1212 host_impl_->ActivateSyncTree(); 1217 host_impl_->ActivateSyncTree();
1213 EXPECT_FALSE(did_request_redraw_); 1218 EXPECT_FALSE(did_request_redraw_);
1214 EXPECT_TRUE(did_request_animate_); 1219 EXPECT_TRUE(did_request_animate_);
1215 1220
1216 did_request_redraw_ = false; 1221 did_request_redraw_ = false;
1217 did_request_animate_ = false; 1222 did_request_animate_ = false;
1218 host_impl_->Animate(start_time); 1223 host_impl_->Animate(start_time);
1219 EXPECT_TRUE(did_request_redraw_); 1224 EXPECT_TRUE(did_request_redraw_);
1220 EXPECT_TRUE(did_request_animate_); 1225 EXPECT_TRUE(did_request_animate_);
1221 1226
(...skipping 29 matching lines...) Expand all
1251 base::TimeTicks halfway_through_animation = start_time + duration / 2; 1256 base::TimeTicks halfway_through_animation = start_time + duration / 2;
1252 base::TimeTicks end_time = start_time + duration; 1257 base::TimeTicks end_time = start_time + duration;
1253 1258
1254 // Anchor zoom with unchanged page scale should not change scroll or scale. 1259 // Anchor zoom with unchanged page scale should not change scroll or scale.
1255 { 1260 {
1256 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1261 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
1257 min_page_scale, 1262 min_page_scale,
1258 max_page_scale); 1263 max_page_scale);
1259 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); 1264 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
1260 1265
1261 host_impl_->active_tree()->SetPageScaleAnimation( 1266 host_impl_->active_tree()->SetPendingPageScaleAnimation(
1262 gfx::Vector2d(), 1267 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
1263 true, 1268 gfx::Vector2d(),
1264 1.f, 1269 true,
1265 duration); 1270 1.f,
1271 duration)));
1266 host_impl_->ActivateSyncTree(); 1272 host_impl_->ActivateSyncTree();
1267 host_impl_->Animate(start_time); 1273 host_impl_->Animate(start_time);
1268 host_impl_->Animate(halfway_through_animation); 1274 host_impl_->Animate(halfway_through_animation);
1269 EXPECT_TRUE(did_request_redraw_); 1275 EXPECT_TRUE(did_request_redraw_);
1270 host_impl_->Animate(end_time); 1276 host_impl_->Animate(end_time);
1271 EXPECT_TRUE(did_request_commit_); 1277 EXPECT_TRUE(did_request_commit_);
1272 1278
1273 scoped_ptr<ScrollAndScaleSet> scroll_info = 1279 scoped_ptr<ScrollAndScaleSet> scroll_info =
1274 host_impl_->ProcessScrollDeltas(); 1280 host_impl_->ProcessScrollDeltas();
1275 EXPECT_EQ(scroll_info->page_scale_delta, 1); 1281 EXPECT_EQ(scroll_info->page_scale_delta, 1);
(...skipping 23 matching lines...) Expand all
1299 base::TimeDelta::FromSeconds(1); 1305 base::TimeDelta::FromSeconds(1);
1300 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 1306 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
1301 base::TimeTicks third_through_animation = start_time + duration / 3; 1307 base::TimeTicks third_through_animation = start_time + duration / 3;
1302 base::TimeTicks halfway_through_animation = start_time + duration / 2; 1308 base::TimeTicks halfway_through_animation = start_time + duration / 2;
1303 base::TimeTicks end_time = start_time + duration; 1309 base::TimeTicks end_time = start_time + duration;
1304 float target_scale = 2.f; 1310 float target_scale = 2.f;
1305 1311
1306 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); 1312 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
1307 1313
1308 // Make sure TakePageScaleAnimation works properly. 1314 // Make sure TakePageScaleAnimation works properly.
1309 host_impl_->sync_tree()->SetPageScaleAnimation( 1315
1310 gfx::Vector2d(), 1316 host_impl_->sync_tree()->SetPendingPageScaleAnimation(
1311 false, 1317 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
1312 target_scale, 1318 gfx::Vector2d(),
1313 duration); 1319 false,
1314 scoped_ptr<PageScaleAnimation> psa = 1320 target_scale,
1315 host_impl_->sync_tree()->TakePageScaleAnimation(); 1321 duration)));
1316 EXPECT_EQ(target_scale, psa->target_page_scale_factor()); 1322 scoped_ptr<PendingPageScaleAnimation> psa =
1317 EXPECT_EQ(duration, psa->duration()); 1323 host_impl_->sync_tree()->TakePendingPageScaleAnimation();
1318 EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePageScaleAnimation()); 1324 EXPECT_EQ(target_scale, psa->scale);
1325 EXPECT_EQ(duration, psa->duration);
1326 EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePendingPageScaleAnimation());
1319 1327
1320 // Recreate the PSA. Nothing should happen here since the tree containing the 1328 // Recreate the PSA. Nothing should happen here since the tree containing the
1321 // PSA hasn't been activated yet. 1329 // PSA hasn't been activated yet.
1322 did_request_redraw_ = false; 1330 did_request_redraw_ = false;
1323 did_request_animate_ = false; 1331 did_request_animate_ = false;
1324 host_impl_->sync_tree()->SetPageScaleAnimation( 1332 host_impl_->sync_tree()->SetPendingPageScaleAnimation(
1325 gfx::Vector2d(), 1333 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
1326 false, 1334 gfx::Vector2d(),
1327 target_scale, 1335 false,
1328 duration); 1336 target_scale,
1337 duration)));
1329 host_impl_->Animate(halfway_through_animation); 1338 host_impl_->Animate(halfway_through_animation);
1330 EXPECT_FALSE(did_request_animate_); 1339 EXPECT_FALSE(did_request_animate_);
1331 EXPECT_FALSE(did_request_redraw_); 1340 EXPECT_FALSE(did_request_redraw_);
1332 1341
1333 // Activate the sync tree. This should cause the animation to become enabled. 1342 // Activate the sync tree. This should cause the animation to become enabled.
1334 // It should also clear the pointer on the sync tree. 1343 // It should also clear the pointer on the sync tree.
1335 host_impl_->ActivateSyncTree(); 1344 host_impl_->ActivateSyncTree();
1336 EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePageScaleAnimation().get()); 1345 EXPECT_EQ(nullptr,
1346 host_impl_->sync_tree()->TakePendingPageScaleAnimation().get());
1337 EXPECT_FALSE(did_request_redraw_); 1347 EXPECT_FALSE(did_request_redraw_);
1338 EXPECT_TRUE(did_request_animate_); 1348 EXPECT_TRUE(did_request_animate_);
1339 1349
1340 // From here on, make sure the animation runs as normal. 1350 // From here on, make sure the animation runs as normal.
1341 did_request_redraw_ = false; 1351 did_request_redraw_ = false;
1342 did_request_animate_ = false; 1352 did_request_animate_ = false;
1343 host_impl_->Animate(start_time); 1353 host_impl_->Animate(start_time);
1344 EXPECT_TRUE(did_request_redraw_); 1354 EXPECT_TRUE(did_request_redraw_);
1345 EXPECT_TRUE(did_request_animate_); 1355 EXPECT_TRUE(did_request_animate_);
1346 1356
(...skipping 6472 matching lines...) Expand 10 before | Expand all | Expand 10 after
7819 // surface. 7829 // surface.
7820 EXPECT_EQ(0, num_lost_surfaces_); 7830 EXPECT_EQ(0, num_lost_surfaces_);
7821 host_impl_->DidLoseOutputSurface(); 7831 host_impl_->DidLoseOutputSurface();
7822 EXPECT_EQ(1, num_lost_surfaces_); 7832 EXPECT_EQ(1, num_lost_surfaces_);
7823 host_impl_->DidLoseOutputSurface(); 7833 host_impl_->DidLoseOutputSurface();
7824 EXPECT_LE(1, num_lost_surfaces_); 7834 EXPECT_LE(1, num_lost_surfaces_);
7825 } 7835 }
7826 7836
7827 } // namespace 7837 } // namespace
7828 } // namespace cc 7838 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698