| OLD | NEW | 
|     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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    89         did_request_manage_tiles_(false), |    89         did_request_manage_tiles_(false), | 
|    90         reduce_memory_result_(true), |    90         reduce_memory_result_(true), | 
|    91         current_limit_bytes_(0), |    91         current_limit_bytes_(0), | 
|    92         current_priority_cutoff_value_(0) { |    92         current_priority_cutoff_value_(0) { | 
|    93   } |    93   } | 
|    94  |    94  | 
|    95   LayerTreeSettings DefaultSettings() { |    95   LayerTreeSettings DefaultSettings() { | 
|    96     LayerTreeSettings settings; |    96     LayerTreeSettings settings; | 
|    97     settings.minimum_occlusion_tracking_size = gfx::Size(); |    97     settings.minimum_occlusion_tracking_size = gfx::Size(); | 
|    98     settings.impl_side_painting = true; |    98     settings.impl_side_painting = true; | 
|    99     settings.texture_id_allocation_chunk_size = 1; |    99     settings.renderer_settings.texture_id_allocation_chunk_size = 1; | 
|   100     settings.report_overscroll_only_for_scrollable_axes = true; |   100     settings.report_overscroll_only_for_scrollable_axes = true; | 
|   101     settings.use_pinch_virtual_viewport = true; |   101     settings.use_pinch_virtual_viewport = true; | 
|   102     return settings; |   102     return settings; | 
|   103   } |   103   } | 
|   104  |   104  | 
|   105   void SetUp() override { |   105   void SetUp() override { | 
|   106     CreateHostImpl(DefaultSettings(), CreateOutputSurface()); |   106     CreateHostImpl(DefaultSettings(), CreateOutputSurface()); | 
|   107   } |   107   } | 
|   108  |   108  | 
|   109   void TearDown() override {} |   109   void TearDown() override {} | 
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   249     contents->SetContentBounds(content_size); |   249     contents->SetContentBounds(content_size); | 
|   250     contents->SetPosition(gfx::PointF()); |   250     contents->SetPosition(gfx::PointF()); | 
|   251  |   251  | 
|   252     scroll->AddChild(contents.Pass()); |   252     scroll->AddChild(contents.Pass()); | 
|   253     page_scale->AddChild(scroll.Pass()); |   253     page_scale->AddChild(scroll.Pass()); | 
|   254     clip->AddChild(page_scale.Pass()); |   254     clip->AddChild(page_scale.Pass()); | 
|   255     root->AddChild(clip.Pass()); |   255     root->AddChild(clip.Pass()); | 
|   256  |   256  | 
|   257     layer_tree_impl->SetRootLayer(root.Pass()); |   257     layer_tree_impl->SetRootLayer(root.Pass()); | 
|   258     layer_tree_impl->SetViewportLayersFromIds( |   258     layer_tree_impl->SetViewportLayersFromIds( | 
|   259         kPageScaleLayerId, kInnerViewportScrollLayerId, Layer::INVALID_ID); |   259         Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 
 |   260         Layer::INVALID_ID); | 
|   260  |   261  | 
|   261     return scroll_layer; |   262     return scroll_layer; | 
|   262   } |   263   } | 
|   263  |   264  | 
|   264   LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { |   265   LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { | 
|   265     LayerImpl* scroll_layer = CreateScrollAndContentsLayers( |   266     LayerImpl* scroll_layer = CreateScrollAndContentsLayers( | 
|   266         host_impl_->active_tree(), content_size); |   267         host_impl_->active_tree(), content_size); | 
|   267     host_impl_->active_tree()->DidBecomeActive(); |   268     host_impl_->active_tree()->DidBecomeActive(); | 
|   268     return scroll_layer; |   269     return scroll_layer; | 
|   269   } |   270   } | 
| (...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1152  |  1153  | 
|  1153   // Non-anchor zoom-in |  1154   // Non-anchor zoom-in | 
|  1154   { |  1155   { | 
|  1155     host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, |  1156     host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, | 
|  1156                                                            min_page_scale, |  1157                                                            min_page_scale, | 
|  1157                                                            max_page_scale); |  1158                                                            max_page_scale); | 
|  1158     scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); |  1159     scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 
|  1159  |  1160  | 
|  1160     did_request_redraw_ = false; |  1161     did_request_redraw_ = false; | 
|  1161     did_request_animate_ = false; |  1162     did_request_animate_ = false; | 
|  1162     host_impl_->active_tree()->SetPageScaleAnimation( |  1163     host_impl_->active_tree()->SetPendingPageScaleAnimation( | 
|  1163         gfx::Vector2d(), |  1164         scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 
|  1164         false, |  1165             gfx::Vector2d(), | 
|  1165         2.f, |  1166             false, | 
|  1166         duration); |  1167             2.f, | 
 |  1168             duration))); | 
|  1167     host_impl_->ActivateSyncTree(); |  1169     host_impl_->ActivateSyncTree(); | 
|  1168     EXPECT_FALSE(did_request_redraw_); |  1170     EXPECT_FALSE(did_request_redraw_); | 
|  1169     EXPECT_TRUE(did_request_animate_); |  1171     EXPECT_TRUE(did_request_animate_); | 
|  1170  |  1172  | 
|  1171     did_request_redraw_ = false; |  1173     did_request_redraw_ = false; | 
|  1172     did_request_animate_ = false; |  1174     did_request_animate_ = false; | 
|  1173     host_impl_->Animate(start_time); |  1175     host_impl_->Animate(start_time); | 
|  1174     EXPECT_TRUE(did_request_redraw_); |  1176     EXPECT_TRUE(did_request_redraw_); | 
|  1175     EXPECT_TRUE(did_request_animate_); |  1177     EXPECT_TRUE(did_request_animate_); | 
|  1176  |  1178  | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|  1195  |  1197  | 
|  1196   // Anchor zoom-out |  1198   // Anchor zoom-out | 
|  1197   { |  1199   { | 
|  1198     host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, |  1200     host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, | 
|  1199                                                            min_page_scale, |  1201                                                            min_page_scale, | 
|  1200                                                            max_page_scale); |  1202                                                            max_page_scale); | 
|  1201     scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); |  1203     scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 
|  1202  |  1204  | 
|  1203     did_request_redraw_ = false; |  1205     did_request_redraw_ = false; | 
|  1204     did_request_animate_ = false; |  1206     did_request_animate_ = false; | 
|  1205     host_impl_->active_tree()->SetPageScaleAnimation( |  1207     host_impl_->active_tree()->SetPendingPageScaleAnimation( | 
|  1206         gfx::Vector2d(25, 25), true, min_page_scale, duration); |  1208         scoped_ptr<PendingPageScaleAnimation> (new PendingPageScaleAnimation( | 
 |  1209             gfx::Vector2d(25, 25), | 
 |  1210             true, | 
 |  1211             min_page_scale, | 
 |  1212             duration))); | 
|  1207     host_impl_->ActivateSyncTree(); |  1213     host_impl_->ActivateSyncTree(); | 
|  1208     EXPECT_FALSE(did_request_redraw_); |  1214     EXPECT_FALSE(did_request_redraw_); | 
|  1209     EXPECT_TRUE(did_request_animate_); |  1215     EXPECT_TRUE(did_request_animate_); | 
|  1210  |  1216  | 
|  1211     did_request_redraw_ = false; |  1217     did_request_redraw_ = false; | 
|  1212     did_request_animate_ = false; |  1218     did_request_animate_ = false; | 
|  1213     host_impl_->Animate(start_time); |  1219     host_impl_->Animate(start_time); | 
|  1214     EXPECT_TRUE(did_request_redraw_); |  1220     EXPECT_TRUE(did_request_redraw_); | 
|  1215     EXPECT_TRUE(did_request_animate_); |  1221     EXPECT_TRUE(did_request_animate_); | 
|  1216  |  1222  | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
|  1246   base::TimeTicks halfway_through_animation = start_time + duration / 2; |  1252   base::TimeTicks halfway_through_animation = start_time + duration / 2; | 
|  1247   base::TimeTicks end_time = start_time + duration; |  1253   base::TimeTicks end_time = start_time + duration; | 
|  1248  |  1254  | 
|  1249   // Anchor zoom with unchanged page scale should not change scroll or scale. |  1255   // Anchor zoom with unchanged page scale should not change scroll or scale. | 
|  1250   { |  1256   { | 
|  1251     host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, |  1257     host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, | 
|  1252                                                            min_page_scale, |  1258                                                            min_page_scale, | 
|  1253                                                            max_page_scale); |  1259                                                            max_page_scale); | 
|  1254     scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); |  1260     scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 
|  1255  |  1261  | 
|  1256     host_impl_->active_tree()->SetPageScaleAnimation( |  1262     host_impl_->active_tree()->SetPendingPageScaleAnimation( | 
|  1257         gfx::Vector2d(), |  1263         scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 
|  1258         true, |  1264             gfx::Vector2d(), | 
|  1259         1.f, |  1265             true, | 
|  1260         duration); |  1266             1.f, | 
 |  1267             duration))); | 
