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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 always_impl_thread_(&proxy_), | 85 always_impl_thread_(&proxy_), |
86 always_main_thread_blocked_(&proxy_), | 86 always_main_thread_blocked_(&proxy_), |
87 shared_bitmap_manager_(new TestSharedBitmapManager), | 87 shared_bitmap_manager_(new TestSharedBitmapManager), |
88 gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager), | 88 gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager), |
89 on_can_draw_state_changed_called_(false), | 89 on_can_draw_state_changed_called_(false), |
90 did_notify_ready_to_activate_(false), | 90 did_notify_ready_to_activate_(false), |
91 did_request_commit_(false), | 91 did_request_commit_(false), |
92 did_request_redraw_(false), | 92 did_request_redraw_(false), |
93 did_request_animate_(false), | 93 did_request_animate_(false), |
94 did_request_prepare_tiles_(false), | 94 did_request_prepare_tiles_(false), |
| 95 did_complete_page_scale_animation_(false), |
95 reduce_memory_result_(true), | 96 reduce_memory_result_(true), |
96 current_limit_bytes_(0), | 97 current_limit_bytes_(0), |
97 current_priority_cutoff_value_(0) { | 98 current_priority_cutoff_value_(0) { |
98 media::InitializeMediaLibraryForTesting(); | 99 media::InitializeMediaLibraryForTesting(); |
99 } | 100 } |
100 | 101 |
101 LayerTreeSettings DefaultSettings() { | 102 LayerTreeSettings DefaultSettings() { |
102 LayerTreeSettings settings; | 103 LayerTreeSettings settings; |
103 settings.minimum_occlusion_tracking_size = gfx::Size(); | 104 settings.minimum_occlusion_tracking_size = gfx::Size(); |
104 settings.impl_side_painting = true; | 105 settings.impl_side_painting = true; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 150 } |
150 bool IsInsideDraw() override { return false; } | 151 bool IsInsideDraw() override { return false; } |
151 void RenewTreePriority() override {} | 152 void RenewTreePriority() override {} |
152 void PostDelayedScrollbarFadeOnImplThread(const base::Closure& start_fade, | 153 void PostDelayedScrollbarFadeOnImplThread(const base::Closure& start_fade, |
153 base::TimeDelta delay) override { | 154 base::TimeDelta delay) override { |
154 scrollbar_fade_start_ = start_fade; | 155 scrollbar_fade_start_ = start_fade; |
155 requested_scrollbar_animation_delay_ = delay; | 156 requested_scrollbar_animation_delay_ = delay; |
156 } | 157 } |
157 void DidActivateSyncTree() override {} | 158 void DidActivateSyncTree() override {} |
158 void DidPrepareTiles() override {} | 159 void DidPrepareTiles() override {} |
| 160 void DidCompletePageScaleAnimationOnImplThread() override { |
| 161 did_complete_page_scale_animation_ = true; |
| 162 } |
159 | 163 |
160 void set_reduce_memory_result(bool reduce_memory_result) { | 164 void set_reduce_memory_result(bool reduce_memory_result) { |
161 reduce_memory_result_ = reduce_memory_result; | 165 reduce_memory_result_ = reduce_memory_result; |
162 } | 166 } |
163 | 167 |
164 virtual bool CreateHostImpl(const LayerTreeSettings& settings, | 168 virtual bool CreateHostImpl(const LayerTreeSettings& settings, |
165 scoped_ptr<OutputSurface> output_surface) { | 169 scoped_ptr<OutputSurface> output_surface) { |
166 host_impl_ = LayerTreeHostImpl::Create(settings, | 170 host_impl_ = LayerTreeHostImpl::Create(settings, |
167 this, | 171 this, |
168 &proxy_, | 172 &proxy_, |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; | 396 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; |
393 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; | 397 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
394 scoped_ptr<LayerTreeHostImpl> host_impl_; | 398 scoped_ptr<LayerTreeHostImpl> host_impl_; |
395 FakeRenderingStatsInstrumentation stats_instrumentation_; | 399 FakeRenderingStatsInstrumentation stats_instrumentation_; |
396 bool on_can_draw_state_changed_called_; | 400 bool on_can_draw_state_changed_called_; |
397 bool did_notify_ready_to_activate_; | 401 bool did_notify_ready_to_activate_; |
398 bool did_request_commit_; | 402 bool did_request_commit_; |
399 bool did_request_redraw_; | 403 bool did_request_redraw_; |
400 bool did_request_animate_; | 404 bool did_request_animate_; |
401 bool did_request_prepare_tiles_; | 405 bool did_request_prepare_tiles_; |
| 406 bool did_complete_page_scale_animation_; |
402 bool reduce_memory_result_; | 407 bool reduce_memory_result_; |
403 base::Closure scrollbar_fade_start_; | 408 base::Closure scrollbar_fade_start_; |
404 base::TimeDelta requested_scrollbar_animation_delay_; | 409 base::TimeDelta requested_scrollbar_animation_delay_; |
405 size_t current_limit_bytes_; | 410 size_t current_limit_bytes_; |
406 int current_priority_cutoff_value_; | 411 int current_priority_cutoff_value_; |
407 }; | 412 }; |
408 | 413 |
409 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { | 414 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { |
410 bool always_draw = false; | 415 bool always_draw = false; |
411 CheckNotifyCalledIfCanDrawChanged(always_draw); | 416 CheckNotifyCalledIfCanDrawChanged(always_draw); |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 host_impl_->Animate(end_time); | 1344 host_impl_->Animate(end_time); |
1340 EXPECT_TRUE(did_request_commit_); | 1345 EXPECT_TRUE(did_request_commit_); |
1341 EXPECT_FALSE(did_request_animate_); | 1346 EXPECT_FALSE(did_request_animate_); |
1342 | 1347 |
1343 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1348 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1344 host_impl_->ProcessScrollDeltas(); | 1349 host_impl_->ProcessScrollDeltas(); |
1345 EXPECT_EQ(scroll_info->page_scale_delta, target_scale); | 1350 EXPECT_EQ(scroll_info->page_scale_delta, target_scale); |
1346 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); | 1351 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); |
1347 } | 1352 } |
1348 | 1353 |
| 1354 TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) { |
| 1355 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 1356 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1357 DrawFrame(); |
| 1358 |
| 1359 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1360 DCHECK(scroll_layer); |
| 1361 |
| 1362 base::TimeTicks start_time = |
| 1363 base::TimeTicks() + base::TimeDelta::FromSeconds(1); |
| 1364 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
| 1365 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
| 1366 base::TimeTicks end_time = start_time + duration; |
| 1367 |
| 1368 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 1369 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); |
| 1370 |
| 1371 did_complete_page_scale_animation_ = false; |
| 1372 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
| 1373 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
| 1374 gfx::Vector2d(), false, 2.f, duration))); |
| 1375 host_impl_->ActivateSyncTree(); |
| 1376 host_impl_->Animate(start_time); |
| 1377 EXPECT_FALSE(did_complete_page_scale_animation_); |
| 1378 |
| 1379 host_impl_->Animate(halfway_through_animation); |
| 1380 EXPECT_FALSE(did_complete_page_scale_animation_); |
| 1381 |
| 1382 host_impl_->Animate(end_time); |
| 1383 EXPECT_TRUE(did_complete_page_scale_animation_); |
| 1384 } |
| 1385 |
1349 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { | 1386 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { |
1350 public: | 1387 public: |
1351 LayerTreeHostImplOverridePhysicalTime( | 1388 LayerTreeHostImplOverridePhysicalTime( |
1352 const LayerTreeSettings& settings, | 1389 const LayerTreeSettings& settings, |
1353 LayerTreeHostImplClient* client, | 1390 LayerTreeHostImplClient* client, |
1354 Proxy* proxy, | 1391 Proxy* proxy, |
1355 SharedBitmapManager* manager, | 1392 SharedBitmapManager* manager, |
1356 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 1393 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
1357 : LayerTreeHostImpl(settings, | 1394 : LayerTreeHostImpl(settings, |
1358 client, | 1395 client, |
(...skipping 6694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8053 // surface. | 8090 // surface. |
8054 EXPECT_EQ(0, num_lost_surfaces_); | 8091 EXPECT_EQ(0, num_lost_surfaces_); |
8055 host_impl_->DidLoseOutputSurface(); | 8092 host_impl_->DidLoseOutputSurface(); |
8056 EXPECT_EQ(1, num_lost_surfaces_); | 8093 EXPECT_EQ(1, num_lost_surfaces_); |
8057 host_impl_->DidLoseOutputSurface(); | 8094 host_impl_->DidLoseOutputSurface(); |
8058 EXPECT_LE(1, num_lost_surfaces_); | 8095 EXPECT_LE(1, num_lost_surfaces_); |
8059 } | 8096 } |
8060 | 8097 |
8061 } // namespace | 8098 } // namespace |
8062 } // namespace cc | 8099 } // namespace cc |
OLD | NEW |