|  1261     host_impl_->ActivateSyncTree(); |  1268     host_impl_->ActivateSyncTree(); | 
|  1262     host_impl_->Animate(start_time); |  1269     host_impl_->Animate(start_time); | 
|  1263     host_impl_->Animate(halfway_through_animation); |  1270     host_impl_->Animate(halfway_through_animation); | 
|  1264     EXPECT_TRUE(did_request_redraw_); |  1271     EXPECT_TRUE(did_request_redraw_); | 
|  1265     host_impl_->Animate(end_time); |  1272     host_impl_->Animate(end_time); | 
|  1266     EXPECT_TRUE(did_request_commit_); |  1273     EXPECT_TRUE(did_request_commit_); | 
|  1267  |  1274  | 
|  1268     scoped_ptr<ScrollAndScaleSet> scroll_info = |  1275     scoped_ptr<ScrollAndScaleSet> scroll_info = | 
|  1269         host_impl_->ProcessScrollDeltas(); |  1276         host_impl_->ProcessScrollDeltas(); | 
|  1270     EXPECT_EQ(scroll_info->page_scale_delta, 1); |  1277     EXPECT_EQ(scroll_info->page_scale_delta, 1); | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
|  1294                                base::TimeDelta::FromSeconds(1); |  1301                                base::TimeDelta::FromSeconds(1); | 
|  1295   base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |  1302   base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 
|  1296   base::TimeTicks third_through_animation = start_time + duration / 3; |  1303   base::TimeTicks third_through_animation = start_time + duration / 3; | 
|  1297   base::TimeTicks halfway_through_animation = start_time + duration / 2; |  1304   base::TimeTicks halfway_through_animation = start_time + duration / 2; | 
|  1298   base::TimeTicks end_time = start_time + duration; |  1305   base::TimeTicks end_time = start_time + duration; | 
|  1299   float target_scale = 2.f; |  1306   float target_scale = 2.f; | 
|  1300  |  1307  | 
|  1301   scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); |  1308   scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 
|  1302  |  1309  | 
|  1303   // Make sure TakePageScaleAnimation works properly. |  1310   // Make sure TakePageScaleAnimation works properly. | 
|  1304   host_impl_->sync_tree()->SetPageScaleAnimation( |  1311  | 
|  1305       gfx::Vector2d(), |  1312   host_impl_->sync_tree()->SetPendingPageScaleAnimation( | 
|  1306       false, |  1313       scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 
|  1307       target_scale, |  1314           gfx::Vector2d(), | 
|  1308       duration); |  1315           false, | 
|  1309   scoped_ptr<PageScaleAnimation> psa = |  1316           target_scale, | 
|  1310       host_impl_->sync_tree()->TakePageScaleAnimation(); |  1317           duration))); | 
|  1311   EXPECT_EQ(target_scale, psa->target_page_scale_factor()); |  1318   scoped_ptr<PendingPageScaleAnimation> psa = | 
|  1312   EXPECT_EQ(duration, psa->duration()); |  1319       host_impl_->sync_tree()->TakePendingPageScaleAnimation(); | 
|  1313   EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePageScaleAnimation()); |  1320   EXPECT_EQ(target_scale, psa->scale); | 
 |  1321   EXPECT_EQ(duration, psa->duration); | 
 |  1322   EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePendingPageScaleAnimation()); | 
|  1314  |  1323  | 
|  1315   // Recreate the PSA. Nothing should happen here since the tree containing the |  1324   // Recreate the PSA. Nothing should happen here since the tree containing the | 
|  1316   // PSA hasn't been activated yet. |  1325   // PSA hasn't been activated yet. | 
|  1317   did_request_redraw_ = false; |  1326   did_request_redraw_ = false; | 
|  1318   did_request_animate_ = false; |  1327   did_request_animate_ = false; | 
|  1319   host_impl_->sync_tree()->SetPageScaleAnimation( |  1328   host_impl_->sync_tree()->SetPendingPageScaleAnimation( | 
|  1320       gfx::Vector2d(), |  1329       scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 
|  1321       false, |  1330           gfx::Vector2d(), | 
|  1322       target_scale, |  1331           false, | 
|  1323       duration); |  1332           target_scale, | 
 |  1333           duration))); | 
|  1324   host_impl_->Animate(halfway_through_animation); |  1334   host_impl_->Animate(halfway_through_animation); | 
|  1325   EXPECT_FALSE(did_request_animate_); |  1335   EXPECT_FALSE(did_request_animate_); | 
|  1326   EXPECT_FALSE(did_request_redraw_); |  1336   EXPECT_FALSE(did_request_redraw_); | 
|  1327  |  1337  | 
|  1328   // Activate the sync tree. This should cause the animation to become enabled. |  1338   // Activate the sync tree. This should cause the animation to become enabled. | 
|  1329   // It should also clear the pointer on the sync tree. |  1339   // It should also clear the pointer on the sync tree. | 
|  1330   host_impl_->ActivateSyncTree(); |  1340   host_impl_->ActivateSyncTree(); | 
|  1331   EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePageScaleAnimation().get()); |  1341   EXPECT_EQ(nullptr, | 
 |  1342       host_impl_->sync_tree()->TakePendingPageScaleAnimation().get()); | 
|  1332   EXPECT_FALSE(did_request_redraw_); |  1343   EXPECT_FALSE(did_request_redraw_); | 
|  1333   EXPECT_TRUE(did_request_animate_); |  1344   EXPECT_TRUE(did_request_animate_); | 
|  1334  |  1345  | 
|  1335   // From here on, make sure the animation runs as normal. |  1346   // From here on, make sure the animation runs as normal. | 
|  1336   did_request_redraw_ = false; |  1347   did_request_redraw_ = false; | 
|  1337   did_request_animate_ = false; |  1348   did_request_animate_ = false; | 
|  1338   host_impl_->Animate(start_time); |  1349   host_impl_->Animate(start_time); | 
|  1339   EXPECT_TRUE(did_request_redraw_); |  1350   EXPECT_TRUE(did_request_redraw_); | 
|  1340   EXPECT_TRUE(did_request_animate_); |  1351   EXPECT_TRUE(did_request_animate_); | 
|  1341  |  1352  | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1388   } |  1399   } | 
|  1389  |  1400  | 
|  1390   void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { |  1401   void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { | 
|  1391     fake_current_physical_time_ = fake_now; |  1402     fake_current_physical_time_ = fake_now; | 
|  1392   } |  1403   } | 
|  1393  |  1404  | 
|  1394  private: |  1405  private: | 
|  1395   base::TimeTicks fake_current_physical_time_; |  1406   base::TimeTicks fake_current_physical_time_; | 
|  1396 }; |  1407 }; | 
|  1397  |  1408  | 
|  1398 #define SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST()                           \ |  1409 #define SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST()                            \ | 
|  1399   gfx::Size viewport_size(10, 10);                                            \ |  1410   gfx::Size viewport_size(10, 10);                                             \ | 
|  1400   gfx::Size content_size(100, 100);                                           \ |  1411   gfx::Size content_size(100, 100);                                            \ | 
|  1401                                                                               \ |  1412                                                                                \ | 
|  1402   LayerTreeHostImplOverridePhysicalTime* host_impl_override_time =            \ |  1413   LayerTreeHostImplOverridePhysicalTime* host_impl_override_time =             \ | 
|  1403       new LayerTreeHostImplOverridePhysicalTime(settings,                     \ |  1414       new LayerTreeHostImplOverridePhysicalTime(settings, this, &proxy_,       \ | 
|  1404                                                 this,                         \ |  1415                                                 shared_bitmap_manager_.get(),  \ | 
|  1405                                                 &proxy_,                      \ |  1416                                                 &stats_instrumentation_);      \ | 
|  1406                                                 shared_bitmap_manager_.get(), \ |  1417   host_impl_ = make_scoped_ptr(host_impl_override_time);                       \ | 
|  1407                                                 &stats_instrumentation_);     \ |  1418   host_impl_->InitializeRenderer(CreateOutputSurface());                       \ | 
|  1408   host_impl_ = make_scoped_ptr(host_impl_override_time);                      \ |  1419   host_impl_->SetViewportSize(viewport_size);                                  \ | 
|  1409   host_impl_->InitializeRenderer(CreateOutputSurface());                      \ |  1420                                                                                \ | 
|  1410   host_impl_->SetViewportSize(viewport_size);                                 \ |  1421   scoped_ptr<LayerImpl> root =                                                 \ | 
|  1411                                                                               \ |  1422       LayerImpl::Create(host_impl_->active_tree(), 1);                         \ | 
|  1412   scoped_ptr<LayerImpl> root =                                                \ |  1423   root->SetBounds(viewport_size);                                              \ | 
|  1413       LayerImpl::Create(host_impl_->active_tree(), 1);                        \ |  1424                                                                                \ | 
|  1414   root->SetBounds(viewport_size);                                             \ |  1425   scoped_ptr<LayerImpl> scroll =                                               \ | 
|  1415                                                                               \ |  1426       LayerImpl::Create(host_impl_->active_tree(), 2);                         \ | 
|  1416   scoped_ptr<LayerImpl> scroll =                                              \ |  1427   scroll->SetScrollClipLayer(root->id());                                      \ | 
|  1417       LayerImpl::Create(host_impl_->active_tree(), 2);                        \ |  1428   scroll->SetScrollOffset(gfx::ScrollOffset());                                \ | 
|  1418   scroll->SetScrollClipLayer(root->id());                                     \ |  1429   root->SetBounds(viewport_size);                                              \ | 
|  1419   scroll->SetScrollOffset(gfx::ScrollOffset());                               \ |  1430   scroll->SetBounds(content_size);                                             \ | 
|  1420   root->SetBounds(viewport_size);                                             \ |  1431   scroll->SetContentBounds(content_size);                                      \ | 
|  1421   scroll->SetBounds(content_size);                                            \ |  1432   scroll->SetIsContainerForFixedPositionLayers(true);                          \ | 
|  1422   scroll->SetContentBounds(content_size);                                     \ |  1433                                                                                \ | 
|  1423   scroll->SetIsContainerForFixedPositionLayers(true);                         \ |  1434   scoped_ptr<LayerImpl> contents =                                             \ | 
|  1424                                                                               \ |  1435       LayerImpl::Create(host_impl_->active_tree(), 3);                         \ | 
|  1425   scoped_ptr<LayerImpl> contents =                                            \ |  1436   contents->SetDrawsContent(true);                                             \ | 
|  1426       LayerImpl::Create(host_impl_->active_tree(), 3);                        \ |  1437   contents->SetBounds(content_size);                                           \ | 
|  1427   contents->SetDrawsContent(true);                                            \ |  1438   contents->SetContentBounds(content_size);                                    \ | 
|  1428   contents->SetBounds(content_size);                                          \ |  1439                                                                                \ | 
|  1429   contents->SetContentBounds(content_size);                                   \ |  1440   scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar =                         \ | 
|  1430                                                                               \ |  1441       SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 4,       \ | 
|  1431   scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar =                        \ |  1442                                            VERTICAL, 10, 0, false, true);      \ | 
|  1432       SolidColorScrollbarLayerImpl::Create(                                   \ |  1443   EXPECT_FLOAT_EQ(0.f, scrollbar->opacity());                                  \ | 
|  1433           host_impl_->active_tree(), 4, VERTICAL, 10, 0, false, true);        \ |  1444                                                                                \ | 
|  1434   EXPECT_FLOAT_EQ(0.f, scrollbar->opacity());                                 \ |  1445   scroll->AddChild(contents.Pass());                                           \ | 
|  1435                                                                               \ |  1446   root->AddChild(scroll.Pass());                                               \ | 
|  1436   scroll->AddChild(contents.Pass());                                          \ |  1447   scrollbar->SetScrollLayerAndClipLayerByIds(2, 1);                            \ | 
|  1437   root->AddChild(scroll.Pass());                                              \ |  1448   root->AddChild(scrollbar.Pass());                                            \ | 
|  1438   scrollbar->SetScrollLayerAndClipLayerByIds(2, 1);                           \ |  1449                                                                                \ | 
|  1439   root->AddChild(scrollbar.Pass());                                           \ |  1450   host_impl_->active_tree()->SetRootLayer(root.Pass());                        \ | 
|  1440                                                                               \ |  1451   host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, \ | 
|  1441   host_impl_->active_tree()->SetRootLayer(root.Pass());                       \ |  1452                                                       Layer::INVALID_ID);      \ | 
|  1442   host_impl_->active_tree()->SetViewportLayersFromIds(                        \ |  1453   host_impl_->active_tree()->DidBecomeActive();                                \ | 
|  1443       1, 2, Layer::INVALID_ID);                                               \ |  | 
|  1444   host_impl_->active_tree()->DidBecomeActive();                               \ |  | 
|  1445   DrawFrame(); |  1454   DrawFrame(); | 
|  1446  |  1455  | 
|  1447 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { |  1456 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { | 
|  1448   LayerTreeSettings settings; |  1457   LayerTreeSettings settings; | 
|  1449   settings.scrollbar_animator = LayerTreeSettings::LinearFade; |  1458   settings.scrollbar_animator = LayerTreeSettings::LinearFade; | 
|  1450   settings.scrollbar_fade_delay_ms = 20; |  1459   settings.scrollbar_fade_delay_ms = 20; | 
|  1451   settings.scrollbar_fade_duration_ms = 20; |  1460   settings.scrollbar_fade_duration_ms = 20; | 
|  1452  |  1461  | 
|  1453   SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST(); |  1462   SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST(); | 
|  1454  |  1463  | 
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1601   scrollbar->SetBounds(gfx::Size(15, viewport_size.height())); |  1610   scrollbar->SetBounds(gfx::Size(15, viewport_size.height())); | 
|  1602   scrollbar->SetContentBounds(gfx::Size(15, viewport_size.height())); |  1611   scrollbar->SetContentBounds(gfx::Size(15, viewport_size.height())); | 
|  1603   scrollbar->SetPosition(gfx::Point(285, 0)); |  1612   scrollbar->SetPosition(gfx::Point(285, 0)); | 
|  1604  |  1613  | 
|  1605   scroll->AddChild(contents.Pass()); |  1614   scroll->AddChild(contents.Pass()); | 
|  1606   root->AddChild(scroll.Pass()); |  1615   root->AddChild(scroll.Pass()); | 
|  1607   scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); |  1616   scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); | 
|  1608   root->AddChild(scrollbar.Pass()); |  1617   root->AddChild(scrollbar.Pass()); | 
|  1609  |  1618  | 
|  1610   host_impl_->active_tree()->SetRootLayer(root.Pass()); |  1619   host_impl_->active_tree()->SetRootLayer(root.Pass()); | 
|  1611   host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); |  1620   host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 
 |  1621                                                       Layer::INVALID_ID); | 
|  1612   host_impl_->active_tree()->DidBecomeActive(); |  1622   host_impl_->active_tree()->DidBecomeActive(); | 
|  1613   DrawFrame(); |  1623   DrawFrame(); | 
|  1614  |  1624  | 
|  1615   LayerImpl* root_scroll = |  1625   LayerImpl* root_scroll = | 
|  1616       host_impl_->active_tree()->InnerViewportScrollLayer(); |  1626       host_impl_->active_tree()->InnerViewportScrollLayer(); | 
|  1617   ASSERT_TRUE(root_scroll->scrollbar_animation_controller()); |  1627   ASSERT_TRUE(root_scroll->scrollbar_animation_controller()); | 
|  1618   ScrollbarAnimationControllerThinning* scrollbar_animation_controller = |  1628   ScrollbarAnimationControllerThinning* scrollbar_animation_controller = | 
|  1619       static_cast<ScrollbarAnimationControllerThinning*>( |  1629       static_cast<ScrollbarAnimationControllerThinning*>( | 
|  1620           root_scroll->scrollbar_animation_controller()); |  1630           root_scroll->scrollbar_animation_controller()); | 
|  1621   scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); |  1631   scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); | 
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2275     root->SetBounds(layer_size_); |  2285     root->SetBounds(layer_size_); | 
|  2276     root->SetContentBounds(layer_size_); |  2286     root->SetContentBounds(layer_size_); | 
|  2277     root->SetPosition(gfx::PointF()); |  2287     root->SetPosition(gfx::PointF()); | 
|  2278     root->SetDrawsContent(false); |  2288     root->SetDrawsContent(false); | 
|  2279     root->SetIsContainerForFixedPositionLayers(true); |  2289     root->SetIsContainerForFixedPositionLayers(true); | 
|  2280     int inner_viewport_scroll_layer_id = root->id(); |  2290     int inner_viewport_scroll_layer_id = root->id(); | 
|  2281     int page_scale_layer_id = root_clip->id(); |  2291     int page_scale_layer_id = root_clip->id(); | 
|  2282     root_clip->AddChild(root.Pass()); |  2292     root_clip->AddChild(root.Pass()); | 
|  2283     host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |  2293     host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 
|  2284     host_impl_->active_tree()->SetViewportLayersFromIds( |  2294     host_impl_->active_tree()->SetViewportLayersFromIds( | 
|  2285         page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); |  2295         Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, | 
 |  2296         Layer::INVALID_ID); | 
|  2286     // Set a viewport size that is large enough to contain both the top controls |  2297     // Set a viewport size that is large enough to contain both the top controls | 
|  2287     // and some content. |  2298     // and some content. | 
|  2288     host_impl_->SetViewportSize(viewport_size_); |  2299     host_impl_->SetViewportSize(viewport_size_); | 
|  2289     host_impl_->SetTopControlsLayoutHeight( |  2300     host_impl_->SetTopControlsLayoutHeight( | 
|  2290         settings_.top_controls_height); |  2301         settings_.top_controls_height); | 
|  2291  |  2302  | 
|  2292     host_impl_->CreatePendingTree(); |  2303     host_impl_->CreatePendingTree(); | 
|  2293     root = |  2304     root = | 
|  2294         LayerImpl::Create(host_impl_->sync_tree(), 1); |  2305         LayerImpl::Create(host_impl_->sync_tree(), 1); | 
|  2295     root_clip = |  2306     root_clip = | 
|  2296         LayerImpl::Create(host_impl_->sync_tree(), 2); |  2307         LayerImpl::Create(host_impl_->sync_tree(), 2); | 
|  2297     root_clip->SetBounds(clip_size_); |  2308     root_clip->SetBounds(clip_size_); | 
|  2298     root->SetScrollClipLayer(root_clip->id()); |  2309     root->SetScrollClipLayer(root_clip->id()); | 
|  2299     root->SetBounds(layer_size_); |  2310     root->SetBounds(layer_size_); | 
|  2300     root->SetContentBounds(layer_size_); |  2311     root->SetContentBounds(layer_size_); | 
|  2301     root->SetPosition(gfx::PointF()); |  2312     root->SetPosition(gfx::PointF()); | 
|  2302     root->SetDrawsContent(false); |  2313     root->SetDrawsContent(false); | 
|  2303     root->SetIsContainerForFixedPositionLayers(true); |  2314     root->SetIsContainerForFixedPositionLayers(true); | 
|  2304     inner_viewport_scroll_layer_id = root->id(); |  2315     inner_viewport_scroll_layer_id = root->id(); | 
|  2305     page_scale_layer_id = root_clip->id(); |  2316     page_scale_layer_id = root_clip->id(); | 
|  2306     root_clip->AddChild(root.Pass()); |  2317     root_clip->AddChild(root.Pass()); | 
|  2307     host_impl_->sync_tree()->SetRootLayer(root_clip.Pass()); |  2318     host_impl_->sync_tree()->SetRootLayer(root_clip.Pass()); | 
|  2308     host_impl_->sync_tree()->SetViewportLayersFromIds( |  2319     host_impl_->sync_tree()->SetViewportLayersFromIds( | 
|  2309         page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); |  2320         Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, | 
 |  2321         Layer::INVALID_ID); | 
|  2310     // Set a viewport size that is large enough to contain both the top controls |  2322     // Set a viewport size that is large enough to contain both the top controls | 
|  2311     // and some content. |  2323     // and some content. | 
|  2312     host_impl_->SetViewportSize(viewport_size_); |  2324     host_impl_->SetViewportSize(viewport_size_); | 
|  2313     host_impl_->sync_tree()->set_top_controls_layout_height( |  2325     host_impl_->sync_tree()->set_top_controls_layout_height( | 
|  2314         settings_.top_controls_height); |  2326         settings_.top_controls_height); | 
|  2315   } |  2327   } | 
|  2316  |  2328  | 
|  2317   void SetupTopControlsAndScrollLayerWithVirtualViewport( |  2329   void SetupTopControlsAndScrollLayerWithVirtualViewport( | 
|  2318       const gfx::Size& inner_viewport_size, |  2330       const gfx::Size& inner_viewport_size, | 
|  2319       const gfx::Size& outer_viewport_size, |  2331       const gfx::Size& outer_viewport_size, | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2354     int outer_viewport_scroll_layer_id = outer_scroll->id(); |  2366     int outer_viewport_scroll_layer_id = outer_scroll->id(); | 
|  2355     int page_scale_layer_id = page_scale->id(); |  2367     int page_scale_layer_id = page_scale->id(); | 
|  2356  |  2368  | 
|  2357     outer_clip->AddChild(outer_scroll.Pass()); |  2369     outer_clip->AddChild(outer_scroll.Pass()); | 
|  2358     root->AddChild(outer_clip.Pass()); |  2370     root->AddChild(outer_clip.Pass()); | 
|  2359     page_scale->AddChild(root.Pass()); |  2371     page_scale->AddChild(root.Pass()); | 
|  2360     root_clip->AddChild(page_scale.Pass()); |  2372     root_clip->AddChild(page_scale.Pass()); | 
|  2361  |  2373  | 
|  2362     host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |  2374     host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 
|  2363     host_impl_->active_tree()->SetViewportLayersFromIds( |  2375     host_impl_->active_tree()->SetViewportLayersFromIds( | 
|  2364         page_scale_layer_id, |  2376         Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, | 
|  2365         inner_viewport_scroll_layer_id, |  | 
|  2366         outer_viewport_scroll_layer_id); |  2377         outer_viewport_scroll_layer_id); | 
|  2367  |  2378  | 
|  2368     host_impl_->SetViewportSize(inner_viewport_size); |  2379     host_impl_->SetViewportSize(inner_viewport_size); | 
|  2369     LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); |  2380     LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); | 
|  2370     EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); |  2381     EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); | 
|  2371   } |  2382   } | 
|  2372  |  2383  | 
|  2373  protected: |  2384  protected: | 
|  2374   gfx::Size layer_size_; |  2385   gfx::Size layer_size_; | 
|  2375   gfx::Size clip_size_; |  2386   gfx::Size clip_size_; | 
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2979       LayerImpl::Create(host_impl_->active_tree(), 2); |  2990       LayerImpl::Create(host_impl_->active_tree(), 2); | 
|  2980   scoped_ptr<LayerImpl> root_scrolling = |  2991   scoped_ptr<LayerImpl> root_scrolling = | 
|  2981       CreateScrollableLayer(3, surface_size, root_clip.get()); |  2992       CreateScrollableLayer(3, surface_size, root_clip.get()); | 
|  2982   EXPECT_EQ(viewport_size, root_clip->bounds()); |  2993   EXPECT_EQ(viewport_size, root_clip->bounds()); | 
|  2983   root_scrolling->SetIsContainerForFixedPositionLayers(true); |  2994   root_scrolling->SetIsContainerForFixedPositionLayers(true); | 
|  2984   root_clip->AddChild(root_scrolling.Pass()); |  2995   root_clip->AddChild(root_scrolling.Pass()); | 
|  2985   root->AddChild(root_clip.Pass()); |  2996   root->AddChild(root_clip.Pass()); | 
|  2986   host_impl_->active_tree()->SetRootLayer(root.Pass()); |  2997   host_impl_->active_tree()->SetRootLayer(root.Pass()); | 
|  2987   // The behaviour in this test assumes the page scale is applied at a layer |  2998   // The behaviour in this test assumes the page scale is applied at a layer | 
|  2988   // above the clip layer. |  2999   // above the clip layer. | 
|  2989   host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); |  3000   host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 
 |  3001                                                       Layer::INVALID_ID); | 
|  2990   host_impl_->active_tree()->DidBecomeActive(); |  3002   host_impl_->active_tree()->DidBecomeActive(); | 
|  2991   host_impl_->SetViewportSize(viewport_size); |  3003   host_impl_->SetViewportSize(viewport_size); | 
|  2992   DrawFrame(); |  3004   DrawFrame(); | 
|  2993  |  3005  | 
|  2994   LayerImpl* root_scroll = |  3006   LayerImpl* root_scroll = | 
|  2995       host_impl_->active_tree()->InnerViewportScrollLayer(); |  3007       host_impl_->active_tree()->InnerViewportScrollLayer(); | 
|  2996   EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |  3008   EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 
|  2997  |  3009  | 
|  2998   gfx::Vector2d scroll_delta(0, 10); |  3010   gfx::Vector2d scroll_delta(0, 10); | 
|  2999   gfx::Vector2d expected_scroll_delta = scroll_delta; |  3011   gfx::Vector2d expected_scroll_delta = scroll_delta; | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
|  3029       LayerImpl::Create(host_impl_->active_tree(), 2); |  3041       LayerImpl::Create(host_impl_->active_tree(), 2); | 
|  3030   scoped_ptr<LayerImpl> root_scrolling = |  3042   scoped_ptr<LayerImpl> root_scrolling = | 
|  3031       CreateScrollableLayer(3, surface_size, root_clip.get()); |  3043       CreateScrollableLayer(3, surface_size, root_clip.get()); | 
|  3032   EXPECT_EQ(viewport_size, root_clip->bounds()); |  3044   EXPECT_EQ(viewport_size, root_clip->bounds()); | 
|  3033   root_scrolling->SetIsContainerForFixedPositionLayers(true); |  3045   root_scrolling->SetIsContainerForFixedPositionLayers(true); | 
|  3034   root_clip->AddChild(root_scrolling.Pass()); |  3046   root_clip->AddChild(root_scrolling.Pass()); | 
|  3035   root->AddChild(root_clip.Pass()); |  3047   root->AddChild(root_clip.Pass()); | 
|  3036   host_impl_->active_tree()->SetRootLayer(root.Pass()); |  3048   host_impl_->active_tree()->SetRootLayer(root.Pass()); | 
|  3037   // The behaviour in this test assumes the page scale is applied at a layer |  3049   // The behaviour in this test assumes the page scale is applied at a layer | 
|  3038   // above the clip layer. |  3050   // above the clip layer. | 
|  3039   host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); |  3051   host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 
 |  3052                                                       Layer::INVALID_ID); | 
|  3040   host_impl_->active_tree()->DidBecomeActive(); |  3053   host_impl_->active_tree()->DidBecomeActive(); | 
|  3041   host_impl_->SetViewportSize(viewport_size); |  3054   host_impl_->SetViewportSize(viewport_size); | 
|  3042   host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale); |  3055   host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale); | 
|  3043   DrawFrame(); |  3056   DrawFrame(); | 
|  3044  |  3057  | 
|  3045   LayerImpl* root_scroll = |  3058   LayerImpl* root_scroll = | 
|  3046       host_impl_->active_tree()->InnerViewportScrollLayer(); |  3059       host_impl_->active_tree()->InnerViewportScrollLayer(); | 
|  3047   EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |  3060   EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 
|  3048  |  3061  | 
|  3049   gfx::Vector2d scroll_delta(0, 10); |  3062   gfx::Vector2d scroll_delta(0, 10); | 
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3144   root_scrolling->SetScrollClipLayer(root->id()); |  3157   root_scrolling->SetScrollClipLayer(root->id()); | 
|  3145   root_scrolling->SetIsContainerForFixedPositionLayers(true); |  3158   root_scrolling->SetIsContainerForFixedPositionLayers(true); | 
|  3146   LayerImpl* root_scrolling_ptr = root_scrolling.get(); |  3159   LayerImpl* root_scrolling_ptr = root_scrolling.get(); | 
|  3147   root->AddChild(root_scrolling.Pass()); |  3160   root->AddChild(root_scrolling.Pass()); | 
|  3148   int child_scroll_layer_id = 3; |  3161   int child_scroll_layer_id = 3; | 
|  3149   scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( |  3162   scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( | 
|  3150       child_scroll_layer_id, surface_size, root_scrolling_ptr); |  3163       child_scroll_layer_id, surface_size, root_scrolling_ptr); | 
|  3151   LayerImpl* child = child_scrolling.get(); |  3164   LayerImpl* child = child_scrolling.get(); | 
|  3152   root_scrolling_ptr->AddChild(child_scrolling.Pass()); |  3165   root_scrolling_ptr->AddChild(child_scrolling.Pass()); | 
|  3153   host_impl_->active_tree()->SetRootLayer(root.Pass()); |  3166   host_impl_->active_tree()->SetRootLayer(root.Pass()); | 
|  3154   host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); |  3167   host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 
 |  3168                                                       Layer::INVALID_ID); | 
|  3155   host_impl_->active_tree()->DidBecomeActive(); |  3169   host_impl_->active_tree()->DidBecomeActive(); | 
|  3156   host_impl_->SetViewportSize(surface_size); |  3170   host_impl_->SetViewportSize(surface_size); | 
|  3157   DrawFrame(); |  3171   DrawFrame(); | 
|  3158  |  3172  | 
|  3159   gfx::Vector2d scroll_delta(0, 10); |  3173   gfx::Vector2d scroll_delta(0, 10); | 
|  3160   gfx::Vector2d expected_scroll_delta(scroll_delta); |  3174   gfx::Vector2d expected_scroll_delta(scroll_delta); | 
|  3161   gfx::ScrollOffset expected_max_scroll(child->MaxScrollOffset()); |  3175   gfx::ScrollOffset expected_max_scroll(child->MaxScrollOffset()); | 
|  3162   EXPECT_EQ(InputHandler::ScrollStarted, |  3176   EXPECT_EQ(InputHandler::ScrollStarted, | 
|  3163             host_impl_->ScrollBegin(gfx::Point(5, 5), |  3177             host_impl_->ScrollBegin(gfx::Point(5, 5), | 
|  3164                                     InputHandler::Wheel)); |  3178                                     InputHandler::Wheel)); | 
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3247   scoped_ptr<LayerImpl> child = |  3261   scoped_ptr<LayerImpl> child = | 
|  3248       CreateScrollableLayer(3, surface_size, root.get()); |  3262       CreateScrollableLayer(3, surface_size, root.get()); | 
|  3249   LayerImpl* grand_child_layer = grand_child.get(); |  3263   LayerImpl* grand_child_layer = grand_child.get(); | 
|  3250   child->AddChild(grand_child.Pass()); |  3264   child->AddChild(grand_child.Pass()); | 
|  3251  |  3265  | 
|  3252   LayerImpl* child_layer = child.get(); |  3266   LayerImpl* child_layer = child.get(); | 
|  3253   root_scrolling->AddChild(child.Pass()); |  3267   root_scrolling->AddChild(child.Pass()); | 
|  3254   root->AddChild(root_scrolling.Pass()); |  3268   root->AddChild(root_scrolling.Pass()); | 
|  3255   EXPECT_EQ(viewport_size, root->bounds()); |  3269   EXPECT_EQ(viewport_size, root->bounds()); | 
|  3256   host_impl_->active_tree()->SetRootLayer(root.Pass()); |  3270   host_impl_->active_tree()->SetRootLayer(root.Pass()); | 
|  3257   host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); |  3271   host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 
 |  3272                                                       Layer::INVALID_ID); | 
|  3258   host_impl_->active_tree()->DidBecomeActive(); |  3273   host_impl_->active_tree()->DidBecomeActive(); | 
|  3259   host_impl_->SetViewportSize(viewport_size); |  3274   host_impl_->SetViewportSize(viewport_size); | 
|  3260  |  3275  | 
|  3261   grand_child_layer->SetScrollOffset(gfx::ScrollOffset(0, 2)); |  3276   grand_child_layer->SetScrollOffset(gfx::ScrollOffset(0, 2)); | 
|  3262   child_layer->SetScrollOffset(gfx::ScrollOffset(0, 3)); |  3277   child_layer->SetScrollOffset(gfx::ScrollOffset(0, 3)); | 
|  3263  |  3278  | 
|  3264   DrawFrame(); |  3279   DrawFrame(); | 
|  3265   { |  3280   { | 
|  3266     gfx::Vector2d scroll_delta(0, -10); |  3281     gfx::Vector2d scroll_delta(0, -10); | 
|  3267     EXPECT_EQ(InputHandler::ScrollStarted, |  3282     EXPECT_EQ(InputHandler::ScrollStarted, | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3353       CreateScrollableLayer(2, content_size, root.get()); |  3368       CreateScrollableLayer(2, content_size, root.get()); | 
|  3354   child->SetIsContainerForFixedPositionLayers(true); |  3369   child->SetIsContainerForFixedPositionLayers(true); | 
|  3355   root->SetBounds(content_size); |  3370   root->SetBounds(content_size); | 
|  3356  |  3371  | 
|  3357   int root_scroll_id = root->id(); |  3372   int root_scroll_id = root->id(); | 
|  3358   root->AddChild(child.Pass()); |  3373   root->AddChild(child.Pass()); | 
|  3359   root_clip->AddChild(root.Pass()); |  3374   root_clip->AddChild(root.Pass()); | 
|  3360  |  3375  | 
|  3361   host_impl_->SetViewportSize(surface_size); |  3376   host_impl_->SetViewportSize(surface_size); | 
|  3362   host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |  3377   host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 
|  3363   host_impl_->active_tree()->SetViewportLayersFromIds(3, 2, Layer::INVALID_ID); |  3378   host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 2, | 
 |  3379                                                       Layer::INVALID_ID); | 
|  3364   host_impl_->active_tree()->DidBecomeActive(); |  3380   host_impl_->active_tree()->DidBecomeActive(); | 
|  3365   DrawFrame(); |  3381   DrawFrame(); | 
|  3366   { |  3382   { | 
|  3367     gfx::Vector2d scroll_delta(0, 4); |  3383     gfx::Vector2d scroll_delta(0, 4); | 
|  3368     EXPECT_EQ(InputHandler::ScrollStarted, |  3384     EXPECT_EQ(InputHandler::ScrollStarted, | 
|  3369               host_impl_->ScrollBegin(gfx::Point(5, 5), |  3385               host_impl_->ScrollBegin(gfx::Point(5, 5), | 
|  3370                                       InputHandler::Wheel)); |  3386                                       InputHandler::Wheel)); | 
|  3371     host_impl_->ScrollBy(gfx::Point(), scroll_delta); |  3387     host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 
|  3372     host_impl_->ScrollEnd(); |  3388     host_impl_->ScrollEnd(); | 
|  3373  |  3389  | 
|  3374     scoped_ptr<ScrollAndScaleSet> scroll_info = |  3390     scoped_ptr<ScrollAndScaleSet> scroll_info = | 
|  3375         host_impl_->ProcessScrollDeltas(); |  3391         host_impl_->ProcessScrollDeltas(); | 
|  3376  |  3392  | 
|  3377     // Only the root scroll should have scrolled. |  3393     // Only the root scroll should have scrolled. | 
|  3378     ASSERT_EQ(scroll_info->scrolls.size(), 1u); |  3394     ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 
|  3379     ExpectContains(*scroll_info.get(), root_scroll_id, scroll_delta); |  3395     ExpectContains(*scroll_info.get(), root_scroll_id, scroll_delta); | 
|  3380   } |  3396   } | 
|  3381 } |  3397 } | 
|  3382  |  3398  | 
|  3383 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { |  3399 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { | 
|  3384   gfx::Size surface_size(10, 10); |  3400   gfx::Size surface_size(10, 10); | 
|  3385   scoped_ptr<LayerImpl> root_clip = |  3401   scoped_ptr<LayerImpl> root_clip = | 
|  3386       LayerImpl::Create(host_impl_->active_tree(), 1); |  3402       LayerImpl::Create(host_impl_->active_tree(), 1); | 
|  3387   scoped_ptr<LayerImpl> root_scroll = |  3403   scoped_ptr<LayerImpl> root_scroll = | 
|  3388       CreateScrollableLayer(2, surface_size, root_clip.get()); |  3404       CreateScrollableLayer(2, surface_size, root_clip.get()); | 
|  3389   root_scroll->SetIsContainerForFixedPositionLayers(true); |  3405   root_scroll->SetIsContainerForFixedPositionLayers(true); | 
|  3390   root_clip->AddChild(root_scroll.Pass()); |  3406   root_clip->AddChild(root_scroll.Pass()); | 
|  3391   host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |  3407   host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 
|  3392   host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); |  3408   host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 
 |  3409                                                       Layer::INVALID_ID); | 
|  3393   host_impl_->active_tree()->DidBecomeActive(); |  3410   host_impl_->active_tree()->DidBecomeActive(); | 
|  3394   host_impl_->SetViewportSize(surface_size); |  3411   host_impl_->SetViewportSize(surface_size); | 
|  3395  |  3412  | 
|  3396   // Draw one frame and then immediately rebuild the layer tree to mimic a tree |  3413   // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 
|  3397   // synchronization. |  3414   // synchronization. | 
|  3398   DrawFrame(); |  3415   DrawFrame(); | 
|  3399   host_impl_->active_tree()->DetachLayerTree(); |  3416   host_impl_->active_tree()->DetachLayerTree(); | 
|  3400   scoped_ptr<LayerImpl> root_clip2 = |  3417   scoped_ptr<LayerImpl> root_clip2 = | 
|  3401       LayerImpl::Create(host_impl_->active_tree(), 3); |  3418       LayerImpl::Create(host_impl_->active_tree(), 3); | 
|  3402   scoped_ptr<LayerImpl> root_scroll2 = |  3419   scoped_ptr<LayerImpl> root_scroll2 = | 
|  3403       CreateScrollableLayer(4, surface_size, root_clip2.get()); |  3420       CreateScrollableLayer(4, surface_size, root_clip2.get()); | 
|  3404   root_scroll2->SetIsContainerForFixedPositionLayers(true); |  3421   root_scroll2->SetIsContainerForFixedPositionLayers(true); | 
|  3405   root_clip2->AddChild(root_scroll2.Pass()); |  3422   root_clip2->AddChild(root_scroll2.Pass()); | 
|  3406   host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); |  3423   host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); | 
|  3407   host_impl_->active_tree()->SetViewportLayersFromIds(3, 4, Layer::INVALID_ID); |  3424   host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, | 
 |  3425                                                       Layer::INVALID_ID); | 
|  3408   host_impl_->active_tree()->DidBecomeActive(); |  3426   host_impl_->active_tree()->DidBecomeActive(); | 
|  3409  |  3427  | 
|  3410   // Scrolling should still work even though we did not draw yet. |  3428   // Scrolling should still work even though we did not draw yet. | 
|  3411   EXPECT_EQ(InputHandler::ScrollStarted, |  3429   EXPECT_EQ(InputHandler::ScrollStarted, | 
|  3412             host_impl_->ScrollBegin(gfx::Point(5, 5), |  3430             host_impl_->ScrollBegin(gfx::Point(5, 5), | 
|  3413                                     InputHandler::Wheel)); |  3431                                     InputHandler::Wheel)); | 
|  3414 } |  3432 } | 
|  3415  |  3433  | 
|  3416 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { |  3434 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { | 
|  3417   LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |  3435   LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3985   root->SetIsContainerForFixedPositionLayers(true); |  4003   root->SetIsContainerForFixedPositionLayers(true); | 
|  3986   scoped_ptr<LayerImpl> child = |  4004   scoped_ptr<LayerImpl> child = | 
|  3987       CreateScrollableLayer(2, content_size, root_clip.get()); |  4005       CreateScrollableLayer(2, content_size, root_clip.get()); | 
|  3988  |  4006  | 
|  3989   child->SetScrollClipLayer(Layer::INVALID_ID); |  4007   child->SetScrollClipLayer(Layer::INVALID_ID); | 
|  3990   root->AddChild(child.Pass()); |  4008   root->AddChild(child.Pass()); | 
|  3991   root_clip->AddChild(root.Pass()); |  4009   root_clip->AddChild(root.Pass()); | 
|  3992  |  4010  | 
|  3993   host_impl_->SetViewportSize(surface_size); |  4011   host_impl_->SetViewportSize(surface_size); | 
|  3994   host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |  4012   host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 
|  3995   host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID); |  4013   host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, | 
 |  4014                                                       Layer::INVALID_ID); | 
|  3996   host_impl_->active_tree()->DidBecomeActive(); |  4015   host_impl_->active_tree()->DidBecomeActive(); | 
|  3997   DrawFrame(); |  4016   DrawFrame(); | 
|  3998   { |  4017   { | 
|  3999     gfx::Vector2d scroll_delta(0, 8); |  4018     gfx::Vector2d scroll_delta(0, 8); | 
|  4000     EXPECT_EQ(InputHandler::ScrollStarted, |  4019     EXPECT_EQ(InputHandler::ScrollStarted, | 
|  4001               host_impl_->ScrollBegin(gfx::Point(5, 5), |  4020               host_impl_->ScrollBegin(gfx::Point(5, 5), | 
|  4002                                       InputHandler::Wheel)); |  4021                                       InputHandler::Wheel)); | 
|  4003     host_impl_->ScrollBy(gfx::Point(), scroll_delta); |  4022     host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 
|  4004     EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |  4023     EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 
|  4005     host_impl_->ScrollBy(gfx::Point(), scroll_delta); |  4024     host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4044   host_impl_->active_tree()->SetPageScaleFactorAndLimits( |  4063   host_impl_->active_tree()->SetPageScaleFactorAndLimits( | 
|  4045       0.326531f, 0.326531f, 5.f); |  4064       0.326531f, 0.326531f, 5.f); | 
|  4046   host_impl_->active_tree()->SetPageScaleDelta(1.f); |  4065   host_impl_->active_tree()->SetPageScaleDelta(1.f); | 
|  4047   child->SetScrollClipLayer(Layer::INVALID_ID); |  4066   child->SetScrollClipLayer(Layer::INVALID_ID); | 
|  4048   root->AddChild(child.Pass()); |  4067   root->AddChild(child.Pass()); | 
|  4049   root_clip->AddChild(root.Pass()); |  4068   root_clip->AddChild(root.Pass()); | 
|  4050  |  4069  | 
|  4051   host_impl_->SetViewportSize(surface_size); |  4070   host_impl_->SetViewportSize(surface_size); | 
|  4052   host_impl_->SetDeviceScaleFactor(device_scale_factor); |  4071   host_impl_->SetDeviceScaleFactor(device_scale_factor); | 
|  4053   host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |  4072   host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 
|  4054   host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID); |  4073   host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, | 
 |  4074                                                       Layer::INVALID_ID); | 
|  4055   host_impl_->active_tree()->DidBecomeActive(); |  4075   host_impl_->active_tree()->DidBecomeActive(); | 
|  4056   DrawFrame(); |  4076   DrawFrame(); | 
|  4057   { |  4077   { | 
|  4058     // Horizontal & Vertical GlowEffect should not be applied when |  4078     // Horizontal & Vertical GlowEffect should not be applied when | 
|  4059     // content size is less then view port size. For Example Horizontal & |  4079     // content size is less then view port size. For Example Horizontal & | 
|  4060     // vertical GlowEffect should not be applied in about:blank page. |  4080     // vertical GlowEffect should not be applied in about:blank page. | 
|  4061     EXPECT_EQ(InputHandler::ScrollStarted, |  4081     EXPECT_EQ(InputHandler::ScrollStarted, | 
|  4062               host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel)); |  4082               host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel)); | 
|  4063     host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -1)); |  4083     host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -1)); | 
|  4064     EXPECT_EQ(gfx::Vector2dF().ToString(), |  4084     EXPECT_EQ(gfx::Vector2dF().ToString(), | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  4078   root->SetIsContainerForFixedPositionLayers(true); |  4098   root->SetIsContainerForFixedPositionLayers(true); | 
|  4079   scoped_ptr<LayerImpl> child = |  4099   scoped_ptr<LayerImpl> child = | 
|  4080       CreateScrollableLayer(2, content_size, root_clip.get()); |  4100       CreateScrollableLayer(2, content_size, root_clip.get()); | 
|  4081  |  4101  | 
|  4082   child->SetScrollClipLayer(Layer::INVALID_ID); |  4102   child->SetScrollClipLayer(Layer::INVALID_ID); | 
|  4083   root->AddChild(child.Pass()); |  4103   root->AddChild(child.Pass()); | 
|  4084   root_clip->AddChild(root.Pass()); |  4104   root_clip->AddChild(root.Pass()); | 
|  4085  |  4105  | 
|  4086   host_impl_->SetViewportSize(surface_size); |  4106   host_impl_->SetViewportSize(surface_size); | 
|  4087   host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |  4107   host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 
|  4088   host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID); |  4108   host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, | 
 |  4109                                                       Layer::INVALID_ID); | 
|  4089   host_impl_->active_tree()->DidBecomeActive(); |  4110   host_impl_->active_tree()->DidBecomeActive(); | 
|  4090   DrawFrame(); |  4111   DrawFrame(); | 
|  4091   { |  4112   { | 
|  4092     // Edge glow effect should be applicable only upon reaching Edges |  4113     // Edge glow effect should be applicable only upon reaching Edges | 
|  4093     // of the content. unnecessary glow effect calls shouldn't be |  4114     // of the content. unnecessary glow effect calls shouldn't be | 
|  4094     // called while scrolling up without reaching the edge of the content. |  4115     // called while scrolling up without reaching the edge of the content. | 
|  4095     EXPECT_EQ(InputHandler::ScrollStarted, |  4116     EXPECT_EQ(InputHandler::ScrollStarted, | 
|  4096               host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel)); |  4117               host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel)); | 
|  4097     host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100)); |  4118     host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100)); | 
|  4098     EXPECT_EQ(gfx::Vector2dF().ToString(), |  4119     EXPECT_EQ(gfx::Vector2dF().ToString(), | 
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4788   context_provider->BindToCurrentThread(); |  4809   context_provider->BindToCurrentThread(); | 
|  4789   context_provider->TestContext3d()->set_have_post_sub_buffer(true); |  4810   context_provider->TestContext3d()->set_have_post_sub_buffer(true); | 
|  4790  |  4811  | 
|  4791   scoped_ptr<FakeOutputSurface> output_surface( |  4812   scoped_ptr<FakeOutputSurface> output_surface( | 
|  4792       FakeOutputSurface::Create3d(context_provider)); |  4813       FakeOutputSurface::Create3d(context_provider)); | 
|  4793   FakeOutputSurface* fake_output_surface = output_surface.get(); |  4814   FakeOutputSurface* fake_output_surface = output_surface.get(); | 
|  4794  |  4815  | 
|  4795   // This test creates its own LayerTreeHostImpl, so |  4816   // This test creates its own LayerTreeHostImpl, so | 
|  4796   // that we can force partial swap enabled. |  4817   // that we can force partial swap enabled. | 
|  4797   LayerTreeSettings settings; |  4818   LayerTreeSettings settings; | 
|  4798   settings.partial_swap_enabled = true; |  4819   settings.renderer_settings.partial_swap_enabled = true; | 
|  4799   scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |  4820   scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 
|  4800       new TestSharedBitmapManager()); |  4821       new TestSharedBitmapManager()); | 
|  4801   scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = |  4822   scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 
|  4802       LayerTreeHostImpl::Create(settings, |  4823       LayerTreeHostImpl::Create(settings, | 
|  4803                                 this, |  4824                                 this, | 
|  4804                                 &proxy_, |  4825                                 &proxy_, | 
|  4805                                 &stats_instrumentation_, |  4826                                 &stats_instrumentation_, | 
|  4806                                 shared_bitmap_manager.get(), |  4827                                 shared_bitmap_manager.get(), | 
|  4807                                 NULL, |  4828                                 NULL, | 
|  4808                                 0); |  4829                                 0); | 
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  5004   } |  5025   } | 
|  5005 }; |  5026 }; | 
|  5006  |  5027  | 
|  5007 TEST_F(LayerTreeHostImplTest, NoPartialSwap) { |  5028 TEST_F(LayerTreeHostImplTest, NoPartialSwap) { | 
|  5008   scoped_ptr<MockContext> mock_context_owned(new MockContext); |  5029   scoped_ptr<MockContext> mock_context_owned(new MockContext); | 
|  5009   MockContext* mock_context = mock_context_owned.get(); |  5030   MockContext* mock_context = mock_context_owned.get(); | 
|  5010   MockContextHarness harness(mock_context); |  5031   MockContextHarness harness(mock_context); | 
|  5011  |  5032  | 
|  5012   // Run test case |  5033   // Run test case | 
|  5013   LayerTreeSettings settings = DefaultSettings(); |  5034   LayerTreeSettings settings = DefaultSettings(); | 
|  5014   settings.partial_swap_enabled = false; |  5035   settings.renderer_settings.partial_swap_enabled = false; | 
|  5015   CreateHostImpl(settings, |  5036   CreateHostImpl(settings, | 
|  5016                  FakeOutputSurface::Create3d(mock_context_owned.Pass())); |  5037                  FakeOutputSurface::Create3d(mock_context_owned.Pass())); | 
|  5017   SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |  5038   SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 
|  5018  |  5039  | 
|  5019   // Without partial swap, and no clipping, no scissor is set. |  5040   // Without partial swap, and no clipping, no scissor is set. | 
|  5020   harness.MustDrawSolidQuad(); |  5041   harness.MustDrawSolidQuad(); | 
|  5021   harness.MustSetNoScissor(); |  5042   harness.MustSetNoScissor(); | 
|  5022   { |  5043   { | 
|  5023     LayerTreeHostImpl::FrameData frame; |  5044     LayerTreeHostImpl::FrameData frame; | 
|  5024     EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |  5045     EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  5040   } |  5061   } | 
|  5041   Mock::VerifyAndClearExpectations(&mock_context); |  5062   Mock::VerifyAndClearExpectations(&mock_context); | 
|  5042 } |  5063 } | 
|  5043  |  5064  | 
|  5044 TEST_F(LayerTreeHostImplTest, PartialSwap) { |  5065 TEST_F(LayerTreeHostImplTest, PartialSwap) { | 
|  5045   scoped_ptr<MockContext> context_owned(new MockContext); |  5066   scoped_ptr<MockContext> context_owned(new MockContext); | 
|  5046   MockContext* mock_context = context_owned.get(); |  5067   MockContext* mock_context = context_owned.get(); | 
|  5047   MockContextHarness harness(mock_context); |  5068   MockContextHarness harness(mock_context); | 
|  5048  |  5069  | 
|  5049   LayerTreeSettings settings = DefaultSettings(); |  5070   LayerTreeSettings settings = DefaultSettings(); | 
|  5050   settings.partial_swap_enabled = true; |  5071   settings.renderer_settings.partial_swap_enabled = true; | 
|  5051   CreateHostImpl(settings, FakeOutputSurface::Create3d(context_owned.Pass())); |  5072   CreateHostImpl(settings, FakeOutputSurface::Create3d(context_owned.Pass())); | 
|  5052   SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |  5073   SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 
|  5053  |  5074  | 
|  5054   // The first frame is not a partially-swapped one. |  5075   // The first frame is not a partially-swapped one. | 
|  5055   harness.MustSetScissor(0, 0, 10, 10); |  5076   harness.MustSetScissor(0, 0, 10, 10); | 
|  5056   harness.MustDrawSolidQuad(); |  5077   harness.MustDrawSolidQuad(); | 
|  5057   { |  5078   { | 
|  5058     LayerTreeHostImpl::FrameData frame; |  5079     LayerTreeHostImpl::FrameData frame; | 
|  5059     EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |  5080     EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 
|  5060     host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |  5081     host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
|  5084     Proxy* proxy, |  5105     Proxy* proxy, | 
|  5085     SharedBitmapManager* manager, |  5106     SharedBitmapManager* manager, | 
|  5086     RenderingStatsInstrumentation* stats_instrumentation) { |  5107     RenderingStatsInstrumentation* stats_instrumentation) { | 
|  5087   scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |  5108   scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 
|  5088   scoped_ptr<OutputSurface> output_surface( |  5109   scoped_ptr<OutputSurface> output_surface( | 
|  5089       FakeOutputSurface::Create3d(provider)); |  5110       FakeOutputSurface::Create3d(provider)); | 
|  5090   provider->BindToCurrentThread(); |  5111   provider->BindToCurrentThread(); | 
|  5091   provider->TestContext3d()->set_have_post_sub_buffer(true); |  5112   provider->TestContext3d()->set_have_post_sub_buffer(true); | 
|  5092  |  5113  | 
|  5093   LayerTreeSettings settings; |  5114   LayerTreeSettings settings; | 
|  5094   settings.partial_swap_enabled = partial_swap; |  5115   settings.renderer_settings.partial_swap_enabled = partial_swap; | 
|  5095   scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( |  5116   scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( | 
|  5096       settings, client, proxy, stats_instrumentation, manager, NULL, 0); |  5117       settings, client, proxy, stats_instrumentation, manager, NULL, 0); | 
|  5097   my_host_impl->InitializeRenderer(output_surface.Pass()); |  5118   my_host_impl->InitializeRenderer(output_surface.Pass()); | 
|  5098   my_host_impl->SetViewportSize(gfx::Size(100, 100)); |  5119   my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 
|  5099  |  5120  | 
|  5100   /* |  5121   /* | 
|  5101     Layers are created as follows: |  5122     Layers are created as follows: | 
|  5102  |  5123  | 
|  5103     +--------------------+ |  5124     +--------------------+ | 
|  5104     |                  1 | |  5125     |                  1 | | 
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  5257                                   GLintptr offset)); |  5278                                   GLintptr offset)); | 
|  5258 }; |  5279 }; | 
|  5259  |  5280  | 
|  5260 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { |  5281 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { | 
|  5261   scoped_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( |  5282   scoped_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( | 
|  5262       new MockDrawQuadsToFillScreenContext); |  5283       new MockDrawQuadsToFillScreenContext); | 
|  5263   MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); |  5284   MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); | 
|  5264  |  5285  | 
|  5265   // Run test case |  5286   // Run test case | 
|  5266   LayerTreeSettings settings = DefaultSettings(); |  5287   LayerTreeSettings settings = DefaultSettings(); | 
|  5267   settings.partial_swap_enabled = false; |  5288   settings.renderer_settings.partial_swap_enabled = false; | 
|  5268   CreateHostImpl(settings, |  5289   CreateHostImpl(settings, | 
|  5269                  FakeOutputSurface::Create3d(mock_context_owned.Pass())); |  5290                  FakeOutputSurface::Create3d(mock_context_owned.Pass())); | 
|  5270   SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |  5291   SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 
|  5271   host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |  5292   host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 
|  5272  |  5293  | 
|  5273   // Verify one quad is drawn when transparent background set is not set. |  5294   // Verify one quad is drawn when transparent background set is not set. | 
|  5274   host_impl_->active_tree()->set_has_transparent_background(false); |  5295   host_impl_->active_tree()->set_has_transparent_background(false); | 
|  5275   EXPECT_CALL(*mock_context, useProgram(_)) |  5296   EXPECT_CALL(*mock_context, useProgram(_)) | 
|  5276       .Times(1); |  5297       .Times(1); | 
|  5277   EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) |  5298   EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) | 
| (...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  6623   root->SetIsContainerForFixedPositionLayers(true); |  6644   root->SetIsContainerForFixedPositionLayers(true); | 
|  6624   scoped_ptr<LayerImpl> child = |  6645   scoped_ptr<LayerImpl> child = | 
|  6625       CreateScrollableLayer(2, content_size, root_clip.get()); |  6646       CreateScrollableLayer(2, content_size, root_clip.get()); | 
|  6626  |  6647  | 
|  6627   root->AddChild(child.Pass()); |  6648   root->AddChild(child.Pass()); | 
|  6628   int root_id = root->id(); |  6649   int root_id = root->id(); | 
|  6629   root_clip->AddChild(root.Pass()); |  6650   root_clip->AddChild(root.Pass()); | 
|  6630  |  6651  | 
|  6631   host_impl_->SetViewportSize(surface_size); |  6652   host_impl_->SetViewportSize(surface_size); | 
|  6632   host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |  6653   host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 
|  6633   host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID); |  6654   host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, | 
 |  6655                                                       Layer::INVALID_ID); | 
|  6634   host_impl_->active_tree()->DidBecomeActive(); |  6656   host_impl_->active_tree()->DidBecomeActive(); | 
|  6635   DrawFrame(); |  6657   DrawFrame(); | 
|  6636   { |  6658   { | 
|  6637     EXPECT_EQ(InputHandler::ScrollStarted, |  6659     EXPECT_EQ(InputHandler::ScrollStarted, | 
|  6638               host_impl_->ScrollBegin(gfx::Point(), |  6660               host_impl_->ScrollBegin(gfx::Point(), | 
|  6639                                       InputHandler::Gesture)); |  6661                                       InputHandler::Gesture)); | 
|  6640  |  6662  | 
|  6641     EXPECT_EQ(InputHandler::ScrollStarted, |  6663     EXPECT_EQ(InputHandler::ScrollStarted, | 
|  6642               host_impl_->FlingScrollBegin()); |  6664               host_impl_->FlingScrollBegin()); | 
|  6643  |  6665  | 
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  7465     contents->SetContentBounds(content_size); |  7487     contents->SetContentBounds(content_size); | 
|  7466     contents->SetPosition(gfx::PointF()); |  7488     contents->SetPosition(gfx::PointF()); | 
|  7467  |  7489  | 
|  7468     outer_scroll->AddChild(contents.Pass()); |  7490     outer_scroll->AddChild(contents.Pass()); | 
|  7469     outer_clip->AddChild(outer_scroll.Pass()); |  7491     outer_clip->AddChild(outer_scroll.Pass()); | 
|  7470     inner_scroll->AddChild(outer_clip.Pass()); |  7492     inner_scroll->AddChild(outer_clip.Pass()); | 
|  7471     page_scale->AddChild(inner_scroll.Pass()); |  7493     page_scale->AddChild(inner_scroll.Pass()); | 
|  7472     inner_clip->AddChild(page_scale.Pass()); |  7494     inner_clip->AddChild(page_scale.Pass()); | 
|  7473  |  7495  | 
|  7474     layer_tree_impl->SetRootLayer(inner_clip.Pass()); |  7496     layer_tree_impl->SetRootLayer(inner_clip.Pass()); | 
|  7475     layer_tree_impl->SetViewportLayersFromIds(kPageScaleLayerId, |  7497     layer_tree_impl->SetViewportLayersFromIds( | 
|  7476         kInnerViewportScrollLayerId, kOuterViewportScrollLayerId); |  7498         Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 
 |  7499         kOuterViewportScrollLayerId); | 
|  7477  |  7500  | 
|  7478     host_impl_->active_tree()->DidBecomeActive(); |  7501     host_impl_->active_tree()->DidBecomeActive(); | 
|  7479   } |  7502   } | 
|  7480 }; |  7503 }; | 
|  7481  |  7504  | 
|  7482 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { |  7505 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { | 
|  7483   gfx::Size content_size = gfx::Size(100, 160); |  7506   gfx::Size content_size = gfx::Size(100, 160); | 
|  7484   gfx::Size outer_viewport = gfx::Size(50, 80); |  7507   gfx::Size outer_viewport = gfx::Size(50, 80); | 
|  7485   gfx::Size inner_viewport = gfx::Size(25, 40); |  7508   gfx::Size inner_viewport = gfx::Size(25, 40); | 
|  7486  |  7509  | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  7520     host_impl_->ScrollBy(gfx::Point(), scroll_delta); |  7543     host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 
|  7521     inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |  7544     inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 
|  7522  |  7545  | 
|  7523     host_impl_->ScrollEnd(); |  7546     host_impl_->ScrollEnd(); | 
|  7524  |  7547  | 
|  7525     EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); |  7548     EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 
|  7526     EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); |  7549     EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 
|  7527   } |  7550   } | 
|  7528 } |  7551 } | 
|  7529  |  7552  | 
 |  7553 TEST_F(LayerTreeHostImplVirtualViewportTest, | 
 |  7554        DiagonalScrollBubblesPerfectlyToInner) { | 
 |  7555   gfx::Size content_size = gfx::Size(100, 160); | 
 |  7556   gfx::Size outer_viewport = gfx::Size(50, 80); | 
 |  7557   gfx::Size inner_viewport = gfx::Size(25, 40); | 
 |  7558  | 
 |  7559   SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 
 |  7560  | 
 |  7561   LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 
 |  7562   LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 
 |  7563   DrawFrame(); | 
 |  7564   { | 
 |  7565     gfx::Vector2dF inner_expected; | 
 |  7566     gfx::Vector2dF outer_expected; | 
 |  7567     EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 
 |  7568     EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 
 |  7569  | 
 |  7570     // Make sure the scroll goes to the outer viewport first. | 
 |  7571     EXPECT_EQ(InputHandler::ScrollStarted, | 
 |  7572               host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 
 |  7573     EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); | 
 |  7574  | 
 |  7575     // Scroll near the edge of the outer viewport. | 
 |  7576     gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); | 
 |  7577     host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 
 |  7578     outer_expected += scroll_delta; | 
 |  7579  | 
 |  7580     EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 
 |  7581     EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 
 |  7582  | 
 |  7583     // Now diagonal scroll across the outer viewport boundary in a single event. | 
 |  7584     // The entirety of the scroll should be consumed, as bubbling between inner | 
 |  7585     // and outer viewport layers is perfect. | 
 |  7586     host_impl_->ScrollBy(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)); | 
 |  7587     outer_expected += scroll_delta; | 
 |  7588     inner_expected += scroll_delta; | 
 |  7589     host_impl_->ScrollEnd(); | 
 |  7590  | 
 |  7591     EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 
 |  7592     EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 
 |  7593   } | 
 |  7594 } | 
 |  7595  | 
|  7530 class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest { |  7596 class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest { | 
|  7531  public: |  7597  public: | 
|  7532   void SetUp() override { |  7598   void SetUp() override { | 
|  7533     LayerTreeSettings settings = DefaultSettings(); |  7599     LayerTreeSettings settings = DefaultSettings(); | 
|  7534     settings.max_memory_for_prepaint_percentage = 50; |  7600     settings.max_memory_for_prepaint_percentage = 50; | 
|  7535     CreateHostImpl(settings, CreateOutputSurface()); |  7601     CreateHostImpl(settings, CreateOutputSurface()); | 
|  7536   } |  7602   } | 
|  7537 }; |  7603 }; | 
|  7538  |  7604  | 
|  7539 TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) { |  7605 TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) { | 
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  7749   // surface. |  7815   // surface. | 
|  7750   EXPECT_EQ(0, num_lost_surfaces_); |  7816   EXPECT_EQ(0, num_lost_surfaces_); | 
|  7751   host_impl_->DidLoseOutputSurface(); |  7817   host_impl_->DidLoseOutputSurface(); | 
|  7752   EXPECT_EQ(1, num_lost_surfaces_); |  7818   EXPECT_EQ(1, num_lost_surfaces_); | 
|  7753   host_impl_->DidLoseOutputSurface(); |  7819   host_impl_->DidLoseOutputSurface(); | 
|  7754   EXPECT_LE(1, num_lost_surfaces_); |  7820   EXPECT_LE(1, num_lost_surfaces_); | 
|  7755 } |  7821 } | 
|  7756  |  7822  | 
|  7757 }  // namespace |  7823 }  // namespace | 
|  7758 }  // namespace cc |  7824 }  // namespace cc | 
| OLD | NEW |